kui-vue 3.2.5 → 3.2.7

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 (107) hide show
  1. package/components/_tool/directives.js +3 -1
  2. package/components/_tool/docClick.js +3 -1
  3. package/components/_tool/outsiteclick.js +1 -2
  4. package/components/_tool/resize.js +2 -3
  5. package/components/_tool/scroll.js +2 -3
  6. package/components/_tool/transfer.js +3 -1
  7. package/components/_tool/utils.js +9 -3
  8. package/components/affix/affix.jsx +21 -8
  9. package/components/avatar/styles/index.less +1 -1
  10. package/components/base/drop.jsx +3 -3
  11. package/components/base/pop.jsx +7 -4
  12. package/components/bin/index.js +2 -0
  13. package/components/button/styles/index.less +7 -6
  14. package/components/colorPicker/colorpicker.jsx +27 -15
  15. package/components/colorPicker/demo/base.md +1 -1
  16. package/components/colorPicker/demo/index.vue +2 -0
  17. package/components/colorPicker/demo/shape.md +33 -0
  18. package/components/colorPicker/index.md +10 -7
  19. package/components/colorPicker/styles/index.less +30 -13
  20. package/components/datePicker/datecalendar.jsx +149 -83
  21. package/components/datePicker/datepicker.jsx +11 -7
  22. package/components/datePicker/demo/base.md +2 -0
  23. package/components/datePicker/demo/index.vue +2 -0
  24. package/components/datePicker/demo/inside.md +76 -0
  25. package/components/datePicker/demo/size.md +3 -3
  26. package/components/datePicker/index.js +2 -1
  27. package/components/datePicker/index.md +1 -0
  28. package/components/datePicker/styles/calendar.less +149 -49
  29. package/components/datePicker/styles/datepicker.less +3 -3
  30. package/components/drawer/demo/base.md +2 -2
  31. package/components/drawer/demo/custom.md +2 -2
  32. package/components/drawer/demo/form.md +1 -1
  33. package/components/drawer/demo/target.md +14 -3
  34. package/components/drawer/drawer.jsx +11 -10
  35. package/components/drawer/index.md +1 -1
  36. package/components/drawer/styles/animal.less +2 -1
  37. package/components/drawer/styles/index.less +26 -10
  38. package/components/dropdown/dropdown.jsx +0 -1
  39. package/components/empty/empty.jsx +2 -1
  40. package/components/form/form.jsx +1 -1
  41. package/components/icon/demo/search.vue +4 -4
  42. package/components/icon/index.md +1 -1
  43. package/components/image/preview.jsx +10 -8
  44. package/components/index.js +12 -4
  45. package/components/input/demo/size.md +3 -3
  46. package/components/input/styles/index.less +5 -5
  47. package/components/locale/index.js +74 -0
  48. package/components/locale/lang/de.js +55 -0
  49. package/components/locale/lang/el.js +72 -0
  50. package/components/locale/lang/en.js +55 -0
  51. package/components/locale/lang/fr.js +72 -0
  52. package/components/locale/lang/it.js +72 -0
  53. package/components/locale/lang/ja.js +72 -0
  54. package/components/locale/lang/ko.js +72 -0
  55. package/components/locale/lang/ru.js +55 -0
  56. package/components/locale/lang/th.js +72 -0
  57. package/components/locale/lang/ua.js +55 -0
  58. package/components/locale/lang/vi.js +55 -0
  59. package/components/locale/lang/zh-CN.js +55 -0
  60. package/components/locale/lang/zh-TW.js +55 -0
  61. package/components/message/styles/index.less +4 -3
  62. package/components/modal/demo/custom.md +1 -1
  63. package/components/modal/index.js +8 -6
  64. package/components/modal/modal.jsx +42 -37
  65. package/components/page/page.jsx +4 -3
  66. package/components/page/styles/index.less +13 -13
  67. package/components/popconfirm/popconfirm.jsx +2 -2
  68. package/components/select/demo/filterable.md +6 -14
  69. package/components/select/demo/search.md +6 -4
  70. package/components/select/index.md +20 -19
  71. package/components/select/select.jsx +7 -4
  72. package/components/select/styles/index.less +13 -3
  73. package/components/slider/slider.jsx +6 -4
  74. package/components/space/space.jsx +2 -2
  75. package/components/styles/color.less +2 -2
  76. package/components/table/extend.jsx +1 -1
  77. package/components/table/index.md +4 -3
  78. package/components/table/table.jsx +4 -3
  79. package/components/tabs/tabs.jsx +3 -3
  80. package/components/timeline/demo/base.md +3 -3
  81. package/components/timeline/demo/icon.md +5 -5
  82. package/components/timeline/demo/mode.md +12 -6
  83. package/components/timeline/index.md +7 -6
  84. package/components/timeline/styles/index.less +40 -13
  85. package/components/timeline/timeline.jsx +5 -1
  86. package/components/timeline/timelineitem.jsx +9 -5
  87. package/components/treeselect/treeselect.vue +36 -35
  88. package/components/upload/index.md +1 -1
  89. package/components/upload/styles/index.less +1 -1
  90. package/components/upload/upload.jsx +5 -4
  91. package/dist/k-ui.css +7 -1
  92. package/dist/k-ui.js +2 -2
  93. package/dist/locale/de.js +8 -0
  94. package/dist/locale/el.js +8 -0
  95. package/dist/locale/en.js +8 -0
  96. package/dist/locale/fr.js +8 -0
  97. package/dist/locale/it.js +8 -0
  98. package/dist/locale/ja.js +8 -0
  99. package/dist/locale/ko.js +8 -0
  100. package/dist/locale/ru.js +8 -0
  101. package/dist/locale/th.js +8 -0
  102. package/dist/locale/ua.js +8 -0
  103. package/dist/locale/vi.js +8 -0
  104. package/dist/locale/zhCN.js +8 -0
  105. package/dist/locale/zhTW.js +8 -0
  106. package/package.json +4 -3
  107. package/readme.md +1 -1
