meixioacomponent 1.1.49 → 1.1.51

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.
Files changed (25) hide show
  1. package/lib/meixioacomponent.common.js +337 -52
  2. package/lib/meixioacomponent.umd.js +337 -52
  3. package/lib/meixioacomponent.umd.min.js +7 -7
  4. package/package.json +1 -1
  5. package/packages/components/base/baseArea/api.js +7 -0
  6. package/packages/components/base/baseArea/areaConfig.js +4 -3
  7. package/packages/components/base/baseArea/baseAreaV2.vue +157 -0
  8. package/packages/components/base/baseArea/index.js +2 -1
  9. package/packages/components/base/elDatePicker/basic/date-table.vue +441 -441
  10. package/packages/components/base/elDatePicker/basic/month-table.vue +269 -269
  11. package/packages/components/base/elDatePicker/basic/time-spinner.vue +304 -304
  12. package/packages/components/base/elDatePicker/basic/year-table.vue +111 -111
  13. package/packages/components/base/elDatePicker/index.js +6 -6
  14. package/packages/components/base/elDatePicker/index.vue +27 -27
  15. package/packages/components/base/elDatePicker/panel/date-range.vue +680 -680
  16. package/packages/components/base/elDatePicker/panel/date.vue +609 -609
  17. package/packages/components/base/elDatePicker/panel/month-range.vue +289 -289
  18. package/packages/components/base/elDatePicker/panel/time-range.vue +248 -248
  19. package/packages/components/base/elDatePicker/panel/time-select.vue +178 -178
  20. package/packages/components/base/elDatePicker/panel/time.vue +186 -186
  21. package/packages/components/base/elDatePicker/picker/date-picker.js +55 -55
  22. package/packages/components/base/elDatePicker/picker/time-picker.js +39 -39
  23. package/packages/components/base/elDatePicker/picker/time-select.js +21 -21
  24. package/packages/components/base/elDatePicker/picker.vue +956 -956
  25. package/packages/components/proForm/proForm/pro_form.vue +6 -4
