renusify 2.3.1 → 2.4.0

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.
@@ -1,110 +1,110 @@
1
1
  <template>
2
- <r-input v-bind="$attrs" :readonly="readonly" :model-value="modelValue" @click.prevent="show=true">
3
- <input
4
- :value="modelValue?$d(modelValueDate,withTime?'long':'medium',locale):null"
5
- />
6
- </r-input>
7
- <r-modal :model-value="show" @update:model-value="close()" :closebtn="false" closable class="text-center">
8
- <div v-if="!showTime" :class="`${$r.prefix}date-input`">
9
- <div>
10
- <r-container>
11
- <r-row>
12
- <r-col class="col-auto">
13
- <r-btn v-if="tab!=='month'" icon
14
- @click.prevent="tab==='day'?incrementMonth(-1):incrementYear(-12)">
15
- <r-icon v-html="$r.icons.arrow_left"></r-icon>
16
- </r-btn>
17
- </r-col>
18
- <r-col class="text-center">
19
- <r-btn class="me-2" text @click.prevent="tab==='month'?tab='day':tab='month'">
20
- <r-icon v-html="tab==='month'?$r.icons.chevron_up:$r.icons.chevron_down"></r-icon>
21
- {{
22
- $d(new
23
- Date(currentPeriod.year, currentPeriod.month, 1, 0, lang_zone_offset - timezoneOffset), 'month', locale)
24
- }}
25
- </r-btn>
26
-
27
- <r-btn text @click.prevent="tab==='year'?tab='day':tab='year'">
28
- <r-icon v-html="tab==='year'?$r.icons.chevron_up:$r.icons.chevron_down"></r-icon>
29
- {{
30
- $d(new
31
- Date(currentPeriod.year, currentPeriod.month, 1, 0, lang_zone_offset - timezoneOffset), 'year', locale)
32
- }}
33
- </r-btn>
34
- </r-col>
35
- <r-col class="col-auto">
36
- <r-btn v-if="tab!=='month'" icon
37
- @click.prevent="tab==='day'?incrementMonth(1):incrementYear(12)">
38
- <r-icon v-html="$r.icons.arrow_right"></r-icon>
39
- </r-btn>
40
- </r-col>
41
- </r-row>
42
- </r-container>
43
- <year-tab v-if="tab==='year'"
44
- :model-value='currentPeriod.year'
45
- @update:model-value="(tab='month',setYear($event))"
46
- :timezoneOffset="lang_zone_offset-timezoneOffset"
47
- :locale="locale"
48
- :month="currentPeriod.month"></year-tab>
49
- <month-tab v-if="tab==='month'"
50
- :model-value='currentPeriod.month'
51
- @update:model-value="(tab='day',setMonth($event))"
52
- :timezoneOffset="lang_zone_offset-timezoneOffset"
53
- :locale="locale"
54
- :month="currentPeriod.month"
55
- :year="currentPeriod.year"></month-tab>
56
- <table v-if="tab==='day'" class="table">
57
- <thead>
58
- <tr>
59
- <th class="headCell" v-for="(weekday, weekdayIndex) in weekDays" :key="weekdayIndex">
60
- <span class="headCellContent">{{ weekday }}</span>
61
- </th>
62
- </tr>
63
- </thead>
64
- <transition :name="direction==='next'?'slide-start-to-end':'slide-end-to-start'" mode="out-in">
65
- <tbody
66
- :key="currentPeriod.year + '-' + currentPeriod.month"
67
- >
68
- <tr class="table-row" v-for="(week, weekIndex) in currentPeriodDates" :key="weekIndex">
69
- <td
70
- class="cell"
71
- v-for="item in week"
72
- :class="{
2
+ <r-input v-bind="$attrs" :readonly="readonly" :model-value="modelValue" @click.prevent="show=true">
3
+ <input
4
+ :value="modelValue?$d(modelValueDate,withTime?'long':'medium',locale):null"
5
+ />
6
+ </r-input>
7
+ <r-modal :model-value="show" @update:model-value="close()" :closebtn="false" closable class="text-center">
8
+ <div v-if="!showTime" :class="`${$r.prefix}date-input`">
9
+ <div>
10
+ <r-container>
11
+ <r-row>
12
+ <r-col class="col-auto">
13
+ <r-btn v-if="tab!=='month'" icon
14
+ @click.prevent="tab==='day'?incrementMonth(-1):incrementYear(-12)">
15
+ <r-icon v-html="$r.icons.arrow_left"></r-icon>
16
+ </r-btn>
17
+ </r-col>
18
+ <r-col class="text-center">
19
+ <r-btn class="me-2" text @click.prevent="tab==='month'?tab='day':tab='month'">
20
+ <r-icon v-html="tab==='month'?$r.icons.chevron_up:$r.icons.chevron_down"></r-icon>
21
+ {{
22
+ $d(new
23
+ Date(currentPeriod.year, currentPeriod.month, 1, 0, lang_zone_offset - timezoneOffset), 'month', locale)
24
+ }}
25
+ </r-btn>
26
+
27
+ <r-btn text @click.prevent="tab==='year'?tab='day':tab='year'">
28
+ <r-icon v-html="tab==='year'?$r.icons.chevron_up:$r.icons.chevron_down"></r-icon>
29
+ {{
30
+ $d(new
31
+ Date(currentPeriod.year, currentPeriod.month, 1, 0, lang_zone_offset - timezoneOffset), 'year', locale)
32
+ }}
33
+ </r-btn>
34
+ </r-col>
35
+ <r-col class="col-auto">
36
+ <r-btn v-if="tab!=='month'" icon
37
+ @click.prevent="tab==='day'?incrementMonth(1):incrementYear(12)">
38
+ <r-icon v-html="$r.icons.arrow_right"></r-icon>
39
+ </r-btn>
40
+ </r-col>
41
+ </r-row>
42
+ </r-container>
43
+ <year-tab v-if="tab==='year'"
44
+ :model-value='currentPeriod.year'
45
+ @update:model-value="(tab='month',incrementYear($event))"
46
+ :timezoneOffset="lang_zone_offset-timezoneOffset"
47
+ :locale="locale"
48
+ :month="currentPeriod.month"></year-tab>
49
+ <month-tab v-if="tab==='month'"
50
+ :model-value='currentPeriod.month'
51
+ @update:model-value="(tab='day',setMonth($event))"
52
+ :timezoneOffset="lang_zone_offset-timezoneOffset"
53
+ :locale="locale"
54
+ :month="currentPeriod.month"
55
+ :year="currentPeriod.year"></month-tab>
56
+ <table v-if="tab==='day'" class="table">
57
+ <thead>
58
+ <tr>
59
+ <th class="headCell" v-for="(weekday, weekdayIndex) in weekDays" :key="weekdayIndex">
60
+ <span class="headCellContent">{{ weekday }}</span>
61
+ </th>
62
+ </tr>
63
+ </thead>
64
+ <transition :name="direction==='next'?'slide-start-to-end':'slide-end-to-start'" mode="out-in">
65
+ <tbody
66
+ :key="currentPeriod.year + '-' + currentPeriod.month"
67
+ >
68
+ <tr class="table-row" v-for="(week, weekIndex) in currentPeriodDates" :key="weekIndex">
69
+ <td
70
+ class="cell"
71
+ v-for="item in week"
72
+ :class="{
73
73
  selectable: !readonly && !item.disabled,
