bi-eleme 2.2.1 → 2.4.2

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 (130) hide show
  1. package/lib/alert.js +4 -4
  2. package/lib/aside.js +4 -4
  3. package/lib/autocomplete.js +10 -10
  4. package/lib/avatar.js +4 -4
  5. package/lib/backtop.js +6 -6
  6. package/lib/badge.js +4 -4
  7. package/lib/breadcrumb-item.js +4 -4
  8. package/lib/breadcrumb.js +4 -4
  9. package/lib/button-group.js +4 -4
  10. package/lib/button.js +4 -4
  11. package/lib/calendar.js +15 -15
  12. package/lib/card.js +4 -4
  13. package/lib/carousel-item.js +4 -4
  14. package/lib/carousel.js +6 -6
  15. package/lib/cascader-panel.js +10 -10
  16. package/lib/cascader.js +12 -12
  17. package/lib/checkbox-button.js +4 -4
  18. package/lib/checkbox-group.js +4 -4
  19. package/lib/checkbox.js +4 -4
  20. package/lib/col.js +2 -2
  21. package/lib/collapse-item.js +6 -6
  22. package/lib/collapse.js +4 -4
  23. package/lib/color-picker.js +8 -8
  24. package/lib/container.js +4 -4
  25. package/lib/date-picker.js +65 -64
  26. package/lib/descriptions-item.js +2 -2
  27. package/lib/descriptions.js +2 -2
  28. package/lib/dialog.js +8 -8
  29. package/lib/divider.js +4 -4
  30. package/lib/drawer.js +6 -6
  31. package/lib/dropdown-item.js +4 -4
  32. package/lib/dropdown-menu.js +4 -4
  33. package/lib/dropdown.js +16 -16
  34. package/lib/element-ui.common.js +4772 -311
  35. package/lib/empty.js +4 -4
  36. package/lib/footer.js +4 -4
  37. package/lib/form-item.js +6 -6
  38. package/lib/form.js +11 -11
  39. package/lib/header.js +4 -4
  40. package/lib/icon.js +4 -4
  41. package/lib/image.js +8 -8
  42. package/lib/index.js +1 -1
  43. package/lib/infinite-scroll.js +2 -2
  44. package/lib/input-number.js +6 -6
  45. package/lib/input.js +6 -6
  46. package/lib/link.js +4 -4
  47. package/lib/loading.js +6 -6
  48. package/lib/main.js +4 -4
  49. package/lib/menu-item-group.js +4 -4
  50. package/lib/menu-item.js +6 -6
  51. package/lib/menu.js +6 -6
  52. package/lib/message-box.js +13 -13
  53. package/lib/message.js +8 -8
  54. package/lib/notification.js +8 -8
  55. package/lib/option-group.js +4 -4
  56. package/lib/option.js +4 -4
  57. package/lib/page-header.js +4 -4
  58. package/lib/pagination.js +4 -4
  59. package/lib/popconfirm.js +8 -8
  60. package/lib/popover.js +4 -4
  61. package/lib/progress.js +4 -4
  62. package/lib/radio-button.js +4 -4
  63. package/lib/radio-group.js +4 -4
  64. package/lib/radio.js +4 -4
  65. package/lib/rate.js +6 -6
  66. package/lib/result.js +4 -4
  67. package/lib/row.js +2 -2
  68. package/lib/scrollbar.js +2 -2
  69. package/lib/select.js +16 -16
  70. package/lib/skeleton-item.js +4 -4
  71. package/lib/skeleton.js +4 -4
  72. package/lib/slider.js +8 -8
  73. package/lib/spinner.js +4 -4
  74. package/lib/step.js +4 -4
  75. package/lib/steps.js +6 -6
  76. package/lib/submenu.js +6 -6
  77. package/lib/super-date.js +4832 -0
  78. package/lib/switch.js +6 -6
  79. package/lib/tab-pane.js +4 -4
  80. package/lib/table-column.js +2 -2
  81. package/lib/table.js +20 -18
  82. package/lib/tabs.js +4 -4
  83. package/lib/tag.js +4 -4
  84. package/lib/theme-chalk/index.css +1 -1
  85. package/lib/theme-chalk/super-date.css +1 -0
  86. package/lib/time-picker.js +59 -59
  87. package/lib/time-select.js +16 -16
  88. package/lib/timeline-item.js +4 -4
  89. package/lib/timeline.js +4 -4
  90. package/lib/tooltip.js +2 -2
  91. package/lib/transfer.js +8 -8
  92. package/lib/tree.js +6 -6
  93. package/lib/upload.js +15 -15
  94. package/lib/utils/date-util.js +5 -2
  95. package/lib/utils/date.js +67 -9
  96. package/package.json +1 -1
  97. package/packages/super-date/index.js +8 -0
  98. package/packages/super-date/src/basic/date-table.vue +448 -0
  99. package/packages/super-date/src/basic/month-table.vue +278 -0
  100. package/packages/super-date/src/basic/time-spinner.vue +340 -0
  101. package/packages/super-date/src/basic/year-table.vue +144 -0
  102. package/packages/super-date/src/panel/date-range.vue +1000 -0
  103. package/packages/super-date/src/panel/date.vue +649 -0
  104. package/packages/super-date/src/panel/month-range.vue +289 -0
  105. package/packages/super-date/src/panel/time-range.vue +250 -0
  106. package/packages/super-date/src/panel/time-select.vue +195 -0
  107. package/packages/super-date/src/panel/time.vue +211 -0
  108. package/packages/super-date/src/picker/date-picker.js +29 -0
  109. package/packages/super-date/src/picker/time-picker.js +39 -0
  110. package/packages/super-date/src/picker/time-select.js +21 -0
  111. package/packages/super-date/src/picker.vue +955 -0
  112. package/packages/theme-chalk/lib/index.css +1 -1
  113. package/packages/theme-chalk/lib/super-date.css +1 -0
  114. package/packages/theme-chalk/src/index.scss +1 -0
  115. package/packages/theme-chalk/src/super-date/date-picker.scss +106 -0
  116. package/packages/theme-chalk/src/super-date/date-range-picker.scss +138 -0
  117. package/packages/theme-chalk/src/super-date/date-table.scss +154 -0
  118. package/packages/theme-chalk/src/super-date/month-table.scss +96 -0
  119. package/packages/theme-chalk/src/super-date/picker-panel.scss +130 -0
  120. package/packages/theme-chalk/src/super-date/picker.scss +204 -0
  121. package/packages/theme-chalk/src/super-date/time-picker.scss +94 -0
  122. package/packages/theme-chalk/src/super-date/time-range-picker.scss +32 -0
  123. package/packages/theme-chalk/src/super-date/time-spinner.scss +111 -0
  124. package/packages/theme-chalk/src/super-date/year-table.scss +66 -0
  125. package/packages/theme-chalk/src/super-date.scss +12 -0
  126. package/src/index.js +4 -1
  127. package/src/utils/date-util.js +3 -0
  128. package/src/utils/date.js +291 -195
  129. package/types/element-ui.d.ts +9 -5
  130. package/types/super-date.d.ts +124 -0