@@ -1,269 +1,269 @@
1
- <template>
2
- <table @click="handleMonthTableClick" @mousemove="handleMouseMove" class="el-month-table">
3
- <tbody>
4
- <tr v-for="(row, key) in rows" :key="key">
5
- <td :class="getCellStyle(cell)" v-for="(cell, key) in row" :key="key">
6
- <div>
7
- <a class="cell">{{ t('el.datepicker.months.' + months[cell.text]) }}</a>
8
- </div>
9
- </td>
10
- </tr>
11
- </tbody>
12
- </table>
13
- </template>
14
-
15
- <script type="text/babel">
16
- import Locale from 'element-ui/src/mixins/locale';
17
- import { isDate, range, getDayCountOfMonth, nextDate } from 'element-ui/src/utils/date-util';
18
- import { hasClass } from 'element-ui/src/utils/dom';
19
- import { arrayFindIndex, coerceTruthyValueToArray, arrayFind } from 'element-ui/src/utils/util';
20
-
21
- const datesInMonth = (year, month) => {
22
- const numOfDays = getDayCountOfMonth(year, month);
23
- const firstDay = new Date(year, month, 1);
24
- return range(numOfDays).map(n => nextDate(firstDay, n));
25
- };
26
-
27
- const clearDate = (date) => {
28
- return new Date(date.getFullYear(), date.getMonth());
29
- };
30
-
31
- const getMonthTimestamp = function(time) {
32
- if (typeof time === 'number' || typeof time === 'string') {
33
- return clearDate(new Date(time)).getTime();
34
- } else if (time instanceof Date) {
35
- return clearDate(time).getTime();
36
- } else {
37
- return NaN;
38
- }
39
- };
40
-
41
- // remove the first element that satisfies `pred` from arr
42
- // return a new array if modification occurs
43
- // return the original array otherwise
44
- const removeFromArray = function(arr, pred) {
45
- const idx = typeof pred === 'function' ? arrayFindIndex(arr, pred) : arr.indexOf(pred);
46
- return idx >= 0 ? [...arr.slice(0, idx), ...arr.slice(idx + 1)] : arr;
47
- };
48
- export default {
49
- props: {
50
- disabledDate: {},
51
- value: {},
52
- selectionMode: {
53
- default: 'month'
54
- },
55
- minDate: {},
56
-
57
- maxDate: {},
58
- defaultValue: {
59
- validator(val) {
60
- // null or valid Date Object
61
- return val === null || isDate(val) || (Array.isArray(val) && val.every(isDate));
62
- }
63
- },
64
- date: {},
65
- rangeState: {
66
- default() {
67
- return {
68
- endDate: null,
69
- selecting: false
70
- };
71
- }
72
- }
73
- },
74
-
75
- mixins: [Locale],
76
-
77
- watch: {
78
- 'rangeState.endDate'(newVal) {
79
- this.markRange(this.minDate, newVal);
80
- },
81
-
82
- minDate(newVal, oldVal) {
83
- if (getMonthTimestamp(newVal) !== getMonthTimestamp(oldVal)) {
84
- this.markRange(this.minDate, this.maxDate);
85
- }
86
- },
87
-
88
- maxDate(newVal, oldVal) {
89
- if (getMonthTimestamp(newVal) !== getMonthTimestamp(oldVal)) {
90
- this.markRange(this.minDate, this.maxDate);
91
- }
92
- }
93
- },
94
-
95
- data() {
96
- return {
97
- months: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'],
98
- tableRows: [ [], [], [] ],
99
- lastRow: null,
100
- lastColumn: null
101
- };
102
- },
103
-
104
- methods: {
105
- cellMatchesDate(cell, date) {
106
- const value = new Date(date);
107
- return this.date.getFullYear() === value.getFullYear() && Number(cell.text) === value.getMonth();
108
- },
109
- getCellStyle(cell) {
110
- const style = {};
111
- const year = this.date.getFullYear();
112
- const today = new Date();
113
- const month = cell.text;
114
- const defaultValue = this.defaultValue ? Array.isArray(this.defaultValue) ? this.defaultValue : [this.defaultValue] : [];
115
- style.disabled = typeof this.disabledDate === 'function'
116
- ? datesInMonth(year, month).every(this.disabledDate)
117
- : false;
118
- style.current = arrayFindIndex(coerceTruthyValueToArray(this.value), date => date.getFullYear() === year && date.getMonth() === month) >= 0;
119
- style.today = today.getFullYear() === year && today.getMonth() === month;
120
- style.default = defaultValue.some(date => this.cellMatchesDate(cell, date));
121
-
122
- if (cell.inRange) {
123
- style['in-range'] = true;
124
-
125
- if (cell.start) {
126
- style['start-date'] = true;
127
- }
128
-
129
- if (cell.end) {
130
- style['end-date'] = true;
131
- }
132
- }
133
- return style;
134
- },
135
- getMonthOfCell(month) {
136
- const year = this.date.getFullYear();
137
- return new Date(year, month, 1);
138
- },
139
- markRange(minDate, maxDate) {
140
- minDate = getMonthTimestamp(minDate);
141
- maxDate = getMonthTimestamp(maxDate) || minDate;
142
- [minDate, maxDate] = [Math.min(minDate, maxDate), Math.max(minDate, maxDate)];
143
- const rows = this.rows;
144
- for (let i = 0, k = rows.length; i < k; i++) {
145
- const row = rows[i];
146
- for (let j = 0, l = row.length; j < l; j++) {
147
-
148
- const cell = row[j];
149
- const index = i * 4 + j;
150
- const time = new Date(this.date.getFullYear(), index).getTime();
151
-
152
- cell.inRange = minDate && time >= minDate && time <= maxDate;
153
- cell.start = minDate && time === minDate;
154
- cell.end = maxDate && time === maxDate;
155
- }
156
- }
157
- },
158
- handleMouseMove(event) {
159
- if (!this.rangeState.selecting) return;
160
-
161
- let target = event.target;
162
- if (target.tagName === 'A') {
163
- target = target.parentNode.parentNode;
164
- }
165
- if (target.tagName === 'DIV') {
166
- target = target.parentNode;
167
- }
168
- if (target.tagName !== 'TD') return;
169
-
170
- const row = target.parentNode.rowIndex;
171
- const column = target.cellIndex;
172
- // can not select disabled date
173
- if (this.rows[row][column].disabled) return;
174
-
175
- // only update rangeState when mouse moves to a new cell
176
- // this avoids frequent Date object creation and improves performance
177
- if (row !== this.lastRow || column !== this.lastColumn) {
178
- this.lastRow = row;
179
- this.lastColumn = column;
180
- this.$emit('changerange', {
181
- minDate: this.minDate,
182
- maxDate: this.maxDate,
183
- rangeState: {
184
- selecting: true,
185
- endDate: this.getMonthOfCell(row * 4 + column)
186
- }
187
- });
188
- }
189
- },
190
- handleMonthTableClick(event) {
191
- let target = event.target;
192
- if (target.tagName === 'A') {
193
- target = target.parentNode.parentNode;
194
- }
195
- if (target.tagName === 'DIV') {
196
- target = target.parentNode;
197
- }
198
- if (target.tagName !== 'TD') return;
199
- if (hasClass(target, 'disabled')) return;
200
- const column = target.cellIndex;
201
- const row = target.parentNode.rowIndex;
202
- const month = row * 4 + column;
203
- const newDate = this.getMonthOfCell(month);
204
- if (this.selectionMode === 'range') {
205
- if (!this.rangeState.selecting) {
206
- this.$emit('pick', {minDate: newDate, maxDate: null});
207
- this.rangeState.selecting = true;
208
- } else {
209
- if (newDate >= this.minDate) {
210
- this.$emit('pick', {minDate: this.minDate, maxDate: newDate});
211
- } else {
212
- this.$emit('pick', {minDate: newDate, maxDate: this.minDate});
213
- }
214
- this.rangeState.selecting = false;
215
- }
216
- } else if (this.selectionMode === 'months') {
217
- const value = this.value || [];
218
- const year = this.date.getFullYear();
219
- const newValue = arrayFindIndex(value, date => date.getFullYear() === year && date.getMonth() === month) >= 0
220
- ? removeFromArray(value, date => date.getTime() === newDate.getTime())
221
- : [...value, newDate];
222
- this.$emit('pick', newValue);
223
- } else {
224
- this.$emit('pick', month);
225
- }
226
- }
227
- },
228
-
229
- computed: {
230
- rows() {
231
- // TODO: refactory rows / getCellClasses
232
- const rows = this.tableRows;
233
- const disabledDate = this.disabledDate;
234
- const selectedDate = [];
235
- const now = getMonthTimestamp(new Date());
236
-
237
- for (let i = 0; i < 3; i++) {
238
- const row = rows[i];
239
- for (let j = 0; j < 4; j++) {
240
- let cell = row[j];
241
- if (!cell) {
242
- cell = { row: i, column: j, type: 'normal', inRange: false, start: false, end: false };
243
- }
244
-
245
- cell.type = 'normal';
246
-
247
- const index = i * 4 + j;
248
- const time = new Date(this.date.getFullYear(), index).getTime();
249
- cell.inRange = time >= getMonthTimestamp(this.minDate) && time <= getMonthTimestamp(this.maxDate);
250
- cell.start = this.minDate && time === getMonthTimestamp(this.minDate);
251
- cell.end = this.maxDate && time === getMonthTimestamp(this.maxDate);
252
- const isToday = time === now;
253
-
254
- if (isToday) {
255
- cell.type = 'today';
256
- }
257
- cell.text = index;
258
- let cellDate = new Date(time);
259
- cell.disabled = typeof disabledDate === 'function' && disabledDate(cellDate);
260
- cell.selected = arrayFind(selectedDate, date => date.getTime() === cellDate.getTime());
261
-
262
- this.$set(row, j, cell);
263
- }
264
- }
265
- return rows;
266
- }
267
- }
268
- };
269
- </script>
1
+ <template>
2
+ <table @click="handleMonthTableClick" @mousemove="handleMouseMove" class="el-month-table">
3
+ <tbody>
4
+ <tr v-for="(row, key) in rows" :key="key">
5
+ <td :class="getCellStyle(cell)" v-for="(cell, key) in row" :key="key">
6
+ <div>
7
+ <a class="cell">{{ t('el.datepicker.months.' + months[cell.text]) }}</a>
8
+ </div>
9
+ </td>
10
+ </tr>
11
+ </tbody>
12
+ </table>
13
+ </template>
14
+
15
+ <script type="text/babel">
16
+ import Locale from 'element-ui/src/mixins/locale';
17
+ import { isDate, range, getDayCountOfMonth, nextDate } from 'element-ui/src/utils/date-util';
18
+ import { hasClass } from 'element-ui/src/utils/dom';
19
+ import { arrayFindIndex, coerceTruthyValueToArray, arrayFind } from 'element-ui/src/utils/util';
20
+
21
+ const datesInMonth = (year, month) => {
22
+ const numOfDays = getDayCountOfMonth(year, month);
23
+ const firstDay = new Date(year, month, 1);
24
+ return range(numOfDays).map(n => nextDate(firstDay, n));
25
+ };
26
+
27
+ const clearDate = (date) => {
28
+ return new Date(date.getFullYear(), date.getMonth());
29
+ };
30
+
31
+ const getMonthTimestamp = function(time) {
32
+ if (typeof time === 'number' || typeof time === 'string') {
33
+ return clearDate(new Date(time)).getTime();
34
+ } else if (time instanceof Date) {
35
+ return clearDate(time).getTime();
36
+ } else {
37
+ return NaN;
38
+ }
39
+ };
40
+
41
+ // remove the first element that satisfies `pred` from arr
42
+ // return a new array if modification occurs
43
+ // return the original array otherwise
44
+ const removeFromArray = function(arr, pred) {
45
+ const idx = typeof pred === 'function' ? arrayFindIndex(arr, pred) : arr.indexOf(pred);
46
+ return idx >= 0 ? [...arr.slice(0, idx), ...arr.slice(idx + 1)] : arr;
47
+ };
48
+ export default {
49
+ props: {
50
+ disabledDate: {},
51
+ value: {},
52
+ selectionMode: {
53
+ default: 'month'
54
+ },
55
+ minDate: {},
56
+
57
+ maxDate: {},
58
+ defaultValue: {
59
+ validator(val) {
60
+ // null or valid Date Object
61
+ return val === null || isDate(val) || (Array.isArray(val) && val.every(isDate));
62
+ }
63
+ },
64
+ date: {},
65
+ rangeState: {
66
+ default() {
67
+ return {
68
+ endDate: null,
69
+ selecting: false
70
+ };
71
+ }
72
+ }
73
+ },
74
+
75
+ mixins: [Locale],
76
+
77
+ watch: {
78
+ 'rangeState.endDate'(newVal) {
79
+ this.markRange(this.minDate, newVal);
80
+ },
81
+
82
+ minDate(newVal, oldVal) {
83
+ if (getMonthTimestamp(newVal) !== getMonthTimestamp(oldVal)) {
84
+ this.markRange(this.minDate, this.maxDate);
85
+ }
86
+ },
87
+
88
+ maxDate(newVal, oldVal) {
89
+ if (getMonthTimestamp(newVal) !== getMonthTimestamp(oldVal)) {
90
+ this.markRange(this.minDate, this.maxDate);
91
+ }
92
+ }
93
+ },
94
+
95
+ data() {
96
+ return {
97
+ months: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'],
98
+ tableRows: [ [], [], [] ],
99
+ lastRow: null,
100
+ lastColumn: null
101
+ };
102
+ },
103
+
104
+ methods: {
105
+ cellMatchesDate(cell, date) {
106
+ const value = new Date(date);
107
+ return this.date.getFullYear() === value.getFullYear() && Number(cell.text) === value.getMonth();
108
+ },
109
+ getCellStyle(cell) {
110
+ const style = {};
111
+ const year = this.date.getFullYear();
112
+ const today = new Date();
113
+ const month = cell.text;
114
+ const defaultValue = this.defaultValue ? Array.isArray(this.defaultValue) ? this.defaultValue : [this.defaultValue] : [];
115
+ style.disabled = typeof this.disabledDate === 'function'
116
+ ? datesInMonth(year, month).every(this.disabledDate)
117
+ : false;
118
+ style.current = arrayFindIndex(coerceTruthyValueToArray(this.value), date => date.getFullYear() === year && date.getMonth() === month) >= 0;
119
+ style.today = today.getFullYear() === year && today.getMonth() === month;
120
+ style.default = defaultValue.some(date => this.cellMatchesDate(cell, date));
121
+
122
+ if (cell.inRange) {
123
+ style['in-range'] = true;
124
+
125
+ if (cell.start) {
126
+ style['start-date'] = true;
127
+ }
128
+
129
+ if (cell.end) {
130
+ style['end-date'] = true;
131
+ }
132
+ }
133
+ return style;
134
+ },
135
+ getMonthOfCell(month) {
136
+ const year = this.date.getFullYear();
137
+ return new Date(year, month, 1);
138
+ },
139
+ markRange(minDate, maxDate) {
140
+ minDate = getMonthTimestamp(minDate);
141
+ maxDate = getMonthTimestamp(maxDate) || minDate;
142
+ [minDate, maxDate] = [Math.min(minDate, maxDate), Math.max(minDate, maxDate)];
143
+ const rows = this.rows;
144
+ for (let i = 0, k = rows.length; i < k; i++) {
145
+ const row = rows[i];
146
+ for (let j = 0, l = row.length; j < l; j++) {
147
+
148
+ const cell = row[j];
149
+ const index = i * 4 + j;
150
+ const time = new Date(this.date.getFullYear(), index).getTime();
151
+
152
+ cell.inRange = minDate && time >= minDate && time <= maxDate;
153
+ cell.start = minDate && time === minDate;
154
+ cell.end = maxDate && time === maxDate;
155
+ }
156
+ }
157
+ },
158
+ handleMouseMove(event) {
159
+ if (!this.rangeState.selecting) return;
160
+
161
+ let target = event.target;
162
+ if (target.tagName === 'A') {
163
+ target = target.parentNode.parentNode;
164
+ }
165
+ if (target.tagName === 'DIV') {
166
+ target = target.parentNode;
167
+ }
168
+ if (target.tagName !== 'TD') return;
169
+
170
+ const row = target.parentNode.rowIndex;
171
+ const column = target.cellIndex;
172
+ // can not select disabled date
173
+ if (this.rows[row][column].disabled) return;
174
+
175
+ // only update rangeState when mouse moves to a new cell
176
+ // this avoids frequent Date object creation and improves performance
177
+ if (row !== this.lastRow || column !== this.lastColumn) {
178
+ this.lastRow = row;
179
+ this.lastColumn = column;
180
+ this.$emit('changerange', {
181
+ minDate: this.minDate,
182
+ maxDate: this.maxDate,
183
+ rangeState: {
184
+ selecting: true,
185
+ endDate: this.getMonthOfCell(row * 4 + column)
186
+ }
187
+ });
188
+ }
189
+ },
190
+ handleMonthTableClick(event) {
191
+ let target = event.target;
192
+ if (target.tagName === 'A') {
193
+ target = target.parentNode.parentNode;
194
+ }
195
+ if (target.tagName === 'DIV') {
196
+ target = target.parentNode;
197
+ }
198
+ if (target.tagName !== 'TD') return;
199
+ if (hasClass(target, 'disabled')) return;
200
+ const column = target.cellIndex;
201
+ const row = target.parentNode.rowIndex;
202
+ const month = row * 4 + column;
203
+ const newDate = this.getMonthOfCell(month);
204
+ if (this.selectionMode === 'range') {
205
+ if (!this.rangeState.selecting) {
206
+ this.$emit('pick', {minDate: newDate, maxDate: null});
207
+ this.rangeState.selecting = true;
208
+ } else {
209
+ if (newDate >= this.minDate) {
210
+ this.$emit('pick', {minDate: this.minDate, maxDate: newDate});
211
+ } else {
212
+ this.$emit('pick', {minDate: newDate, maxDate: this.minDate});
213
+ }
214
+ this.rangeState.selecting = false;
215
+ }
216
+ } else if (this.selectionMode === 'months') {
217
+ const value = this.value || [];
218
+ const year = this.date.getFullYear();
219
+ const newValue = arrayFindIndex(value, date => date.getFullYear() === year && date.getMonth() === month) >= 0
220
+ ? removeFromArray(value, date => date.getTime() === newDate.getTime())
221
+ : [...value, newDate];
222
+ this.$emit('pick', newValue);
223
+ } else {
224
+ this.$emit('pick', month);
225
+ }
226
+ }
227
+ },
228
+
229
+ computed: {
230
+ rows() {
231
+ // TODO: refactory rows / getCellClasses
232
+ const rows = this.tableRows;
233
+ const disabledDate = this.disabledDate;
234
+ const selectedDate = [];
235
+ const now = getMonthTimestamp(new Date());
236
+
237
+ for (let i = 0; i < 3; i++) {
238
+ const row = rows[i];
239
+ for (let j = 0; j < 4; j++) {
240
+ let cell = row[j];
241
+ if (!cell) {
242
+ cell = { row: i, column: j, type: 'normal', inRange: false, start: false, end: false };
243
+ }
244
+
245
+ cell.type = 'normal';
246
+
247
+ const index = i * 4 + j;
248
+ const time = new Date(this.date.getFullYear(), index).getTime();
249
+ cell.inRange = time >= getMonthTimestamp(this.minDate) && time <= getMonthTimestamp(this.maxDate);
250
+ cell.start = this.minDate && time === getMonthTimestamp(this.minDate);
251
+ cell.end = this.maxDate && time === getMonthTimestamp(this.maxDate);
252
+ const isToday = time === now;
253
+
254
+ if (isToday) {
255
+ cell.type = 'today';
256
+ }
257
+ cell.text = index;
258
+ let cellDate = new Date(time);
259
+ cell.disabled = typeof disabledDate === 'function' && disabledDate(cellDate);
260
+ cell.selected = arrayFind(selectedDate, date => date.getTime() === cellDate.getTime());
261
+
262
+ this.$set(row, j, cell);
263
+ }
264
+ }
265
+ return rows;
266
+ }
267
+ }
268
+ };
269
+ </script>