74
74
  selected: item.selected,
75
75
  disabled: item.disabled,
76
76
  today: item.today
77
77
  }"
78
- :key="item.date"
79
- @click.prevent="item.date!==0 &&!readonly&& selectDateItem(item)"
80
- >
81
- <div
82
- class="cellContent d-flex h-center v-center"
83
- v-if="item.date!==0"
84
- >
85
- {{ $d(item.date, 'day', locale) }}
86
- </div>
87
- </td>
88
- </tr>
89
- </tbody>
90
- </transition>
91
- </table>
92
- </div>
93
- </div>
94
- <div v-else class="d-flex flex-column h-center v-center pa-5">
95
- <timepicker
96
- is24-hour
97
- withSec
98
- v-model="time"
99
- ></timepicker>
100
- <div class="mt-5">
101
- <r-btn class="color-success mx-5" @click.prevent="selectTime">{{ $t('ok', 'renusify') }}</r-btn>
102
- <r-btn class="color-error mx-5" @click.prevent="close">{{ $t('cancel', 'renusify') }}</r-btn>
103
- </div>
104
-
105
- </div>
106
-
107
- </r-modal>
78
+ :key="item.date"
79
+ @click.prevent="item.date!==0 &&!readonly&& selectDateItem(item)"
80
+ >
81
+ <div
82
+ class="cellContent d-flex h-center v-center"
83
+ v-if="item.date!==0"
84
+ >
85
+ {{ $d(item.date, 'day', locale) }}
86
+ </div>
87
+ </td>
88
+ </tr>
89
+ </tbody>
90
+ </transition>
91
+ </table>
92
+ </div>
93
+ </div>
94
+ <div v-else class="d-flex flex-column h-center v-center pa-5">
95
+ <timepicker
96
+ is24-hour
97
+ withSec
98
+ v-model="time"
99
+ ></timepicker>
100
+ <div class="mt-5">
101
+ <r-btn class="color-success mx-5" @click.prevent="selectTime">{{ $t('ok', 'renusify') }}</r-btn>
102
+ <r-btn class="color-error mx-5" @click.prevent="close">{{ $t('cancel', 'renusify') }}</r-btn>
103
+ </div>
104
+
105
+ </div>
106
+
107
+ </r-modal>
108
108
 