package/src/utils/date.js CHANGED
@@ -25,57 +25,56 @@
25
25
 
26
26
  /*eslint-disable*/
27
27
  // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
28
- (function (main) {
29
- 'use strict';
28
+ ;(function (main) {
29
+ 'use strict'
30
30
 
31
31
  /**
32
32
  * Parse or format dates
33
33
  * @class fecha
34
34
  */
35
- var fecha = {};
36
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
37
- var twoDigits = '\\d\\d?';
38
- var threeDigits = '\\d{3}';
39
- var fourDigits = '\\d{4}';
40
- var word = '[^\\s]+';
41
- var literal = /\[([^]*?)\]/gm;
42
- var noop = function () {
43
- };
35
+ var fecha = {}
36
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g
37
+ var twoDigits = '\\d\\d?'
38
+ var threeDigits = '\\d{3}'
39
+ var fourDigits = '\\d{4}'
40
+ var word = '[^\\s]+'
41
+ var literal = /\[([^]*?)\]/gm
42
+ var noop = function () {}
44
43
 
45
44
  function regexEscape(str) {
46
- return str.replace( /[|\\{()[^$+*?.-]/g, '\\$&');
45
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&')
47
46
  }
48
47
 
49
48
  function shorten(arr, sLen) {
50
- var newArr = [];
49
+ var newArr = []
51
50
  for (var i = 0, len = arr.length; i < len; i++) {
52
- newArr.push(arr[i].substr(0, sLen));
51
+ newArr.push(arr[i].substr(0, sLen))
53
52
  }
54
- return newArr;
53
+ return newArr
55
54
  }
56
55
 
57
56
  function monthUpdate(arrName) {
58
57
  return function (d, v, i18n) {
59
- var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
58
+ var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase())
60
59
  if (~index) {
61
- d.month = index;
60
+ d.month = index
62
61
  }
63
- };
62
+ }
64
63
  }
65
64
 
66
65
  function pad(val, len) {
67
- val = String(val);
68
- len = len || 2;
66
+ val = String(val)
67
+ len = len || 2
69
68
  while (val.length < len) {
70
- val = '0' + val;
69
+ val = '0' + val
71
70
  }
72
- return val;
71
+ return val
73
72
  }
74
73
 
75
- var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
76
- var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
77
- var monthNamesShort = shorten(monthNames, 3);
78
- var dayNamesShort = shorten(dayNames, 3);
74
+ var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
75
+ var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
76
+ var monthNamesShort = shorten(monthNames, 3)
77
+ var dayNamesShort = shorten(dayNames, 3)
79
78
  fecha.i18n = {
80
79
  dayNamesShort: dayNamesShort,
81
80
  dayNames: dayNames,
@@ -83,160 +82,200 @@
83
82
  monthNames: monthNames,
84
83
  amPm: ['am', 'pm'],
85
84
  DoFn: function DoFn(D) {
86
- return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
85
+ return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : ((D - (D % 10) !== 10) * D) % 10]
87
86
  }
88
- };
87
+ }
89
88
 
90
89
  var formatFlags = {
91
- D: function(dateObj) {
92
- return dateObj.getDay();
90
+ D: function (dateObj) {
91
+ return dateObj.getDay()
93
92
  },
94
- DD: function(dateObj) {
95
- return pad(dateObj.getDay());
93
+ DD: function (dateObj) {
94
+ return pad(dateObj.getDay())
96
95
  },
97
- Do: function(dateObj, i18n) {
98
- return i18n.DoFn(dateObj.getDate());
96
+ Do: function (dateObj, i18n) {
97
+ return i18n.DoFn(dateObj.getDate())
99
98
  },
100
- d: function(dateObj) {
101
- return dateObj.getDate();
99
+ d: function (dateObj) {
100
+ return dateObj.getDate()
102
101
  },
103
- dd: function(dateObj) {
104
- return pad(dateObj.getDate());
102
+ dd: function (dateObj) {
103
+ return pad(dateObj.getDate())
105
104
  },
106
- ddd: function(dateObj, i18n) {
107
- return i18n.dayNamesShort[dateObj.getDay()];
105
+ ddd: function (dateObj, i18n) {
106
+ return i18n.dayNamesShort[dateObj.getDay()]
108
107
  },
109
- dddd: function(dateObj, i18n) {
110
- return i18n.dayNames[dateObj.getDay()];
108
+ dddd: function (dateObj, i18n) {
109
+ return i18n.dayNames[dateObj.getDay()]
111
110
  },
112
- M: function(dateObj) {
113
- return dateObj.getMonth() + 1;
111
+ M: function (dateObj) {
112
+ return dateObj.getMonth() + 1
114
113
  },
115
- MM: function(dateObj) {
116
- return pad(dateObj.getMonth() + 1);
114
+ MM: function (dateObj) {
115
+ return pad(dateObj.getMonth() + 1)
117
116
  },
118
- MMM: function(dateObj, i18n) {
119
- return i18n.monthNamesShort[dateObj.getMonth()];
117
+ MMM: function (dateObj, i18n) {
118
+ return i18n.monthNamesShort[dateObj.getMonth()]
120
119
  },
121
- MMMM: function(dateObj, i18n) {
122
- return i18n.monthNames[dateObj.getMonth()];
120
+ MMMM: function (dateObj, i18n) {
121
+ return i18n.monthNames[dateObj.getMonth()]
123
122
  },
124
- yy: function(dateObj) {
125
- return pad(String(dateObj.getFullYear()), 4).substr(2);
123
+ yy: function (dateObj) {
124
+ return pad(String(dateObj.getFullYear()), 4).substr(2)
126
125
  },
127
- yyyy: function(dateObj) {
128
- return pad(dateObj.getFullYear(), 4);
126
+ yyyy: function (dateObj) {
127
+ return pad(dateObj.getFullYear(), 4)
129
128
  },
130
- h: function(dateObj) {
131
- return dateObj.getHours() % 12 || 12;
129
+ h: function (dateObj) {
130
+ return dateObj.getHours() % 12 || 12
132
131
  },
133
- hh: function(dateObj) {
134
- return pad(dateObj.getHours() % 12 || 12);
132
+ hh: function (dateObj) {
133
+ return pad(dateObj.getHours() % 12 || 12)
135
134
  },
136
- H: function(dateObj) {
137
- return dateObj.getHours();
135
+ H: function (dateObj) {
136
+ return dateObj.getHours()
138
137
  },
139
- HH: function(dateObj) {
140
- return pad(dateObj.getHours());
138
+ HH: function (dateObj) {
139
+ return pad(dateObj.getHours())
141
140
  },
142
- m: function(dateObj) {
143
- return dateObj.getMinutes();
141
+ m: function (dateObj) {
142
+ return dateObj.getMinutes()
144
143
  },
145
- mm: function(dateObj) {
146
- return pad(dateObj.getMinutes());
144
+ mm: function (dateObj) {
145
+ return pad(dateObj.getMinutes())
147
146
  },
148
- s: function(dateObj) {
149
- return dateObj.getSeconds();
147
+ s: function (dateObj) {
148
+ return dateObj.getSeconds()
150
149
  },
151
- ss: function(dateObj) {
152
- return pad(dateObj.getSeconds());
150
+ ss: function (dateObj) {
151
+ return pad(dateObj.getSeconds())
153
152
  },
154
- S: function(dateObj) {
155
- return Math.round(dateObj.getMilliseconds() / 100);
153
+ S: function (dateObj) {
154
+ return Math.round(dateObj.getMilliseconds() / 100)
156
155
  },
157
- SS: function(dateObj) {
158
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
156
+ SS: function (dateObj) {
157
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2)
159
158
  },
160
- SSS: function(dateObj) {
161
- return pad(dateObj.getMilliseconds(), 3);
159
+ SSS: function (dateObj) {
160
+ return pad(dateObj.getMilliseconds(), 3)
162
161
  },
163
- a: function(dateObj, i18n) {
164
- return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
162
+ a: function (dateObj, i18n) {
163
+ return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1]
165
164
  },
166
- A: function(dateObj, i18n) {
167
- return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
165
+ A: function (dateObj, i18n) {
166
+ return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase()
168
167
  },
169
- ZZ: function(dateObj) {
170
- var o = dateObj.getTimezoneOffset();
171
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
168
+ ZZ: function (dateObj) {
169
+ var o = dateObj.getTimezoneOffset()
170
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + (Math.abs(o) % 60), 4)
172
171
  }
173
- };
172
+ }
174
173
 
175
174
  var parseFlags = {
176
- d: [twoDigits, function (d, v) {
177
- d.day = v;
178
- }],
179
- Do: [twoDigits + word, function (d, v) {
180
- d.day = parseInt(v, 10);
181
- }],
182
- M: [twoDigits, function (d, v) {
183
- d.month = v - 1;
184
- }],
185
- yy: [twoDigits, function (d, v) {
186
- var da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
187
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
188
- }],
189
- h: [twoDigits, function (d, v) {
190
- d.hour = v;
191
- }],
192
- m: [twoDigits, function (d, v) {
193
- d.minute = v;
194
- }],
195
- s: [twoDigits, function (d, v) {
196
- d.second = v;
197
- }],
198
- yyyy: [fourDigits, function (d, v) {
199
- d.year = v;
200
- }],
201
- S: ['\\d', function (d, v) {
202
- d.millisecond = v * 100;
203
- }],
204
- SS: ['\\d{2}', function (d, v) {
205
- d.millisecond = v * 10;
206
- }],
207
- SSS: [threeDigits, function (d, v) {
208
- d.millisecond = v;
209
- }],
175
+ d: [
176
+ twoDigits,
177
+ function (d, v) {
178
+ d.day = v
179
+ }
180
+ ],
181
+ Do: [
182
+ twoDigits + word,
183
+ function (d, v) {
184
+ d.day = parseInt(v, 10)
185
+ }
186
+ ],
187
+ M: [
188
+ twoDigits,
189
+ function (d, v) {
190
+ d.month = v - 1
191
+ }
192
+ ],
193
+ yy: [
194
+ twoDigits,
195
+ function (d, v) {
196
+ var da = new Date(),
197
+ cent = +('' + da.getFullYear()).substr(0, 2)
198
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v
199
+ }
200
+ ],
201
+ h: [
202
+ twoDigits,
203
+ function (d, v) {
204
+ d.hour = v
205
+ }
206
+ ],
207
+ m: [
208
+ twoDigits,
209
+ function (d, v) {
210
+ d.minute = v
211
+ }
212
+ ],
213
+ s: [
214
+ twoDigits,
215
+ function (d, v) {
216
+ d.second = v
217
+ }
218
+ ],
219
+ yyyy: [
220
+ fourDigits,
221
+ function (d, v) {
222
+ d.year = v
223
+ }
224
+ ],
225
+ S: [
226
+ '\\d',
227
+ function (d, v) {
228
+ d.millisecond = v * 100
229
+ }
230
+ ],
231
+ SS: [
232
+ '\\d{2}',
233
+ function (d, v) {
234
+ d.millisecond = v * 10
235
+ }
236
+ ],
237
+ SSS: [
238
+ threeDigits,
239
+ function (d, v) {
240
+ d.millisecond = v
241
+ }
242
+ ],
210
243
  D: [twoDigits, noop],
211
244
  ddd: [word, noop],
212
245
  MMM: [word, monthUpdate('monthNamesShort')],
213
246
  MMMM: [word, monthUpdate('monthNames')],
214
- a: [word, function (d, v, i18n) {
215
- var val = v.toLowerCase();
216
- if (val === i18n.amPm[0]) {
217
- d.isPm = false;
218
- } else if (val === i18n.amPm[1]) {
219
- d.isPm = true;
247
+ a: [
248
+ word,
249
+ function (d, v, i18n) {
250
+ var val = v.toLowerCase()
251
+ if (val === i18n.amPm[0]) {
252
+ d.isPm = false
253
+ } else if (val === i18n.amPm[1]) {
254
+ d.isPm = true
255
+ }
220
256
  }
221
- }],
222
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
223
- var parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
257
+ ],
258
+ ZZ: [
259
+ '[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z',
260
+ function (d, v) {
261
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
262
+ minutes
224
263
 
225
- if (parts) {
226
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
227
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
264
+ if (parts) {
265
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10)
266
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes
267
+ }
228
268
  }
229
- }]
230
- };
231
- parseFlags.dd = parseFlags.d;
232
- parseFlags.dddd = parseFlags.ddd;
233
- parseFlags.DD = parseFlags.D;
234
- parseFlags.mm = parseFlags.m;
235
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
236
- parseFlags.MM = parseFlags.M;
237
- parseFlags.ss = parseFlags.s;
238
- parseFlags.A = parseFlags.a;
239
-
269
+ ]
270
+ }
271
+ parseFlags.dd = parseFlags.d
272
+ parseFlags.dddd = parseFlags.ddd
273
+ parseFlags.DD = parseFlags.D
274
+ parseFlags.mm = parseFlags.m
275
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h
276
+ parseFlags.MM = parseFlags.M
277
+ parseFlags.ss = parseFlags.s
278
+ parseFlags.A = parseFlags.a
240
279
 
241
280
  // Some common format strings
242
281
  fecha.masks = {
@@ -248,7 +287,7 @@
248
287
  shortTime: 'HH:mm',
249
288
  mediumTime: 'HH:mm:ss',
250
289
  longTime: 'HH:mm:ss.SSS'
251
- };
290
+ }
252
291
 
253
292
  /***
254
293
  * Format a date
@@ -257,34 +296,34 @@
257
296
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
258
297
  */
259
298
  fecha.format = function (dateObj, mask, i18nSettings) {
260
- var i18n = i18nSettings || fecha.i18n;
299
+ var i18n = i18nSettings || fecha.i18n
261
300
 
262
301
  if (typeof dateObj === 'number') {
263
- dateObj = new Date(dateObj);
302
+ dateObj = new Date(dateObj)
264
303
  }
265
304
 
266
305
  if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
267
- throw new Error('Invalid Date in fecha.format');
306
+ throw new Error('Invalid Date in fecha.format')
268
307
  }
269
308
 
270
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
309
+ mask = fecha.masks[mask] || mask || fecha.masks['default']
271
310
 
272
- var literals = [];
311
+ var literals = []
273
312
 
274
313
  // Make literals inactive by replacing them with ??
275
- mask = mask.replace(literal, function($0, $1) {
276
- literals.push($1);
277
- return '@@@';
278
- });
314
+ mask = mask.replace(literal, function ($0, $1) {
315
+ literals.push($1)
316
+ return '@@@'
317
+ })
279
318
  // Apply formatting rules
280
319
  mask = mask.replace(token, function ($0) {
281
- return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
282
- });
320
+ return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1)
321
+ })
283
322
  // Inline literal values back into the formatted value
284
- return mask.replace(/@@@/g, function() {
285
- return literals.shift();
286
- });
287
- };
323
+ return mask.replace(/@@@/g, function () {
324
+ return literals.shift()
325
+ })
326
+ }
288
327
 
289
328
  /**
290
329
  * Parse a date string into an object, changes - into /
@@ -294,75 +333,132 @@
294
333
  * @returns {Date|boolean}
295
334
  */
296
335
  fecha.parse = function (dateStr, format, i18nSettings) {
297
- var i18n = i18nSettings || fecha.i18n;
336
+ var i18n = i18nSettings || fecha.i18n
298
337
 
299
338
  if (typeof format !== 'string') {
300
- throw new Error('Invalid format in fecha.parse');
339
+ throw new Error('Invalid format in fecha.parse')
301
340
  }
302
341
 
303
- format = fecha.masks[format] || format;
342
+ format = fecha.masks[format] || format
304
343
 
305
344
  // Avoid regular expression denial of service, fail early for really long strings
306
345
  // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
307
346
  if (dateStr.length > 1000) {
308
- return null;
347
+ return null
309
348
  }
310
349
 
311
- var dateInfo = {};
312
- var parseInfo = [];
313
- var literals = [];
314
- format = format.replace(literal, function($0, $1) {
315
- literals.push($1);
316
- return '@@@';
317
- });
350
+ var dateInfo = {}
351
+ var parseInfo = []
352
+ var literals = []
353
+ format = format.replace(literal, function ($0, $1) {
354
+ literals.push($1)
355
+ return '@@@'
356
+ })
318
357
  var newFormat = regexEscape(format).replace(token, function ($0) {
319
358
  if (parseFlags[$0]) {
320
- var info = parseFlags[$0];
321
- parseInfo.push(info[1]);
322
- return '(' + info[0] + ')';
359
+ var info = parseFlags[$0]
360
+ parseInfo.push(info[1])
361
+ return '(' + info[0] + ')'
323
362
  }
324
363
 
325
- return $0;
326
- });
327
- newFormat = newFormat.replace(/@@@/g, function() {
328
- return literals.shift();
329
- });
330
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
364
+ return $0
365
+ })
366
+ newFormat = newFormat.replace(/@@@/g, function () {
367
+ return literals.shift()
368
+ })
369
+ var matches = dateStr.match(new RegExp(newFormat, 'i'))
331
370
  if (!matches) {
332
- return null;
371
+ return null
333
372
  }
334
373
 
335
374
  for (var i = 1; i < matches.length; i++) {
336
- parseInfo[i - 1](dateInfo, matches[i], i18n);
375
+ parseInfo[i - 1](dateInfo, matches[i], i18n)
337
376
  }
338
377
 
339
- var today = new Date();
378
+ var today = new Date()
340
379
  if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
341
- dateInfo.hour = +dateInfo.hour + 12;
380
+ dateInfo.hour = +dateInfo.hour + 12
342
381
  } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
343
- dateInfo.hour = 0;
382
+ dateInfo.hour = 0
344
383
  }
345
384
 
346
- var date;
385
+ var date
347
386
  if (dateInfo.timezoneOffset != null) {
348
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
349
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
350
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
387
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset
388
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0))
351
389
  } else {
352
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
353
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
390
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0)
354
391
  }
355
- return date;
356
- };
392
+ return date
393
+ }
394
+
395
+ /**
396
+ * Calculate days difference between two dates
397
+ * @param {Date|string} date1 First date
398
+ * @param {Date|string} date2 Second date (optional, defaults to current date)
399
+ * @returns {number} Days difference
400
+ */
401
+ fecha.getDaysDiff = function (date1, date2) {
402
+ // Convert to Date objects if strings
403
+ if (typeof date1 === 'string') {
404
+ date1 = fecha.parse(date1, 'yyyy-MM-dd')
405
+ }
406
+ if (!date2) {
407
+ date2 = new Date()
408
+ } else if (typeof date2 === 'string') {
409
+ date2 = fecha.parse(date2, 'yyyy-MM-dd')
410
+ }
411
+
412
+ // Validate dates
413
+ if (!date1 || !date2 || isNaN(date1.getTime()) || isNaN(date2.getTime())) {
414
+ throw new Error('Invalid date in fecha.getDaysDiff')
415
+ }
416
+
417
+ // Reset time to midnight to ensure accurate day calculation
418
+ date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate())
419
+ date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate())
420
+
421
+ // Calculate difference in days
422
+ const timeDiff = date2.getTime() - date1.getTime()
423
+ return Math.round(timeDiff / (1000 * 60 * 60 * 24))
424
+ }
425
+
426
+ /**
427
+ * Calculate the date that is a specified number of days before the given date
428
+ * @param {Date|string} date The reference date
429
+ * @param {number} diff Number of days to subtract (must be positive)
430
+ * @returns {Date} The resulting date
431
+ */
432
+ fecha.setDaysDiff = function (date, diff) {
433
+ // Validate diff parameter
434
+ if (typeof diff !== 'number' || diff < 0) {
435
+ throw new Error('diff parameter must be a positive number in fecha.setDaysDiff')
436
+ }
437
+
438
+ // Convert to Date object if string
439
+ if (typeof date === 'string') {
440
+ date = fecha.parse(date, 'yyyy-MM-dd')
441
+ }
442
+
443
+ // Validate date
444
+ if (!date || isNaN(date.getTime())) {
445
+ throw new Error('Invalid date in fecha.setDaysDiff')
446
+ }
447
+
448
+ // Reset time to midnight to ensure accurate day calculation
449
+ const result = new Date(date.getFullYear(), date.getMonth(), date.getDate())
450
+ result.setDate(result.getDate() - diff)
451
+ return result
452
+ }
357
453
 
358
454
  /* istanbul ignore next */
359
455
  if (typeof module !== 'undefined' && module.exports) {
360
- module.exports = fecha;
456
+ module.exports = fecha
361
457
  } else if (typeof define === 'function' && define.amd) {
362
458
  define(function () {
363
- return fecha;
364
- });
459
+ return fecha
460
+ })
365
461
  } else {
366
- main.fecha = fecha;
462
+ main.fecha = fecha
367
463
  }
368
- })(this);
464
+ })(this)
@@ -22,6 +22,7 @@ import { ElCollapseItem } from './collapse-item'
22
22
  import { ElColorPicker } from './color-picker'
23
23
  import { ElContainer } from './container'
24
24
  import { ElDatePicker } from './date-picker'
25
+ import { ElSuperDate } from './super-date'
25
26
  import { ElDialog } from './dialog'
26
27
  import { ElDropdown } from './dropdown'
27
28
  import { ElDropdownItem } from './dropdown-item'
@@ -90,8 +91,8 @@ import { ElDescriptionsItem } from './descriptions-item'
90
91
  import { ElResult } from './result'
91
92
 
92
93
  export interface InstallationOptions {
93
- locale: any,
94
- i18n: any,
94
+ locale: any
95
+ i18n: any
95
96
  size: string
96
97
  }
97
98
 
@@ -103,7 +104,7 @@ export const version: string
103
104
  * Please do not invoke this method directly.
104
105
  * Call `Vue.use(ElementUI)` to install.
105
106
  */
106
- export function install (vue: typeof Vue, options: InstallationOptions): void
107
+ export function install(vue: typeof Vue, options: InstallationOptions): void
107
108
 
108
109
  /** ElementUI component common definition */
109
110
  export type Component = ElementUIComponent
@@ -191,6 +192,9 @@ export class Container extends ElContainer {}
191
192
  /** Date Picker Component */
192
193
  export class DatePicker extends ElDatePicker {}
193
194
 
195
+ /** SuperDate Component */
196
+ export class SuperDate extends ElSuperDate {}
197
+
194
198
  /** Dialog Component */
195
199
  export class Dialog extends ElDialog {}
196
200
 
@@ -339,7 +343,7 @@ export class Calendar extends ElCalendar {}
339
343
  export class Backtop extends ElBacktop {}
340
344
 
341
345
  /** InfiniteScroll Directive */
342
- export const InfiniteScroll: PluginObject<ElInfiniteScroll>;
346
+ export const InfiniteScroll: PluginObject<ElInfiniteScroll>
343
347
 
344
348
  /** PageHeader Component */
345
349
  export class PageHeader extends ElPageHeader {}
@@ -375,4 +379,4 @@ export class Descriptions extends ElDescriptions {}
375
379
  export class DescriptionsItem extends ElDescriptionsItem {}
376
380
 
377
381
  /** Result Component */
378
- export class Result extends ElResult {}
382
+ export class Result extends ElResult {}