@94ai/nf-timezone-picker 8.3.0 → 8.3.4

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,316 +1,316 @@
1
- <template>
2
- <div class="el-time-spinner" :class="{ 'has-seconds': showSeconds }">
3
- <template v-if="!arrowControl">
4
- <el-scrollbar
5
- ref="hours"
6
- class="el-time-spinner__wrapper"
7
- wrap-style="max-height: inherit;"
8
- view-class="el-time-spinner__list"
9
- noresize
10
- tag="ul"
11
- @mouseenter.native="emitSelectRange('hours')"
12
- @mousemove.native="adjustCurrentSpinner('hours')"
13
- >
14
- <li
15
- v-for="(disabled, hour) in hoursList"
16
- :key="hour"
17
- class="el-time-spinner__item"
18
- :class="{ 'active': hour === hours, 'disabled': disabled }"
19
- @click="handleClick('hours', { value: hour, disabled: disabled })"
20
- >{{ ('0' + (amPmMode ? (hour % 12 || 12) : hour )).slice(-2) }}{{ amPm(hour) }}</li>
21
- </el-scrollbar>
22
- <el-scrollbar
23
- ref="minutes"
24
- class="el-time-spinner__wrapper"
25
- wrap-style="max-height: inherit;"
26
- view-class="el-time-spinner__list"
27
- noresize
28
- tag="ul"
29
- @mouseenter.native="emitSelectRange('minutes')"
30
- @mousemove.native="adjustCurrentSpinner('minutes')"
31
- >
32
- <li
33
- v-for="(enabled, key) in minutesList"
34
- :key="key"
35
- class="el-time-spinner__item"
36
- :class="{ 'active': key === minutes, disabled: !enabled }"
37
- @click="handleClick('minutes', { value: key, disabled: false })"
38
- >{{ ('0' + key).slice(-2) }}</li>
39
- </el-scrollbar>
40
- <el-scrollbar
41
- v-show="showSeconds"
42
- ref="seconds"
43
- class="el-time-spinner__wrapper"
44
- wrap-style="max-height: inherit;"
45
- view-class="el-time-spinner__list"
46
- noresize
47
- tag="ul"
48
- @mouseenter.native="emitSelectRange('seconds')"
49
- @mousemove.native="adjustCurrentSpinner('seconds')"
50
- >
51
- <li
52
- v-for="(second, key) in 60"
53
- :key="key"
54
- class="el-time-spinner__item"
55
- :class="{ 'active': key === seconds }"
56
- @click="handleClick('seconds', { value: key, disabled: false })"
57
- >{{ ('0' + key).slice(-2) }}</li>
58
- </el-scrollbar>
59
- </template>
60
- <template v-if="arrowControl">
61
- <div
62
- class="el-time-spinner__wrapper is-arrow"
63
- @mouseenter="emitSelectRange('hours')"
64
- >
65
- <i v-repeat-click="decrease" class="el-time-spinner__arrow el-icon-arrow-up" />
66
- <i v-repeat-click="increase" class="el-time-spinner__arrow el-icon-arrow-down" />
67
- <ul ref="hours" class="el-time-spinner__list">
68
- <li
69
- v-for="(hour, key) in arrowHourList"
70
- :key="key"
71
- class="el-time-spinner__item"
72
- :class="{ 'active': hour === hours, 'disabled': hoursList[hour] }"
73
- >{{ hour === undefined ? '' : ('0' + (amPmMode ? (hour % 12 || 12) : hour )).slice(-2) + amPm(hour) }}</li>
74
- </ul>
75
- </div>
76
- <div
77
- class="el-time-spinner__wrapper is-arrow"
78
- @mouseenter="emitSelectRange('minutes')"
79
- >
80
- <i v-repeat-click="decrease" class="el-time-spinner__arrow el-icon-arrow-up" />
81
- <i v-repeat-click="increase" class="el-time-spinner__arrow el-icon-arrow-down" />
82
- <ul ref="minutes" class="el-time-spinner__list">
83
- <li
84
- v-for="(minute, key) in arrowMinuteList"
85
- :key="key"
86
- class="el-time-spinner__item"
87
- :class="{ 'active': minute === minutes }"
88
- >
89
- {{ minute === undefined ? '' : ('0' + minute).slice(-2) }}
90
- </li>
91
- </ul>
92
- </div>
93
- <div
94
- v-if="showSeconds"
95
- class="el-time-spinner__wrapper is-arrow"
96
- @mouseenter="emitSelectRange('seconds')"
97
- >
98
- <i v-repeat-click="decrease" class="el-time-spinner__arrow el-icon-arrow-up" />
99
- <i v-repeat-click="increase" class="el-time-spinner__arrow el-icon-arrow-down" />
100
- <ul ref="seconds" class="el-time-spinner__list">
101
- <li
102
- v-for="(second, key) in arrowSecondList"
103
- :key="key"
104
- class="el-time-spinner__item"
105
- :class="{ 'active': second === seconds }"
106
- >
107
- {{ second === undefined ? '' : ('0' + second).slice(-2) }}
108
- </li>
109
- </ul>
110
- </div>
111
- </template>
112
- </div>
113
- </template>
114
-
115
- <script type="text/babel">
116
- import { getRangeHours, getRangeMinutes, modifyTime } from 'element-ui/src/utils/date-util'
117
- // import ElScrollbar from 'element-ui/packages/scrollbar';
118
- import RepeatClick from 'element-ui/src/directives/repeat-click'
119
-
120
- export default {
121
- components: { },
122
-
123
- directives: {
124
- repeatClick: RepeatClick
125
- },
126
-
127
- props: {
128
- date: {},
129
- defaultValue: {}, // reserved for future use
130
- showSeconds: {
131
- type: Boolean,
132
- default: true
133
- },
134
- arrowControl: Boolean,
135
- amPmMode: {
136
- type: String,
137
- default: '' // 'a': am/pm; 'A': AM/PM
138
- }
139
- },
140
-
141
- data() {
142
- return {
143
- selectableRange: [],
144
- currentScrollbar: null
145
- }
146
- },
147
-
148
- computed: {
149
- hours() {
150
- return this.date.getHours()
151
- },
152
- minutes() {
153
- return this.date.getMinutes()
154
- },
155
- seconds() {
156
- return this.date.getSeconds()
157
- },
158
- hoursList() {
159
- return getRangeHours(this.selectableRange)
160
- },
161
- minutesList() {
162
- return getRangeMinutes(this.selectableRange, this.hours)
163
- },
164
- arrowHourList() {
165
- const hours = this.hours
166
- return [
167
- hours > 0 ? hours - 1 : undefined,
168
- hours,
169
- hours < 23 ? hours + 1 : undefined
170
- ]
171
- },
172
- arrowMinuteList() {
173
- const minutes = this.minutes
174
- return [
175
- minutes > 0 ? minutes - 1 : undefined,
176
- minutes,
177
- minutes < 59 ? minutes + 1 : undefined
178
- ]
179
- },
180
- arrowSecondList() {
181
- const seconds = this.seconds
182
- return [
183
- seconds > 0 ? seconds - 1 : undefined,
184
- seconds,
185
- seconds < 59 ? seconds + 1 : undefined
186
- ]
187
- }
188
- },
189
-
190
- mounted() {
191
- this.$nextTick(() => {
192
- !this.arrowControl && this.bindScrollEvent()
193
- })
194
- },
195
-
196
- methods: {
197
- increase() {
198
- this.scrollDown(1)
199
- },
200
-
201
- decrease() {
202
- this.scrollDown(-1)
203
- },
204
-
205
- modifyDateField(type, value) {
206
- switch (type) {
207
- case 'hours': this.$emit('change', modifyTime(this.date, value, this.minutes, this.seconds)); break
208
- case 'minutes': this.$emit('change', modifyTime(this.date, this.hours, value, this.seconds)); break
209
- case 'seconds': this.$emit('change', modifyTime(this.date, this.hours, this.minutes, value)); break
210
- }
211
- },
212
-
213
- handleClick(type, { value, disabled }) {
214
- if (!disabled) {
215
- this.modifyDateField(type, value)
216
- this.emitSelectRange(type)
217
- this.adjustSpinner(type, value)
218
- }
219
- },
220
-
221
- emitSelectRange(type) {
222
- if (type === 'hours') {
223
- this.$emit('select-range', 0, 2)
224
- } else if (type === 'minutes') {
225
- this.$emit('select-range', 3, 5)
226
- } else if (type === 'seconds') {
227
- this.$emit('select-range', 6, 8)
228
- }
229
- this.currentScrollbar = type
230
- },
231
-
232
- bindScrollEvent() {
233
- const bindFuntion = (type) => {
234
- this.$refs[type].wrap.onscroll = (e) => {
235
- // TODO: scroll is emitted when set scrollTop programatically
236
- // should find better solutions in the future!
237
- this.handleScroll(type, e)
238
- }
239
- }
240
- bindFuntion('hours')
241
- bindFuntion('minutes')
242
- bindFuntion('seconds')
243
- },
244
-
245
- handleScroll(type) {
246
- const value = Math.min(Math.round((this.$refs[type].wrap.scrollTop - (this.scrollBarHeight(type) * 0.5 - 10) / this.typeItemHeight(type) + 3) / this.typeItemHeight(type)), (type === 'hours' ? 23 : 59))
247
- this.modifyDateField(type, value)
248
- },
249
-
250
- // NOTE: used by datetime / date-range panel
251
- // renamed from adjustScrollTop
252
- // should try to refactory it
253
- adjustSpinners() {
254
- this.adjustSpinner('hours', this.hours)
255
- this.adjustSpinner('minutes', this.minutes)
256
- this.adjustSpinner('seconds', this.seconds)
257
- },
258
-
259
- adjustCurrentSpinner(type) {
260
- this.adjustSpinner(type, this[type])
261
- },
262
-
263
- adjustSpinner(type, value) {
264
- if (this.arrowControl) return
265
- const el = this.$refs[type].wrap
266
- if (el) {
267
- el.scrollTop = Math.max(0, value * this.typeItemHeight(type))
268
- }
269
- },
270
-
271
- scrollDown(step) {
272
- if (!this.currentScrollbar) {
273
- this.emitSelectRange('hours')
274
- }
275
-
276
- const label = this.currentScrollbar
277
- const hoursList = this.hoursList
278
- let now = this[label]
279
-
280
- if (this.currentScrollbar === 'hours') {
281
- let total = Math.abs(step)
282
- step = step > 0 ? 1 : -1
283
- let length = hoursList.length
284
- while (length-- && total) {
285
- now = (now + step + hoursList.length) % hoursList.length
286
- if (hoursList[now]) {
287
- continue
288
- }
289
- total--
290
- }
291
- if (hoursList[now]) return
292
- } else {
293
- now = (now + step + 60) % 60
294
- }
295
-
296
- this.modifyDateField(label, now)
297
- this.adjustSpinner(label, now)
298
- this.$nextTick(() => this.emitSelectRange(this.currentScrollbar))
299
- },
300
- amPm(hour) {
301
- const shouldShowAmPm = this.amPmMode.toLowerCase() === 'a'
302
- if (!shouldShowAmPm) return ''
303
- const isCapital = this.amPmMode === 'A'
304
- let content = (hour < 12) ? ' am' : ' pm'
305
- if (isCapital) content = content.toUpperCase()
306
- return content
307
- },
308
- typeItemHeight(type) {
309
- return this.$refs[type].$el.querySelector('li').offsetHeight
310
- },
311
- scrollBarHeight(type) {
312
- return this.$refs[type].$el.offsetHeight
313
- }
314
- }
315
- }
316
- </script>
1
+ <template>
2
+ <div class="el-time-spinner" :class="{ 'has-seconds': showSeconds }">
3
+ <template v-if="!arrowControl">
4
+ <el-scrollbar
5
+ ref="hours"
6
+ class="el-time-spinner__wrapper"
7
+ wrap-style="max-height: inherit;"
8
+ view-class="el-time-spinner__list"
9
+ noresize
10
+ tag="ul"
11
+ @mouseenter.native="emitSelectRange('hours')"
12
+ @mousemove.native="adjustCurrentSpinner('hours')"
13
+ >
14
+ <li
15
+ v-for="(disabled, hour) in hoursList"
16
+ :key="hour"
17
+ class="el-time-spinner__item"
18
+ :class="{ 'active': hour === hours, 'disabled': disabled }"
19
+ @click="handleClick('hours', { value: hour, disabled: disabled })"
20
+ >{{ ('0' + (amPmMode ? (hour % 12 || 12) : hour )).slice(-2) }}{{ amPm(hour) }}</li>
21
+ </el-scrollbar>
22
+ <el-scrollbar
23
+ ref="minutes"
24
+ class="el-time-spinner__wrapper"
25
+ wrap-style="max-height: inherit;"
26
+ view-class="el-time-spinner__list"
27
+ noresize
28
+ tag="ul"
29
+ @mouseenter.native="emitSelectRange('minutes')"
30
+ @mousemove.native="adjustCurrentSpinner('minutes')"
31
+ >
32
+ <li
33
+ v-for="(enabled, key) in minutesList"
34
+ :key="key"
35
+ class="el-time-spinner__item"
36
+ :class="{ 'active': key === minutes, disabled: !enabled }"
37
+ @click="handleClick('minutes', { value: key, disabled: false })"
38
+ >{{ ('0' + key).slice(-2) }}</li>
39
+ </el-scrollbar>
40
+ <el-scrollbar
41
+ v-show="showSeconds"
42
+ ref="seconds"
43
+ class="el-time-spinner__wrapper"
44
+ wrap-style="max-height: inherit;"
45
+ view-class="el-time-spinner__list"
46
+ noresize
47
+ tag="ul"
48
+ @mouseenter.native="emitSelectRange('seconds')"
49
+ @mousemove.native="adjustCurrentSpinner('seconds')"
50
+ >
51
+ <li
52
+ v-for="(second, key) in 60"
53
+ :key="key"
54
+ class="el-time-spinner__item"
55
+ :class="{ 'active': key === seconds }"
56
+ @click="handleClick('seconds', { value: key, disabled: false })"
57
+ >{{ ('0' + key).slice(-2) }}</li>
58
+ </el-scrollbar>
59
+ </template>
60
+ <template v-if="arrowControl">
61
+ <div
62
+ class="el-time-spinner__wrapper is-arrow"
63
+ @mouseenter="emitSelectRange('hours')"
64
+ >
65
+ <i v-repeat-click="decrease" class="el-time-spinner__arrow el-icon-arrow-up" />
66
+ <i v-repeat-click="increase" class="el-time-spinner__arrow el-icon-arrow-down" />
67
+ <ul ref="hours" class="el-time-spinner__list">
68
+ <li
69
+ v-for="(hour, key) in arrowHourList"
70
+ :key="key"
71
+ class="el-time-spinner__item"
72
+ :class="{ 'active': hour === hours, 'disabled': hoursList[hour] }"
73
+ >{{ hour === undefined ? '' : ('0' + (amPmMode ? (hour % 12 || 12) : hour )).slice(-2) + amPm(hour) }}</li>
74
+ </ul>
75
+ </div>
76
+ <div
77
+ class="el-time-spinner__wrapper is-arrow"
78
+ @mouseenter="emitSelectRange('minutes')"
79
+ >
80
+ <i v-repeat-click="decrease" class="el-time-spinner__arrow el-icon-arrow-up" />
81
+ <i v-repeat-click="increase" class="el-time-spinner__arrow el-icon-arrow-down" />
82
+ <ul ref="minutes" class="el-time-spinner__list">
83
+ <li
84
+ v-for="(minute, key) in arrowMinuteList"
85
+ :key="key"
86
+ class="el-time-spinner__item"
87
+ :class="{ 'active': minute === minutes }"
88
+ >
89
+ {{ minute === undefined ? '' : ('0' + minute).slice(-2) }}
90
+ </li>
91
+ </ul>
92
+ </div>
93
+ <div
94
+ v-if="showSeconds"
95
+ class="el-time-spinner__wrapper is-arrow"
96
+ @mouseenter="emitSelectRange('seconds')"
97
+ >
98
+ <i v-repeat-click="decrease" class="el-time-spinner__arrow el-icon-arrow-up" />
99
+ <i v-repeat-click="increase" class="el-time-spinner__arrow el-icon-arrow-down" />
100
+ <ul ref="seconds" class="el-time-spinner__list">
101
+ <li
102
+ v-for="(second, key) in arrowSecondList"
103
+ :key="key"
104
+ class="el-time-spinner__item"
105
+ :class="{ 'active': second === seconds }"
106
+ >
107
+ {{ second === undefined ? '' : ('0' + second).slice(-2) }}
108
+ </li>
109
+ </ul>
110
+ </div>
111
+ </template>
112
+ </div>
113
+ </template>
114
+
115
+ <script type="text/babel">
116
+ import { getRangeHours, getRangeMinutes, modifyTime } from 'element-ui/src/utils/date-util'
117
+ // import ElScrollbar from 'element-ui/packages/scrollbar';
118
+ import RepeatClick from 'element-ui/src/directives/repeat-click'
119
+
120
+ export default {
121
+ components: { },
122
+
123
+ directives: {
124
+ repeatClick: RepeatClick
125
+ },
126
+
127
+ props: {
128
+ date: {},
129
+ defaultValue: {}, // reserved for future use
130
+ showSeconds: {
131
+ type: Boolean,
132
+ default: true
133
+ },
134
+ arrowControl: Boolean,
135
+ amPmMode: {
136
+ type: String,
137
+ default: '' // 'a': am/pm; 'A': AM/PM
138
+ }
139
+ },
140
+
141
+ data() {
142
+ return {
143
+ selectableRange: [],
144
+ currentScrollbar: null
145
+ }
146
+ },
147
+
148
+ computed: {
149
+ hours() {
150
+ return this.date.getHours()
151
+ },
152
+ minutes() {
153
+ return this.date.getMinutes()
154
+ },
155
+ seconds() {
156
+ return this.date.getSeconds()
157
+ },
158
+ hoursList() {
159
+ return getRangeHours(this.selectableRange)
160
+ },
161
+ minutesList() {
162
+ return getRangeMinutes(this.selectableRange, this.hours)
163
+ },
164
+ arrowHourList() {
165
+ const hours = this.hours
166
+ return [
167
+ hours > 0 ? hours - 1 : undefined,
168
+ hours,
169
+ hours < 23 ? hours + 1 : undefined
170
+ ]
171
+ },
172
+ arrowMinuteList() {
173
+ const minutes = this.minutes
174
+ return [
175
+ minutes > 0 ? minutes - 1 : undefined,
176
+ minutes,
177
+ minutes < 59 ? minutes + 1 : undefined
178
+ ]
179
+ },
180
+ arrowSecondList() {
181
+ const seconds = this.seconds
182
+ return [
183
+ seconds > 0 ? seconds - 1 : undefined,
184
+ seconds,
185
+ seconds < 59 ? seconds + 1 : undefined
186
+ ]
187
+ }
188
+ },
189
+
190
+ mounted() {
191
+ this.$nextTick(() => {
192
+ !this.arrowControl && this.bindScrollEvent()
193
+ })
194
+ },
195
+
196
+ methods: {
197
+ increase() {
198
+ this.scrollDown(1)
199
+ },
200
+
201
+ decrease() {
202
+ this.scrollDown(-1)
203
+ },
204
+
205
+ modifyDateField(type, value) {
206
+ switch (type) {
207
+ case 'hours': this.$emit('change', modifyTime(this.date, value, this.minutes, this.seconds)); break
208
+ case 'minutes': this.$emit('change', modifyTime(this.date, this.hours, value, this.seconds)); break
209
+ case 'seconds': this.$emit('change', modifyTime(this.date, this.hours, this.minutes, value)); break
210
+ }
211
+ },
212
+
213
+ handleClick(type, { value, disabled }) {
214
+ if (!disabled) {
215
+ this.modifyDateField(type, value)
216
+ this.emitSelectRange(type)
217
+ this.adjustSpinner(type, value)
218
+ }
219
+ },
220
+
221
+ emitSelectRange(type) {
222
+ if (type === 'hours') {
223
+ this.$emit('select-range', 0, 2)
224
+ } else if (type === 'minutes') {
225
+ this.$emit('select-range', 3, 5)
226
+ } else if (type === 'seconds') {
227
+ this.$emit('select-range', 6, 8)
228
+ }
229
+ this.currentScrollbar = type
230
+ },
231
+
232
+ bindScrollEvent() {
233
+ const bindFuntion = (type) => {
234
+ this.$refs[type].wrap.onscroll = (e) => {
235
+ // TODO: scroll is emitted when set scrollTop programatically
236
+ // should find better solutions in the future!
237
+ this.handleScroll(type, e)
238
+ }
239
+ }
240
+ bindFuntion('hours')
241
+ bindFuntion('minutes')
242
+ bindFuntion('seconds')
243
+ },
244
+
245
+ handleScroll(type) {
246
+ const value = Math.min(Math.round((this.$refs[type].wrap.scrollTop - (this.scrollBarHeight(type) * 0.5 - 10) / this.typeItemHeight(type) + 3) / this.typeItemHeight(type)), (type === 'hours' ? 23 : 59))
247
+ this.modifyDateField(type, value)
248
+ },
249
+
250
+ // NOTE: used by datetime / date-range panel
251
+ // renamed from adjustScrollTop
252
+ // should try to refactory it
253
+ adjustSpinners() {
254
+ this.adjustSpinner('hours', this.hours)
255
+ this.adjustSpinner('minutes', this.minutes)
256
+ this.adjustSpinner('seconds', this.seconds)
257
+ },
258
+
259
+ adjustCurrentSpinner(type) {
260
+ this.adjustSpinner(type, this[type])
261
+ },
262
+
263
+ adjustSpinner(type, value) {
264
+ if (this.arrowControl) return
265
+ const el = this.$refs[type].wrap
266
+ if (el) {
267
+ el.scrollTop = Math.max(0, value * this.typeItemHeight(type))
268
+ }
269
+ },
270
+
271
+ scrollDown(step) {
272
+ if (!this.currentScrollbar) {
273
+ this.emitSelectRange('hours')
274
+ }
275
+
276
+ const label = this.currentScrollbar
277
+ const hoursList = this.hoursList
278
+ let now = this[label]
279
+
280
+ if (this.currentScrollbar === 'hours') {
281
+ let total = Math.abs(step)
282
+ step = step > 0 ? 1 : -1
283
+ let length = hoursList.length
284
+ while (length-- && total) {
285
+ now = (now + step + hoursList.length) % hoursList.length
286
+ if (hoursList[now]) {
287
+ continue
288
+ }
289
+ total--
290
+ }
291
+ if (hoursList[now]) return
292
+ } else {
293
+ now = (now + step + 60) % 60
294
+ }
295
+
296
+ this.modifyDateField(label, now)
297
+ this.adjustSpinner(label, now)
298
+ this.$nextTick(() => this.emitSelectRange(this.currentScrollbar))
299
+ },
300
+ amPm(hour) {
301
+ const shouldShowAmPm = this.amPmMode.toLowerCase() === 'a'
302
+ if (!shouldShowAmPm) return ''
303
+ const isCapital = this.amPmMode === 'A'
304
+ let content = (hour < 12) ? ' am' : ' pm'
305
+ if (isCapital) content = content.toUpperCase()
306
+ return content
307
+ },
308
+ typeItemHeight(type) {
309
+ return this.$refs[type].$el.querySelector('li').offsetHeight
310
+ },
311
+ scrollBarHeight(type) {
312
+ return this.$refs[type].$el.offsetHeight
313
+ }
314
+ }
315
+ }
316
+ </script>
@@ -1,101 +1,101 @@
1
- <template>
2
- <table class="el-year-table" @click="handleYearTableClick">
3
- <tbody>
4
- <tr>
5
- <td class="available" :class="getCellStyle(startYear + 0)">
6
- <a class="cell">{{ startYear }}</a>
7
- </td>
8
- <td class="available" :class="getCellStyle(startYear + 1)">
9
- <a class="cell">{{ startYear + 1 }}</a>
10
- </td>
11
- <td class="available" :class="getCellStyle(startYear + 2)">
12
- <a class="cell">{{ startYear + 2 }}</a>
13
- </td>
14
- <td class="available" :class="getCellStyle(startYear + 3)">
15
- <a class="cell">{{ startYear + 3 }}</a>
16
- </td>
17
- </tr>
18
- <tr>
19
- <td class="available" :class="getCellStyle(startYear + 4)">
20
- <a class="cell">{{ startYear + 4 }}</a>
21
- </td>
22
- <td class="available" :class="getCellStyle(startYear + 5)">
23
- <a class="cell">{{ startYear + 5 }}</a>
24
- </td>
25
- <td class="available" :class="getCellStyle(startYear + 6)">
26
- <a class="cell">{{ startYear + 6 }}</a>
27
- </td>
28
- <td class="available" :class="getCellStyle(startYear + 7)">
29
- <a class="cell">{{ startYear + 7 }}</a>
30
- </td>
31
- </tr>
32
- <tr>
33
- <td class="available" :class="getCellStyle(startYear + 8)">
34
- <a class="cell">{{ startYear + 8 }}</a>
35
- </td>
36
- <td class="available" :class="getCellStyle(startYear + 9)">
37
- <a class="cell">{{ startYear + 9 }}</a>
38
- </td>
39
- <td />
40
- <td />
41
- </tr>
42
- </tbody>
43
- </table>
44
- </template>
45
-
46
- <script type="text/babel">
47
- import { hasClass } from 'element-ui/src/utils/dom'
48
- import { isDate, range, nextDate, getDayCountOfYear } from 'element-ui/src/utils/date-util'
49
- import { arrayFindIndex, coerceTruthyValueToArray } from 'element-ui/src/utils/util'
50
-
51
- const datesInYear = year => {
52
- const numOfDays = getDayCountOfYear(year)
53
- const firstDay = new Date(year, 0, 1)
54
- return range(numOfDays).map(n => nextDate(firstDay, n))
55
- }
56
-
57
- export default {
58
- props: {
59
- disabledDate: {},
60
- value: {},
61
- defaultValue: {
62
- validator(val) {
63
- // null or valid Date Object
64
- return val === null || (val instanceof Date && isDate(val))
65
- }
66
- },
67
- date: {}
68
- },
69
-
70
- computed: {
71
- startYear() {
72
- return Math.floor(this.date.getFullYear() / 10) * 10
73
- }
74
- },
75
-
76
- methods: {
77
- getCellStyle(year) {
78
- const style = {}
79
- const today = new Date()
80
-
81
- style.disabled = typeof this.disabledDate === 'function'
82
- ? datesInYear(year).every(this.disabledDate)
83
- : false
84
- style.current = arrayFindIndex(coerceTruthyValueToArray(this.value), date => date.getFullYear() === year) >= 0
85
- style.today = today.getFullYear() === year
86
- style.default = this.defaultValue && this.defaultValue.getFullYear() === year
87
-
88
- return style
89
- },
90
-
91
- handleYearTableClick(event) {
92
- const target = event.target
93
- if (target.tagName === 'A') {
94
- if (hasClass(target.parentNode, 'disabled')) return
95
- const year = target.textContent || target.innerText
96
- this.$emit('pick', Number(year))
97
- }
98
- }
99
- }
100
- }
101
- </script>
1
+ <template>
2
+ <table class="el-year-table" @click="handleYearTableClick">
3
+ <tbody>
4
+ <tr>
5
+ <td class="available" :class="getCellStyle(startYear + 0)">
6
+ <a class="cell">{{ startYear }}</a>
7
+ </td>
8
+ <td class="available" :class="getCellStyle(startYear + 1)">
9
+ <a class="cell">{{ startYear + 1 }}</a>
10
+ </td>
11
+ <td class="available" :class="getCellStyle(startYear + 2)">
12
+ <a class="cell">{{ startYear + 2 }}</a>
13
+ </td>
14
+ <td class="available" :class="getCellStyle(startYear + 3)">
15
+ <a class="cell">{{ startYear + 3 }}</a>
16
+ </td>
17
+ </tr>
18
+ <tr>
19
+ <td class="available" :class="getCellStyle(startYear + 4)">
20
+ <a class="cell">{{ startYear + 4 }}</a>
21
+ </td>
22
+ <td class="available" :class="getCellStyle(startYear + 5)">
23
+ <a class="cell">{{ startYear + 5 }}</a>
24
+ </td>
25
+ <td class="available" :class="getCellStyle(startYear + 6)">
26
+ <a class="cell">{{ startYear + 6 }}</a>
27
+ </td>
28
+ <td class="available" :class="getCellStyle(startYear + 7)">
29
+ <a class="cell">{{ startYear + 7 }}</a>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td class="available" :class="getCellStyle(startYear + 8)">
34
+ <a class="cell">{{ startYear + 8 }}</a>
35
+ </td>
36
+ <td class="available" :class="getCellStyle(startYear + 9)">
37
+ <a class="cell">{{ startYear + 9 }}</a>
38
+ </td>
39
+ <td />
40
+ <td />
41
+ </tr>
42
+ </tbody>
43
+ </table>
44
+ </template>
45
+
46
+ <script type="text/babel">
47
+ import { hasClass } from 'element-ui/src/utils/dom'
48
+ import { isDate, range, nextDate, getDayCountOfYear } from 'element-ui/src/utils/date-util'
49
+ import { arrayFindIndex, coerceTruthyValueToArray } from 'element-ui/src/utils/util'
50
+
51
+ const datesInYear = year => {
52
+ const numOfDays = getDayCountOfYear(year)
53
+ const firstDay = new Date(year, 0, 1)
54
+ return range(numOfDays).map(n => nextDate(firstDay, n))
55
+ }
56
+
57
+ export default {
58
+ props: {
59
+ disabledDate: {},
60
+ value: {},
61
+ defaultValue: {
62
+ validator(val) {
63
+ // null or valid Date Object
64
+ return val === null || (val instanceof Date && isDate(val))
65
+ }
66
+ },
67
+ date: {}
68
+ },
69
+
70
+ computed: {
71
+ startYear() {
72
+ return Math.floor(this.date.getFullYear() / 10) * 10
73
+ }
74
+ },
75
+
76
+ methods: {
77
+ getCellStyle(year) {
78
+ const style = {}
79
+ const today = new Date()
80
+
81
+ style.disabled = typeof this.disabledDate === 'function'
82
+ ? datesInYear(year).every(this.disabledDate)
83
+ : false
84
+ style.current = arrayFindIndex(coerceTruthyValueToArray(this.value), date => date.getFullYear() === year) >= 0
85
+ style.today = today.getFullYear() === year
86
+ style.default = this.defaultValue && this.defaultValue.getFullYear() === year
87
+
88
+ return style
89
+ },
90
+
91
+ handleYearTableClick(event) {
92
+ const target = event.target
93
+ if (target.tagName === 'A') {
94
+ if (hasClass(target.parentNode, 'disabled')) return
95
+ const year = target.textContent || target.innerText
96
+ this.$emit('pick', Number(year))
97
+ }
98
+ }
99
+ }
100
+ }
101
+ </script>
@@ -1,39 +1,39 @@
1
- import Picker from '../picker'
2
- import TimePanel from '../panel/time'
3
- import TimeRangePanel from '../panel/time-range'
4
-
5
- export default {
6
- mixins: [Picker],
7
-
8
- name: 'ElTimePicker',
9
-
10
- props: {
11
- isRange: Boolean,
12
- arrowControl: Boolean
13
- },
14
-
15
- data() {
16
- return {
17
- type: ''
18
- }
19
- },
20
-
21
- watch: {
22
- isRange(isRange) {
23
- if (this.picker) {
24
- this.unmountPicker()
25
- this.type = isRange ? 'timerange' : 'time'
26
- this.panel = isRange ? TimeRangePanel : TimePanel
27
- this.mountPicker()
28
- } else {
29
- this.type = isRange ? 'timerange' : 'time'
30
- this.panel = isRange ? TimeRangePanel : TimePanel
31
- }
32
- }
33
- },
34
-
35
- created() {
36
- this.type = this.isRange ? 'timerange' : 'time'
37
- this.panel = this.isRange ? TimeRangePanel : TimePanel
38
- }
39
- }
1
+ import Picker from '../picker'
2
+ import TimePanel from '../panel/time'
3
+ import TimeRangePanel from '../panel/time-range'
4
+
5
+ export default {
6
+ mixins: [Picker],
7
+
8
+ name: 'ElTimePicker',
9
+
10
+ props: {
11
+ isRange: Boolean,
12
+ arrowControl: Boolean
13
+ },
14
+
15
+ data() {
16
+ return {
17
+ type: ''
18
+ }
19
+ },
20
+
21
+ watch: {
22
+ isRange(isRange) {
23
+ if (this.picker) {
24
+ this.unmountPicker()
25
+ this.type = isRange ? 'timerange' : 'time'
26
+ this.panel = isRange ? TimeRangePanel : TimePanel
27
+ this.mountPicker()
28
+ } else {
29
+ this.type = isRange ? 'timerange' : 'time'
30
+ this.panel = isRange ? TimeRangePanel : TimePanel
31
+ }
32
+ }
33
+ },
34
+
35
+ created() {
36
+ this.type = this.isRange ? 'timerange' : 'time'
37
+ this.panel = this.isRange ? TimeRangePanel : TimePanel
38
+ }
39
+ }
@@ -1,21 +1,21 @@
1
- import Picker from '../picker'
2
- import Panel from '../panel/time-select'
3
-
4
- export default {
5
- mixins: [Picker],
6
-
7
- name: 'ElTimeSelect',
8
-
9
- componentName: 'ElTimeSelect',
10
-
11
- props: {
12
- type: {
13
- type: String,
14
- default: 'time-select'
15
- }
16
- },
17
-
18
- beforeCreate() {
19
- this.panel = Panel
20
- }
21
- }
1
+ import Picker from '../picker'
2
+ import Panel from '../panel/time-select'
3
+
4
+ export default {
5
+ mixins: [Picker],
6
+
7
+ name: 'ElTimeSelect',
8
+
9
+ componentName: 'ElTimeSelect',
10
+
11
+ props: {
12
+ type: {
13
+ type: String,
14
+ default: 'time-select'
15
+ }
16
+ },
17
+
18
+ beforeCreate() {
19
+ this.panel = Panel
20
+ }
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-timezone-picker",
3
- "version": "8.3.0",
3
+ "version": "8.3.4",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,7 +14,7 @@
14
14
  "url": "http://94ai.gitlab.com/ui/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^8.3.0",
17
+ "@94ai/nf-theme-chalk": "^8.3.4",
18
18
  "vue-demi": "^0.14.5"
19
19
  },
20
20
  "peerDependenciesMeta": {
@@ -30,5 +30,5 @@
30
30
  "types": "lib/index.d.ts",
31
31
  "main": "lib/nf-timezone-picker.cjs.js",
32
32
  "module": "lib/nf-timezone-picker.esm-bundler.js",
33
- "gitHead": "d5b29fecd87582ed9747c58e279d4490294c5891"
33
+ "gitHead": "d79d17da5054791bd9aac0240fd5ef916e2b0ab3"
34
34
  }