109
109
  </template>
110
110
 
@@ -112,261 +112,251 @@
112
112
  import {defineAsyncComponent} from 'vue'
113
113
 
114
114
  export default {
115
- name: 'datePicker',
116
- components: {
117
- MonthTab: defineAsyncComponent(() => import('./month.vue')),
118
- YearTab: defineAsyncComponent(() => import('./year.vue')),
119
- Timepicker: defineAsyncComponent(() => import('../timeInput/timepicker.vue'))
115
+ name: 'datePicker',
116
+ components: {
117
+ MonthTab: defineAsyncComponent(() => import('./month.vue')),
118
+ YearTab: defineAsyncComponent(() => import('./year.vue')),
119
+ Timepicker: defineAsyncComponent(() => import('../timeInput/timepicker.vue'))
120
+ },
121
+ inheritAttrs: false,
122
+ props: {
123
+ modelValue: {
124
+ type: String
120
125
  },
121
- inheritAttrs: false,
122
- props: {
123
- modelValue: {
124
- type: String
125
- },
126
- lang: {
127
- type: String
128
- },
129
- readonly: Boolean,
130
- withTime: Boolean,
131
- isDateDisabled: {
132
- type: Function,
133
- default: () => false
134
- }
126
+ lang: {
127
+ type: String
135
128
  },
136
- emits: ['update:modelValue'],
137
- data() {
138
- return {
139
- tab: 'day',
140
- show: false,
141
- showTime: false,
142
- time: null,
143
- date: null,
144
- direction: undefined,
145
- currentPeriod: {
146
- month: (new Date()).getMonth() + 1,
147
- year: (new Date()).getFullYear()
148
- }
149
- }
129
+ readonly: Boolean,
130
+ withTime: Boolean,
131
+ isDateDisabled: {
132
+ type: Function,
133
+ default: () => false
134
+ }
135
+ },
136
+ emits: ['update:modelValue'],
137
+ data() {
138
+ return {
139
+ tab: 'day',
140
+ show: false,
141
+ showTime: false,
142
+ time: null,
143
+ date: null,
144
+ direction: undefined,
145
+ currentPeriod: {
146
+ month: (new Date()).getMonth() + 1,
147
+ year: (new Date()).getFullYear()
148
+ }
149
+ }
150
+ },
151
+ created() {
152
+ this.$dateTime.set_format({
153
+ 'de': {
154
+ day: 'numeric',
155
+ numberingSystem: 'latn'
156
+ },
157
+ 'me': {
158
+ month: 'numeric',
159
+ numberingSystem: 'latn'
160
+ },
161
+ 'ye': {
162
+ year: 'numeric',
163
+ numberingSystem: 'latn'
164
+ }
165
+ })
166
+ this.currentPeriod = {
167
+ month: this.modelValueDate.getMonth() + 1,
168
+ year: this.modelValueDate.getFullYear()
169
+ }
170
+ if (this.rangeLocalDate.start > this.modelValueDate) {
171
+ this.incrementMonth(-1)
172
+ }
173
+ if (this.rangeLocalDate.end < this.modelValueDate) {
174
+ this.incrementMonth(1)
175
+ }
176
+ },
177
+ computed: {
178
+ firstDayOfWeek() {
179
+ return this.$helper.ifHas(this.$dateTime.langs, 0, this.locale, 'first_day')
180
+ },
181
+ locale() {
182
+ return this.lang || this.$r.lang
183
+ },
184
+ today() {
185
+ return new Date()
186
+ },
187
+
188
+ weekDays() {
189
+ const first = parseInt(this.firstDayOfWeek, 10)
190
+
191
+ return this.createRange(7).map(i => this.$d(new Date(2025, 2, first + i + 23, 0, this.lang_zone_offset - this.timezoneOffset, 0), 'narrow', this.locale)) // 2017-02-02 is Sunday
150
192
  },
151
- created() {
152
- this.$dateTime.set_format({
153
- 'de': {
154
- day: 'numeric',
155
- numberingSystem: 'latn'
156
- },
157
- 'me': {
158
- month: 'numeric',
159
- numberingSystem: 'latn'
160
- }
193
+ modelValueDate() {
194
+ if (!this.modelValue || !new Date(this.modelValue)) {
195
+ return new Date()
196
+ }
197
+ return new Date(this.modelValue)
198
+ },
199
+ rangeLocalDate() {
200
+ const {year, month} = this.currentPeriod
201
+ let firstDay = 1
202
+ let firstmonth = month
203
+ let firstyear = year
204
+ let first = new Date(firstyear, firstmonth, firstDay, 0, this.lang_zone_offset - this.timezoneOffset, 0)
205
+ let lc = parseInt(this.$d(first, 'de', this.locale))
206
+ first = new Date(firstyear, firstmonth, firstDay - lc + 1, 0, this.lang_zone_offset - this.timezoneOffset, 0)
207
+
208
+ firstDay = 1
209
+ firstmonth = month + 1
210
+ firstyear = year
211
+ let last = new Date(firstyear, firstmonth, firstDay, 0, this.lang_zone_offset - this.timezoneOffset, 0)
212
+ lc = parseInt(this.$d(last, 'de', this.locale))
213
+ last = new Date(firstyear, firstmonth, firstDay - lc, 23, 59 + this.lang_zone_offset - this.timezoneOffset, 59)
214
+
215
+ return {start: first, end: last}
216
+ },
217
+ weekDaysBeforeFirstDayOfTheMonth() {
218
+ const {start} = this.rangeLocalDate
219
+ const weekDay = start.getDay()
220
+ return (weekDay - parseInt(this.firstDayOfWeek) + 7) % 7
221
+ },
222
+ currentPeriodDates() {
223
+ const {start, end} = this.rangeLocalDate
224
+ const children = []
225
+ let firstday = start.getDate()
226
+ let firstmonth = start.getMonth()
227
+ let firstyear = start.getFullYear()
228
+ let rows = []
229
+ let day = this.weekDaysBeforeFirstDayOfTheMonth
230
+
231
+ while (day--) {
232
+ rows.push({
233
+ date: 0,
234
+ disabled: true,
235
+ selected: false,
236
+ today: false
161
237
  })
162
- this.currentPeriod = {
163
- month: this.modelValueDate.getMonth() + 1,
164
- year: this.modelValueDate.getFullYear()
165
- }
166
- if (this.rangeLocalDate.start > this.modelValueDate) {
167
- this.incrementMonth(-1)
168
- }
169
- if (this.rangeLocalDate.end < this.modelValueDate) {
170
- this.incrementMonth(1)
238
+ }
239
+ let doJob = true
240
+ while (doJob) {
241
+ const date = new Date(firstyear, firstmonth, 1, 24, this.lang_zone_offset - this.timezoneOffset, 0)
242
+ date.setDate(firstday)
243
+ firstmonth = date.getMonth()
244
+ firstyear = date.getFullYear()
245
+ firstday = date.getDate() + 1
246
+ if (date.getTime() > end.getTime()) {
247
+ doJob = false
248
+ } else {
249
+ rows.push({
250
+ date: date,
251
+ disabled: this.isDateDisabled(date),
252
+ selected: this.areSameDates(date, this.modelValueDate),
253
+ today: this.areSameDates(date, this.today)
254
+ })
255
+
256
+ if (rows.length % 7 === 0) {
257
+ children.push(rows)
258
+ rows = []
259
+ }
171
260
  }
261
+ }
262
+
263
+ if (rows.length) {
264
+ children.push(rows)
265
+ }
266
+
267
+ return children
172
268
  },
173
- computed: {
174
- firstDayOfWeek() {
175
- return this.$helper.ifHas(this.$dateTime.langs, 0, this.locale, 'first_day')
176
- },
177
- locale() {
178
- return this.lang || this.$r.lang
179
- },
180
- today() {
181
- return new Date()
182
- },
183
- timezoneOffset() {
184
- return (new Date(this.currentPeriod.year, this.currentPeriod.month, 10)).getTimezoneOffset()
185
- },
186
- weekDays() {
187
- const first = parseInt(this.firstDayOfWeek, 10)
188
-
189
- return this.createRange(7).map(i => this.$d(new Date(2020, 2, first + i + 2, 0, this.timezoneOffset, 0), 'narrow', this.locale)) // 2017-02-02 is Sunday
190
- },
191
- modelValueDate() {
192
- if (!this.modelValue || !new Date(this.modelValue)) {
193
- return new Date()
194
- }
195
- return new Date(this.modelValue)
196
- },
197
- rangeLocalDate() {
198
- const {year, month} = this.currentPeriod
199
- let firstDay = 1
200
- let firstmonth = month
201
- let firstyear = year
202
-
203
- let first = new Date(firstyear, firstmonth, firstDay, 0, this.lang_zone_offset - this.timezoneOffset, 0)
204
- let lc = parseInt(this.$d(first, 'de', this.locale))
205
- first = new Date(firstyear, firstmonth, firstDay - lc + 1, 0, this.lang_zone_offset - this.timezoneOffset, 0)
206
-
207
- firstDay = 1
208
- firstmonth = month + 1
209
- firstyear = year
210
- let last = new Date(firstyear, firstmonth, firstDay, 0, this.lang_zone_offset - this.timezoneOffset, 0)
211
- lc = parseInt(this.$d(last, 'de', this.locale))
212
- last = new Date(firstyear, firstmonth, firstDay - lc, 23, 59 + this.lang_zone_offset - this.timezoneOffset, 59)
213
-
214
- return {start: first, end: last}
215
- },
216
- weekDaysBeforeFirstDayOfTheMonth() {
217
- const {start} = this.rangeLocalDate
218
- const weekDay = start.getDay()
219
- return (weekDay - parseInt(this.firstDayOfWeek) + 7) % 7
220
- },
221
- currentPeriodDates() {
222
- const {start, end} = this.rangeLocalDate
223
- const children = []
224
- let firstday = start.getDate()
225
- let firstmonth = start.getMonth()
226
- let firstyear = start.getFullYear()
227
- let rows = []
228
- let day = this.weekDaysBeforeFirstDayOfTheMonth
229
-
230
- while (day--) {
231
- rows.push({
232
- date: 0,
233
- disabled: true,
234
- selected: false,
235
- today: false
236
- })
237
- }
238
- let doJob = true
239
- while (doJob) {
240
- const date = new Date(firstyear, firstmonth, 1, 24, this.lang_zone_offset - this.timezoneOffset, 0)
241
- date.setDate(firstday)
242
- firstmonth = date.getMonth()
243
- firstyear = date.getFullYear()
244
- firstday = date.getDate() + 1
245
- if (date.getTime() > end.getTime()) {
246
- doJob = false
247
- } else {
248
- rows.push({
249
- date: date,
250
- disabled: this.isDateDisabled(date),
251
- selected: this.areSameDates(date, this.modelValueDate),
252
- today: this.areSameDates(date, this.today)
253
- })
254
-
255
- if (rows.length % 7 === 0) {
256
- children.push(rows)
257
- rows = []
258
- }
259
- }
260
- }
261
-
262
- if (rows.length) {
263
- children.push(rows)
264
- }
265
-
266
- return children
267
- },
268
- lang_zone_offset() {
269
- let offset = this.$helper.ifHas(this.$dateTime.langs, 0, this.locale, 'time_zone_offset')
270
- let dst = this.$helper.ifHas(this.$dateTime.langs, false, this.locale, 'daylight_saving_time')
271
-
272
- const m = this.$d(new Date(this.currentPeriod.year, this.currentPeriod.month, 10), 'me', this.locale)
273
- if (parseInt(m) < 7 && dst) {
274
- offset += 60
275
- }
276
- return offset * -1
277
- }
269
+ timezoneOffset() {
270
+ return (new Date(this.currentPeriod.year, this.currentPeriod.month, 10)).getTimezoneOffset()
278
271
  },
279
- watch: {
280
- modelValueDate(newVal) {
281
- this.currentPeriod = {
282
- month: newVal.getMonth() + 1,
283
- year: newVal.getFullYear()
284
- }
285
- if (this.rangeLocalDate.start > this.modelValueDate) {
286
- this.incrementMonth(-1)
287
- }
288
- if (this.rangeLocalDate.end < this.modelValueDate) {
289
- this.incrementMonth(1)
290
- }
291
- },
292
- currentPeriod(currentPeriod, oldPeriod) {
293
- const currentDate = new Date(currentPeriod.year, currentPeriod.month).getTime()
294
- const oldDate = new Date(oldPeriod.year, oldPeriod.month).getTime()
295
- this.direction = currentDate !== oldDate
296
- ? (currentDate > oldDate ? 'next' : 'prev')
297
- : undefined
298
- }
272
+ lang_zone_offset() {
273
+ return this.$helper.ifHas(this.$dateTime.langs, 0, this.locale, 'time_zone_offset') * -1
274
+ }
275
+ },
276
+ watch: {
277
+ modelValueDate(newVal) {
278
+ this.currentPeriod = {
279
+ month: newVal.getMonth() + 1,
280
+ year: newVal.getFullYear()
281
+ }
282
+ if (this.rangeLocalDate.start > this.modelValueDate) {
283
+ this.incrementMonth(-1)
284
+ }
285
+ if (this.rangeLocalDate.end < this.modelValueDate) {
286
+ this.incrementMonth(1)
287
+ }
288
+ },
289
+ currentPeriod(currentPeriod, oldPeriod) {
290
+ const currentDate = new Date(currentPeriod.year, currentPeriod.month).getTime()
291
+ const oldDate = new Date(oldPeriod.year, oldPeriod.month).getTime()
292
+ this.direction = currentDate !== oldDate
293
+ ? (currentDate > oldDate ? 'next' : 'prev')
294
+ : undefined
295
+ }
296
+ },
297
+ methods: {
298
+ close() {
299
+ this.show = false
300
+ this.showTime = false
299
301
  },
300
- methods: {
301
- close() {
302
- this.show = false
303
- this.showTime = false
304
- },
305
- createRange(number) {
306
- const res = []
307
- for (let i = 0; i < number; i++) {
308
- res.push(i)
309
- }
310
- return res
311
- },
312
- incrementMonth(increment = 1) {
313
- const incrementDate = new Date(this.currentPeriod.year, this.currentPeriod.month + increment)
314
- this.currentPeriod = {
315
- month: incrementDate.getMonth(),
316
- year: incrementDate.getFullYear()
317
- }
318
- },
319
- incrementYear(increment = 1) {
320
- const incrementDate = new Date(this.currentPeriod.year + increment, this.currentPeriod.month)
321
- this.currentPeriod = {
322
- month: incrementDate.getMonth(),
323
- year: incrementDate.getFullYear()
324
- }
325
- },
326
- setMonth(increment) {
327
- const incrementDate = new Date(this.currentPeriod.year, increment)
328
- this.currentPeriod = {
329
- month: incrementDate.getMonth(),
330
- year: incrementDate.getFullYear()
331
- }
332
- },
333
- setYear(increment) {
334
- const incrementDate = new Date(increment, this.currentPeriod.month)
335
- this.currentPeriod = {
336
- month: incrementDate.getMonth(),
337
- year: incrementDate.getFullYear()
338
- }
339
- },
340
- selectTime() {
341
- const times = (this.time ? this.time : '00:00:00').split(':')
342
- let d = (new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(),
343
- this.date.getHours() + parseInt(times[0]),
344
- this.date.getMinutes() + parseInt(times[1]),
345
- this.date.getSeconds() + parseInt(times[2])))
346
-
347
- this.$emit('update:modelValue', d.toISOString())
348
- this.close()
349
- },
350
- selectDateItem(item) {
351
- if (!item.disabled) {
352
- if (this.withTime) {
353
- this.date = item.date
354
- this.showTime = true
355
- } else {
356
- this.$emit('update:modelValue', item.date.toISOString())
357
- this.close()
358
- }
359
- }
360
- },
361
- areSameDates(date1, date2) {
362
- if (typeof date1.getDate === 'function' && typeof date2.getDate === 'function') {
363
- return (date1.getDate() === date2.getDate()) &&
364
- (date1.getMonth() === date2.getMonth()) &&
365
- (date1.getFullYear() === date2.getFullYear())
366
- }
367
- return false
302
+ createRange(number) {
303
+ const res = []
304
+ for (let i = 0; i < number; i++) {
305
+ res.push(i)
306
+ }
307
+ return res
308
+ },
309
+ incrementMonth(increment = 1) {
310
+ const incrementDate = new Date(this.currentPeriod.year, this.currentPeriod.month + increment)
311
+ this.currentPeriod = {
312
+ month: incrementDate.getMonth(),
313
+ year: incrementDate.getFullYear()
314
+ }
315
+ },
316
+ incrementYear(increment = 1) {
317
+ const incrementDate = new Date(this.currentPeriod.year + increment, this.currentPeriod.month)
318
+ this.currentPeriod = {
319
+ month: incrementDate.getMonth(),
320
+ year: incrementDate.getFullYear()
321
+ }
322
+ },
323
+ setMonth(increment) {
324
+ const incrementDate = new Date(this.currentPeriod.year, increment)
325
+ this.currentPeriod = {
326
+ month: incrementDate.getMonth(),
327
+ year: incrementDate.getFullYear()
328
+ }
329
+ },
330
+ selectTime() {
331
+ const times = (this.time ? this.time : '00:00:00').split(':')
332
+ let d = (new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(),
333
+ this.date.getHours() + parseInt(times[0]),
334
+ this.date.getMinutes() + parseInt(times[1]),
335
+ this.date.getSeconds() + parseInt(times[2])))
336
+
337
+ this.$emit('update:modelValue', d.toISOString())
338
+ this.close()
339
+ },
340
+ selectDateItem(item) {
341
+ if (!item.disabled) {
342
+ if (this.withTime) {
343
+ this.date = item.date
344
+ this.showTime = true
345
+ } else {
346
+ this.$emit('update:modelValue', item.date.toISOString())
347
+ this.close()
368
348
  }
349
+ }
350
+ },
351
+ areSameDates(date1, date2) {
352
+ if (typeof date1.getDate === 'function' && typeof date2.getDate === 'function') {
353
+ return (date1.getDate() === date2.getDate()) &&
354
+ (date1.getMonth() === date2.getMonth()) &&
355
+ (date1.getFullYear() === date2.getFullYear())
356
+ }
357
+ return false
369
358
  }
359
+ }
370
360
  }
371
361
 
372
362
  </script>
@@ -375,102 +365,106 @@ export default {
375
365
  @use "../../../style/variables/base";
376
366
 
377
367
  .#{base.$prefix}date-input {
378
- position: relative;
379
- display: inline-block;
380
- font-size: 10px;
381
- color: var(--color-on-sheet);
382
- background-color: var(--color-sheet-container-high);
383
-
384
- .cell {
385
- &.today {
386
- color: var(--color-one);
387
-
388
- .cellContent {
389
- border: solid 1px var(--color-one);
390
- }
391
- }
392
-
393
- &.selected {
394
- .cellContent {
395
- color: var(--color-on-one);
396
- background: var(--color-one);
368
+ position: relative;
369
+ display: inline-block;
370
+ font-size: 10px;
371
+ color: var(--color-on-sheet);
372
+ background-color: var(--color-sheet-container-high);
373
+
374
+ .date-picker-year {
375
+ max-height: 300px;
376
+ }
377
+
378
+ .cell {
379
+ &.today {
380
+ color: var(--color-one);
381
+
382
+ .cellContent {
383
+ border: solid 1px var(--color-one);
384
+ }
385
+ }
397
386
 
398
- }
399
- }
387
+ &.selected {
388
+ .cellContent {
389
+ color: var(--color-on-one);
390
+ background: var(--color-one);
400
391
 
401
- &.selectable:hover {
402
- .cellContent {
392
+ }
393
+ }
403
394
 
404
- color: var(--color-on-one);
405
- background: var(--color-one);
395
+ &.selectable:hover {
396
+ .cellContent {
406
397
 
407
- }
408
- }
398
+ color: var(--color-on-one);
399
+ background: var(--color-one);
409
400
 
401
+ }
410
402
  }
411
403
 
404
+ }
412
405
 
413
- .table {
414
406
 
415
- width: 100%;
416
- table-layout: fixed;
417
- position: relative;
418
- z-index: 5;
407
+ .table {
419
408
 
420
- }
409
+ width: 100%;
410
+ table-layout: fixed;
411
+ position: relative;
412
+ z-index: 5;
421
413
 
422
- .cell, .headCell {
414
+ }
423
415
 
424
- text-align: center;
425
- box-sizing: border-box;
416
+ .cell, .headCell {
426
417
 
427
- }
418
+ text-align: center;
419
+ box-sizing: border-box;
428
420
 
429
- .cell {
421
+ }
430
422
 
431
- padding: 0.5em 0;
423
+ .cell {
432
424
 
433
- }
425
+ padding: 0.5em 0;
434
426
 
435
- .headCell {
427
+ }
436
428
 
437
- padding: 0.3em 0.5em 1.8em;
429
+ .headCell {
438
430
 
439
- }
431
+ padding: 0.3em 0.5em 1.8em;
440
432
 
441
- .headCellContent {
433
+ }
442
434
 
443
- font-size: 1.3em;
444
- font-weight: normal;
445
- color: var(--color-on-sheet-low);
435
+ .headCellContent {
446
436
 
447
- }
437
+ font-size: 1.3em;
438
+ font-weight: normal;
439
+ color: var(--color-on-sheet-low);
448
440
 
449
- .cellContent {
450
- padding: 5px;
451
- font-size: 1.4em;
452
- margin: 0 auto;
453
- width: 30px;
454
- height: 30px;
455
- text-align: center;
456
- border-radius: 100%;
457
- transition: background 0.1s, color 0.1s;
441
+ }
458
442
 
459
- }
443
+ .cellContent {
444
+ padding: 5px;
445
+ font-size: 1.4em;
446
+ margin: 0 auto;
447
+ width: 30px;
448
+ height: 30px;
449
+ text-align: center;
450
+ border-radius: 100%;
451
+ transition: background 0.1s, color 0.1s;
460
452
 
461
- .cell.outOfRange {
462
- color: var(--color-sheet-low);
463
- }
453
+ }
464
454
 
465
- .cell.selectable {
455
+ .cell.outOfRange {
456
+ color: var(--color-sheet-low);
457
+ }
466
458
 
467
- cursor: pointer;
459
+ .cell.selectable {
468
460
 
469
- }
461
+ cursor: pointer;
470
462
 
471
- .cell.disabled {
472
- opacity: 0.38;
473
- }
463
+ }
464
+
465
+ .cell.disabled {
466
+ opacity: 0.38;
467
+ }
474
468
 
475
469
  }
476
470
  </style>