@@ -2,6 +2,7 @@
2
2
  import Button from '../button'
3
3
  import moment from 'moment'
4
4
  import animate from '../_tool/animate'
5
+ import { t } from '../locale'
5
6
  export default {
6
7
  name: "Calendar",
7
8
  props: {
@@ -12,11 +13,11 @@ export default {
12
13
  mode: { type: String, default: 'date' },
13
14
  format: { type: String, default: 'YYYY-MM-DD' },
14
15
  float: String,
16
+ pickerSize: String,
15
17
  },
16
18
  data() {
17
19
  return {
18
20
  showYears: false,
19
- showMonths: false,
20
21
  showTimes: false,
21
22
  currentValue: this.value ? new Date(this.value) : '',
22
23
  today: new Date(),
@@ -28,9 +29,9 @@ export default {
28
29
  second: null,
29
30
 
30
31
  monthsHead: "1.2.3.4.5.6.7.8.9.10.11.12".split("."),
31
- months: "一.二.三.四.五.六.七.八.九.十.十一.十二".split("."), // months of panel
32
- weeks: "一.二.三.四.五.六.日".split("."), // weeks
33
- years: [],
32
+ // months: t('k.datePicker.months'), // months of panel
33
+ // weeks: t('k.datePicker.weeks'), // weeks
34
+ // years: [],
34
35
 
35
36
  };
36
37
  },
@@ -44,10 +45,23 @@ export default {
44
45
  this.updateStamp()
45
46
  }
46
47
  },
48
+ showYears(show) {
49
+ if (show) {
50
+ this.$nextTick(e => {
51
+ let year = new Date().getFullYear()
52
+ let y = this.years.indexOf(this.year || year)
53
+ let d = [y, this.month].map(x => x * 40)
54
+ let years = this.$refs.yearspicker;
55
+ let month = this.$refs.monthspicker;
56
+ years.scrollTop = d[0]
57
+ month.scrollTop = d[1]
58
+ })
59
+ }
60
+ },
47
61
  showTimes(show) {
48
62
  if (show) {
49
63
  this.$nextTick(e => {
50
- let d = [this.hour, this.minute, this.second].map(x => x * 24)
64
+ let d = [this.hour, this.minute, this.second].map(x => x * 32)
51
65
  let childs = this.$refs.timepicker.children;
52
66
  [0, 1, 2].map((e, i) => childs[i].scrollTop = d[i])
53
67
  })
@@ -90,6 +104,15 @@ export default {
90
104
  }
91
105
  return days;
92
106
  },
107
+ years() {
108
+ let year = new Date().getFullYear()
109
+ let min = year - 100, max = year + 100;
110
+ let y = []
111
+ for (let j = min; j <= max; j++) {
112
+ y.push(j)
113
+ }
114
+ return y
115
+ }
93
116
  },
94
117
  methods: {
95
118
  updateStamp() {
@@ -106,28 +129,19 @@ export default {
106
129
  this.year = d.getFullYear()
107
130
  this.month = d.getMonth()
108
131
  this.day = d.getDate()
109
- this.setYears(this.year);
110
132
  if (this.showTime && this.currentValue) {
111
133
  this.hour = d.getHours()
112
134
  this.minute = d.getMinutes()
113
135
  this.second = d.getSeconds()
114
136
  }
115
137
  },
116
- setYears(year) {
117
- const arr = [];
118
- let start = year - 1;
119
- while (arr.length < 12) {
120
- arr.push(start++);
121
- }
122
- this.years = arr
123
- },
138
+
124
139
  nextMonth() {
125
140
  if (this.month < 11) {
126
141
  this.month++;
127
142
  } else {
128
143
  this.month = 0;
129
144
  this.year++;
130
- this.setYears(this.year)
131
145
  }
132
146
  },
133
147
  prevMonth() {
@@ -136,7 +150,6 @@ export default {
136
150
  } else {
137
151
  this.month = 11;
138
152
  this.year--;
139
- this.setYears(this.year)
140
153
  }
141
154
  },
142
155
  classes(Y, M, D, out, format) {
@@ -188,12 +201,14 @@ export default {
188
201
  let disabled = this.disabledDate(time)
189
202
 
190
203
  let classes = {
191
- 'k-calendar-date': true,
204
+ 'k-calendar-date': format == 'YYYYMMDD',
192
205
  'k-calendar-date-today': istoday,
193
206
  'k-calendar-date-on': on && !out && !disabled,
194
- 'k-calendar-date-selected': isselected && !out,
195
- 'k-calendar-date-disabled': disabled,
196
- 'k-calendar-date-out': out
207
+ 'k-calendar-item-selected': isselected && !out,
208
+ 'k-calendar-item-disabled': disabled,
209
+ 'k-calendar-date-out': out,
210
+ 'k-calendar-year-item': format == 'YYYY',
211
+ 'k-calendar-month-item': format == 'YYYYMM',
197
212
  }
198
213
  return classes
199
214
  },
@@ -206,8 +221,11 @@ export default {
206
221
  this.currentValue = new Date(this.currentValue).setMonth(m)
207
222
  if (this.mode == 'month') {
208
223
  this.setDate()
209
- } else
210
- this.showMonths = 0
224
+ }
225
+
226
+ this.$nextTick(() => {
227
+ this.setYMScroll()
228
+ })
211
229
  },
212
230
  setYear(e, y) {
213
231
  e.stopPropagation();
@@ -216,18 +234,20 @@ export default {
216
234
  }
217
235
  this.year = y
218
236
  if (this.years.indexOf(y) == 0) {
219
- this.setYears(y - 10)
220
237
  return;
221
238
  }
222
239
  if (this.years.indexOf(y) == 11) {
223
- this.setYears(y)
224
240
  return;
225
241
  }
226
242
  this.currentValue = new Date(this.currentValue).setYear(y)
227
- this.showYears = 0
243
+ // this.showYears = 0
228
244
  if (this.mode == 'year') {
229
245
  this.$emit('input', this.currentValue)
246
+ this.$emit('change', this.currentValue)
230
247
  }
248
+ this.$nextTick(() => {
249
+ this.setYMScroll()
250
+ })
231
251
  },
232
252
  setDay(e, j) {
233
253
  e.stopPropagation();
@@ -255,6 +275,7 @@ export default {
255
275
  time = temp < date ? [temp, date] : [date, temp]
256
276
  // this.DatePicker.currentValue = time
257
277
  this.$emit('input', time)
278
+ this.$emit('change', time)
258
279
  }
259
280
  }
260
281
  if ((float == 'right' && n) || (float == 'left' && p)) {
@@ -299,22 +320,22 @@ export default {
299
320
  <li onClick={e => this.setTime(j, t, e)} class={this.timeClass(j, t, d)}>{this.fix(j)}</li>)
300
321
  },
301
322
  setShowTime() {
302
- this.showMonths = 0
303
323
  this.showYears = 0
304
- if (this.mode == 'range') {
305
- this.DatePicker.temp_range_showtime = !this.DatePicker.temp_range_showtime
306
- this.showTimes = this.DatePicker.temp_range_showtime
307
- } else {
308
- this.showTimes = !this.showTimes
309
- }
324
+ // if (this.mode == 'range') {
325
+ // this.DatePicker.temp_range_showtime = !this.DatePicker.temp_range_showtime
326
+ // this.showTimes = this.DatePicker.temp_range_showtime
327
+ // } else {
328
+ this.showTimes = !this.showTimes
329
+ // }
330
+ // if (this.showTimes) {
331
+ // this.$nextTick(() => {
332
+ // this.setTimeScroll()
333
+ // })
334
+ // }
310
335
  },
311
336
  setShowYear() {
312
337
  !this.showTimes && (this.showYears = !this.showYears)
313
338
  },
314
- setShowMonth(e) {
315
- e.stopPropagation()
316
- !this.showTimes && (this.showMonths = !this.showMonths)
317
- },
318
339
  setTime(v, t, e) {
319
340
  e.stopPropagation();
320
341
  if (e.target.className.indexOf('k-calendar-time-disabled') >= 0) {
@@ -343,11 +364,25 @@ export default {
343
364
  break;
344
365
  default: ;
345
366
  }
346
-
347
- this.setTimeScroll()
367
+ this.$nextTick(() => {
368
+ this.setTimeScroll()
369
+ })
370
+ },
371
+ setYMScroll() {
372
+ let year = new Date().getFullYear()
373
+ let y = this.years.indexOf(this.year || year)
374
+ let d = [y, this.month].map(x => x * 40)
375
+ let years = this.$refs.yearspicker
376
+ let month = this.$refs.monthspicker
377
+ animate({
378
+ draw: function (progress) {
379
+ years.scrollTop += progress * (d[0] - years.scrollTop)
380
+ month.scrollTop += progress * (d[1] - month.scrollTop)
381
+ }
382
+ })
348
383
  },
349
384
  setTimeScroll() {
350
- let d = [this.hour, this.minute, this.second].map(x => x * 24)
385
+ let d = [this.hour, this.minute, this.second].map(x => x * 32)
351
386
  let childs = this.$refs.timepicker.children;
352
387
  animate({
353
388
  draw: function (progress) {
@@ -357,75 +392,95 @@ export default {
357
392
  },
358
393
  setDate() {
359
394
  if (this.mode == 'range') {
360
- let values = this.DatePicker.currentValue;
395
+ let values = this.DatePicker.currentValue || [];
361
396
  let t1 = this.DatePicker.temp_range_left || values[0],
362
397
  t2 = this.DatePicker.temp_range_right || values[1];
363
398
  let date = t1 > t2 ? [t2, t1] : [t1, t2]
364
399
  this.$emit('input', date)
400
+ this.$emit('change', date)
365
401
  } else {
366
402
  let date = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second)
367
403
  this.showTimes = false
368
- this.showMonths = false
369
404
  this.showYears = false
370
405
  this.currentValue = date
371
406
  this.$emit('input', date)
407
+ this.$emit('change', date)
372
408
  }
373
409
  },
374
- setToday() {
375
- this.currentValue = new Date()
410
+ setToday(e) {
411
+ let d = new Date()
412
+ this.currentValue = d
376
413
  this.updateStamp()
377
- this.setDate()
414
+ if (this.mode != 'range') {
415
+ this.setDate()
416
+ } else {
417
+ let { float } = this
418
+ this.hour = d.getHours()
419
+ this.minute = d.getMinutes()
420
+ this.second = d.getSeconds()
421
+ let j = {
422
+ y: d.getFullYear(),
423
+ m: d.getMonth(),
424
+ d: d.getDate(),
425
+ p: float == 'left',
426
+ n: float == 'right'
427
+ }
428
+ this.setDay(e, j)
429
+ }
378
430
  },
379
431
  nextYear() {
380
- let y = this.year + (this.showMonths ? 1 : 10)
432
+ let y = this.year + 10
381
433
  this.year = y
382
- this.setYears(y)
383
434
  },
384
435
  prevYear() {
385
- let y = this.year - (this.showMonths ? 1 : 10)
436
+ let y = this.year - 10
386
437
  this.year = y
387
- this.setYears(y)
438
+ },
439
+ back() {
440
+ this.showYears = false
441
+ this.showTimes = false
388
442
  }
389
443
  },
390
444
  mounted() {
391
445
  this.updateStamp()
392
446
  },
393
447
  render() {
394
- let { classes, year, month, day, hour, minute, second, showYears, showMonths, disabledDate,
448
+ let { classes, year, month, day, hour, minute, second, showYears, disabledDate, pickerSize,
395
449
  showTimes, getTime, mode, DatePicker, float, currentValue } = this
450
+ let small = pickerSize == 'small', btnSize = small ? 'small' : null;
396
451
  let isRange = mode == 'range', values = DatePicker.currentValue || [];
397
452
  let temp_left, temp_right;
398
453
  if (isRange) {
399
- showTimes = DatePicker.temp_range_showtime
454
+ // showTimes = DatePicker.temp_range_showtime
400
455
  temp_left = DatePicker.temp_range_left || values[0]
401
456
  temp_right = DatePicker.temp_range_right || values[1]
402
457
  }
403
458
 
404
- showMonths = showMonths || mode == 'month'
405
- showYears = showYears || mode == 'year'
406
-
407
- let showArrow = true
459
+ showYears = showYears || mode == 'year' || mode == 'month'
460
+ let months = t('k.datePicker.months');
461
+ let weeks = t('k.datePicker.weeks');
408
462
  //header
409
463
  let headNode = []
410
- if (!showTimes)
411
- headNode.push(<span class="k-calendar-prev-year-btn" onClick={this.prevYear}>«</span>)
412
- if ((!showYears && !showMonths && !showTimes))
413
- headNode.push(<span class="k-calendar-prev-month-btn" onClick={this.prevMonth}>‹</span>)
414
- headNode.push(<span class="k-calendar-year-select" onClick={this.setShowYear}>{year}年</span>)
415
- if (!showYears && !showMonths) {
416
- headNode.push(<span class="k-calendar-month-select" onClick={this.setShowMonth}>{month + 1}月</span>)
464
+ if (!showTimes && !showYears) {
465
+ headNode.push(<Button icon="chevron-double-back-outline" size={btnSize} theme="normal" class="k-calendar-prev-year-btn" onClick={this.prevYear}></Button>)
466
+ headNode.push(<Button icon="chevron-back-outline" size={btnSize} theme="normal" class="k-calendar-prev-month-btn" onClick={this.prevMonth}></Button>)
467
+ } else if (mode != 'year' && mode != 'month') {
468
+ headNode.push(<Button class="k-calendar-back" size={btnSize} icon="chevron-back-outline" theme="normal" onClick={this.back}>{t('k.datePicker.back')} </Button>)
469
+ }
470
+ headNode.push(<Button class="k-calendar-year-select" size={btnSize} theme="normal" onClick={this.setShowYear}>{year}{t('k.datePicker.year')} {months[month]} {!showYears && showTimes ? day : ''}</Button>)
471
+ if (!showYears) {
417
472
  if (!showTimes)
418
- headNode.push(<span class="k-calendar-next-month-btn" onClick={this.nextMonth}>›</span>)
419
- else
420
- headNode.push(<span class="k-calendar-day-select">{day}日</span>)
473
+ headNode.push(<Button theme="normal" size={btnSize} icon="chevron-forward-outline" class="k-calendar-next-month-btn" onClick={this.nextMonth}></Button>)
474
+ // else
475
+ // headNode.push(<span class="k-calendar-day-select">{day}{t('k.datePicker.day')}</span>)
421
476
  }
422
- if (!showTimes)
423
- headNode.push(<span class="k-calendar-next-year-btn" onClick={this.nextYear}>»</span>)
477
+ if (!showTimes && !showYears)
478
+ headNode.push(<Button icon="chevron-double-forward-outline" size={btnSize} theme="normal" class="k-calendar-next-year-btn" onClick={this.nextYear}></Button>)
424
479
 
425
480
  //body
426
481
  const bodyNode = []
427
- if (mode == 'date' || isRange) {
428
- let weekNode = this.weeks.map(w => <span class="k-calendar-week" key={w}>{w}</span>)
482
+ if ((mode == 'date' || isRange) && !showYears && !showTimes) {
483
+ let weekNode = weeks.map(w => <span class="k-calendar-weekday" key={w}>{w}</span>)
429
484
  const getDay = (j, x) => {
430
485
  const props = {
431
486
  domProps: { innerHTML: j.d },
@@ -438,18 +493,28 @@ export default {
438
493
  }
439
494
  return <span {...props} />
440
495
  }
441
- let dayNode = this.days.map((j, x) => getDay(j, x))
442
- const daysNode = <div class="k-calendar-days">{weekNode}{dayNode}</div>
496
+ let wekday = [], temp = [];
497
+ this.days.forEach((j, x) => {
498
+ let d = getDay(j, x)
499
+ temp.push(d)
500
+ if ((x + 1) % 7 == 0) {
501
+ wekday.push(<div class="k-calendar-week">{temp}</div>)
502
+ temp = []
503
+ }
504
+ })
505
+ const daysNode = <div class="k-calendar-weeks">{wekday}</div>
506
+ const weeksNode = <div class="k-calendar-weekdays">{weekNode}</div>
507
+ bodyNode.push(weeksNode)
443
508
  bodyNode.push(daysNode)
444
509
  }
445
- if (showMonths) {
446
- const m = this.months.map((i, j) => <span key={i} class={classes(year, j, day, null, 'YYYYMM')} onClick={(e) => this.setMonth(e, j)}>{i}月</span >)
447
- const mouthNode = <div class="k-calendar-months">{m}</div>
448
- bodyNode.push(mouthNode)
449
- }
510
+ // console.log(showYears)
450
511
  if (showYears) {
451
- const y = this.years.map((i, j) => <span key={j} class={classes(i, month, day, (j == 0 || j == 11), 'YYYY')} onClick={(e) => this.setYear(e, i)}>{i}</span >)
452
- const yearNode = <div class="k-calendar-years">{y}</div>
512
+ const m = months.map((i, j) => <span key={i} class={classes(year, j, day, null, 'YYYYMM')} onClick={(e) => this.setMonth(e, j)}>{i}</span >)
513
+ const mouthNode = <div class="k-calendar-months" ref="monthspicker">{m}</div>
514
+ bodyNode.push(mouthNode)
515
+
516
+ const y = this.years.map((i, j) => <span key={j} class={classes(i, month, day, null, 'YYYY')} onClick={(e) => this.setYear(e, i)}>{i}</span >)
517
+ const yearNode = <div class="k-calendar-years" ref="yearspicker">{y}</div>
453
518
  bodyNode.push(yearNode)
454
519
  }
455
520
  //footer
@@ -473,22 +538,23 @@ export default {
473
538
  bodyNode.push(timeNode)
474
539
 
475
540
  }
476
- if ((this.showTime && !isRange) || (this.showTime && isRange && float == 'right')) {
541
+
542
+ if (this.showTime) {
477
543
  //footer
478
544
  // let disabled = moment()
479
545
  let disabled = disabledDate(new Date())
480
546
  let time_disabled = isRange ? !(temp_left && temp_right) : (!currentValue);
481
547
 
482
- !isRange && footerNode.push(<Button type="link" size='small' disabled={disabled} class="k-calendar-btn-today" onClick={this.setToday}>此刻</Button>)
483
- footerNode.push(<Button type="link" size="small" disabled={time_disabled} onClick={this.setShowTime}>{showTimes ? '选择日期' : '选择时间'}</Button>)
484
- footerNode.push(<Button type="primary" size='small' disabled={time_disabled} onClick={this.setDate}>确定</Button>)
548
+ footerNode.push(<Button theme="normal" size={btnSize} disabled={disabled} class="k-calendar-btn-today" onClick={this.setToday}>{t('k.datePicker.now')}</Button>)
549
+ footerNode.push(<Button theme="normal" size={btnSize} disabled={time_disabled} onClick={this.setShowTime}>{showTimes ? t('k.datePicker.selectDate') : t('k.datePicker.selectTime')}</Button>)
550
+ if (!isRange || float != 'left') footerNode.push(<Button type="primary" class="k-calendar-btn-ok" size={btnSize} disabled={time_disabled} onClick={this.setDate}>{t('k.datePicker.ok')}</Button>)
485
551
  } else if (mode == 'date') {
486
552
  let disabled = disabledDate(new Date())
487
- footerNode.push(<Button type="link" disabled={disabled} block size='small' onClick={this.setToday}>今天</Button>)
553
+ footerNode.push(<Button theme="normal" size={btnSize} disabled={disabled} block onClick={this.setToday}>{t('k.datePicker.today')}</Button>)
488
554
  }
489
555
  footerNode = footerNode.length || (isRange && this.showTime) ? <div class="k-calendar-footer">{footerNode}</div> : null
490
556
  return (
491
- <div class="k-calendar">
557
+ <div class={['k-calendar', { 'k-calendar-small': small }]}>
492
558
  <div class="k-calendar-head">{headNode}</div>
493
559
  <div class="k-calendar-body">{bodyNode}</div>
494
560
  {footerNode}
@@ -3,7 +3,7 @@ import Icon from "../icon";
3
3
  import { isNotEmpty } from '../_tool/utils'
4
4
  import moment from 'moment'
5
5
  import Drop from '../base/drop'
6
-
6
+ import { t } from '../locale'
7
7
  export default {
8
8
  name: 'DatePicker',
9
9
  props: {
@@ -17,12 +17,14 @@ export default {
17
17
  format: { type: String, default: 'YYYY-MM-DD' },
18
18
  clearable: { type: Boolean, default: true },
19
19
  bordered: { type: Boolean, default: true },
20
+ pickerSize: String,
20
21
  size: {
21
22
  default: 'default',
22
23
  validator(value) {
23
24
  return ["small", "large", "default"].indexOf(value) >= 0;
24
25
  }
25
26
  },
27
+ placement: String,
26
28
  theme: String,
27
29
  shape: String,
28
30
  placeholder: [String, Array],
@@ -127,9 +129,10 @@ export default {
127
129
  },
128
130
  },
129
131
  render() {
132
+ // console.log(t('k.datePicker'))
130
133
  let { currentValue, placeholder, disabled, clearable,
131
134
  opened, size, label, transfer, bordered, theme, shape, dateIcon,
132
- format, mode, disabledTime, disabledDate, showTime
135
+ format, mode, disabledTime, disabledDate, showTime, pickerSize
133
136
  } = this
134
137
  let childNode = [], isRange = mode == 'range';
135
138
 
@@ -140,7 +143,7 @@ export default {
140
143
  console.error('Please set placeholder as array !')
141
144
  placeholder = []
142
145
  }
143
- let p1 = placeholder[0] || '开始日期', p2 = placeholder[1] || '结束日期'
146
+ let p1 = placeholder[0] || t('k.datePicker.startDate'), p2 = placeholder[1] || t('k.datePicker.endDate')
144
147
  let v1 = label[0], v2 = label[1]
145
148
  if (v1) {
146
149
  childNode.push(<div class="k-datepicker-value">{v1}</div>)
@@ -154,7 +157,7 @@ export default {
154
157
  childNode.push(<div class="k-datepicker-placeholder">{p2}</div>)
155
158
  }
156
159
  } else {
157
- placeholder = placeholder || '请选择日期'
160
+ placeholder = placeholder || t('k.datePicker.placeholder')
158
161
  if (label) {
159
162
  childNode.push(<div class="k-datepicker-value">{label}</div>)
160
163
  } else if (placeholder) {
@@ -168,13 +171,13 @@ export default {
168
171
  currentValue = currentValue || []
169
172
  let v1 = currentValue[0] || '', v2 = currentValue[1] || '';
170
173
  let leftProps = {
171
- props: { format, mode, disabledTime, disabledDate, showTime, float: 'left', value: v1 },
174
+ props: { format, mode, disabledTime, disabledDate, showTime, float: 'left', value: v1, pickerSize },
172
175
  on: {
173
176
  input: e => this.updateValue(e)
174
177
  }
175
178
  }
176
179
  let rightProps = {
177
- props: { format, mode, disabledTime, disabledDate, showTime, float: 'right', value: v2 },
180
+ props: { format, mode, disabledTime, disabledDate, showTime, float: 'right', value: v2, pickerSize },
178
181
  on: {
179
182
  input: e => this.updateValue(e)
180
183
  }
@@ -183,7 +186,7 @@ export default {
183
186
  calendar.push(<Calendar {...leftProps} />, <Calendar {...rightProps} />)
184
187
  } else {
185
188
  const props = {
186
- props: { format, mode, disabledTime, disabledDate, showTime, value: currentValue },
189
+ props: { format, mode, disabledTime, disabledDate, showTime, value: currentValue, pickerSize },
187
190
  on: {
188
191
  input: e => {
189
192
  this.updateValue(e);
@@ -199,6 +202,7 @@ export default {
199
202
  transfer: transfer,
200
203
  selection: this.$el,
201
204
  value: this.opened,
205
+ placement: 'bottom-left',
202
206
  transitionName: 'k-date-picker'
203
207
  },
204
208
  on: {
@@ -7,10 +7,12 @@
7
7
  <template>
8
8
  <div>
9
9
  <DatePicker />
10
+ <DatePicker placeholder="小尺寸/Small" picker-size="small"/>
10
11
  <br/>
11
12
  <DatePicker mode="month" placeholder="请选择月份"/>
12
13
  <br/>
13
14
  <DatePicker mode="range" />
15
+ <DatePicker mode="range" picker-size="small" showTime/>
14
16
  </div>
15
17
  </template>
16
18
  ```
@@ -2,6 +2,7 @@
2
2
  import Info from './info'
3
3
  import Base from './base.md'
4
4
  import Theme from './theme.md'
5
+ import Inside from './inside.md'
5
6
  import Disabled from './disabled.md'
6
7
  import NoBorder from './noborder.md'
7
8
  import DisabledDate from './disabled-date.md'
@@ -16,6 +17,7 @@ export default {
16
17
  <Info class="typo" />
17
18
  <Base />
18
19
  <Theme />
20
+ <Inside />
19
21
  <Disabled />
20
22
  <NoBorder />
21
23
  <Format />
@@ -0,0 +1,76 @@
1
+ <cn>
2
+ #### 在内部展示
3
+ 嵌入其他组件内部
4
+ </cn>
5
+
6
+ ```vue
7
+ <template>
8
+ <div>
9
+ <Button @click="show=true">在Modal</Button>
10
+ <Button @click="show2=true">在 Drawer</Button>
11
+
12
+ <Modal v-model="show"
13
+ :title="null"
14
+ :footer="null"
15
+ :showClose="false"
16
+ :width="316"
17
+ >
18
+ <DateCalendar v-model="date" @change="change">
19
+ </Modal>
20
+
21
+ <div class="date-demo">
22
+ <div class="date-demo-inner" ref="demo-date">
23
+ <div class="demo-nav"><Icon type="chevron-back-outline" />商城首页</div>
24
+ <Drawer v-model="show2" height="340"
25
+ :closable="false"
26
+ :footer="null"
27
+ :title="null"
28
+ height="300"
29
+ placement="bottom"
30
+ :target="()=>$refs['demo-date']">
31
+ <DateCalendar v-model="date2" @change="change2" picker-size="small">
32
+ </Drawer>
33
+ <div>
34
+ <div>
35
+ </div>
36
+ </template>
37
+ <script>
38
+ export default{
39
+ data(){
40
+ return {
41
+ show:false,
42
+ show2:false,
43
+ date:'',
44
+ date2:''
45
+ }
46
+ },
47
+ methods: {
48
+ change(date){
49
+ this.show = false
50
+ console.log(date.toString())
51
+ this.$Message.info(date.toString())
52
+ },
53
+ change2(date){
54
+ this.show2 = false
55
+ console.log(date.toString())
56
+ this.$Message.info(date.toString())
57
+ }
58
+ },
59
+ }
60
+ </script>
61
+ <style lang="less">
62
+ .date-demo{
63
+ width:256px;
64
+ height:400px;
65
+ border:1px solid var(--kui-color-border);
66
+ margin-top:10px;
67
+ position:relative;
68
+ overflow:hidden;
69
+ }
70
+ .demo-nav{
71
+ border-bottom:1px solid var(--kui-color-border);
72
+ padding:8px 10px;
73
+ font-size:12px;
74
+ }
75
+ </style>
76
+ ```
@@ -12,11 +12,11 @@
12
12
  <RadioButton value="small" label="Small"/>
13
13
  </RadioGroup>
14
14
  <br/>
15
- <DatePicker :size="size"/>
15
+ <DatePicker :size="size" :picker-size="size"/>
16
16
  <br/>
17
- <DatePicker mode="month" placeholder="请选择月份" :size="size" />
17
+ <DatePicker mode="month" placeholder="请选择月份" :size="size" :picker-size="size"/>
18
18
  <br/>
19
- <DatePicker :size="size" mode="range"/>
19
+ <DatePicker :size="size" mode="range" :picker-size="size"/>
20
20
  </div>
21
21
  </template>
22
22
  <script>
@@ -1,2 +1,3 @@
1
+ import DateCalendar from './datecalendar.jsx'
1
2
  import DatePicker from './datepicker.jsx'
2
- export default DatePicker
3
+ export { DatePicker, DateCalendar }
@@ -5,6 +5,7 @@
5
5
  | mode | 使用 `mode` 属性,可以自定义日期显示类型,提供 `year` `month` `date` `range`。 | String | date |
6
6
  | disabled | 是否禁用组件 | Boolen | false |
7
7
  | size | 按钮尺寸,可选值 `small`、`large`,默认不选 | String | - |
8
+ | pickerSize | 值Ï为`small`时日期呈现小尺寸 | String | - |
8
9
  | clearable | 是否显示清除图标 | Boolean | true |
9
10
  | placeholder | 提示语 | String, Array | - |
10
11
  | transfer | 默认渲染到body 上,如定位有问题,请尝试修改为 false | Boolean | true |