From 8bec6708d65995686a82632cbe65c75305c1a574 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 23 Jan 2019 22:47:44 +0800 Subject: [PATCH 001/132] feat: update vc-calendar --- .../__snapshots__/other.test.js.snap | 2 +- .../__snapshots__/index.test.js.snap | 178 +++++++++--------- .../vc-calendar/assets/index/DecadePanel.less | 25 +-- .../vc-calendar/assets/index/MonthPanel.less | 30 ++- .../vc-calendar/assets/index/YearPanel.less | 29 +-- components/vc-calendar/demo/antd-calendar.vue | 3 +- components/vc-calendar/index.js | 5 + components/vc-calendar/src/Calendar.jsx | 78 +++++--- components/vc-calendar/src/FullCalendar.jsx | 23 ++- components/vc-calendar/src/MonthCalendar.jsx | 12 +- components/vc-calendar/src/Picker.jsx | 3 +- components/vc-calendar/src/RangeCalendar.jsx | 7 +- .../src/calendar/CalendarFooter.jsx | 5 +- .../src/calendar/CalendarHeader.jsx | 5 + components/vc-calendar/src/date/DateInput.jsx | 76 +++++--- .../vc-calendar/src/decade/DecadePanel.jsx | 8 +- components/vc-calendar/src/locale/hi_IN.js | 28 +++ components/vc-calendar/src/locale/kn_IN.js | 28 +++ .../vc-calendar/src/mixin/CalendarMixin.js | 10 +- .../vc-calendar/src/mixin/CommonMixin.js | 8 +- .../vc-calendar/src/month/MonthPanel.jsx | 8 + components/vc-calendar/src/year/YearPanel.jsx | 9 +- 22 files changed, 382 insertions(+), 198 deletions(-) create mode 100644 components/vc-calendar/src/locale/hi_IN.js create mode 100644 components/vc-calendar/src/locale/kn_IN.js diff --git a/components/date-picker/__tests__/__snapshots__/other.test.js.snap b/components/date-picker/__tests__/__snapshots__/other.test.js.snap index 17be1ba9f..0865167ef 100644 --- a/components/date-picker/__tests__/__snapshots__/other.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/other.test.js.snap @@ -53,7 +53,7 @@ exports[`MonthPicker and WeekPicker render WeekPicker 1`] = `
-
+
diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap index 5116d8b94..ac917a9db 100644 --- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap +++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap @@ -10,7 +10,7 @@ exports[`Locale Provider set moment locale when locale changes 1`] = `
-
+
@@ -188,7 +188,7 @@ exports[`Locale Provider set moment locale when locale changes 2`] = `
-
+
@@ -366,7 +366,7 @@ exports[`Locale Provider set moment locale when locale changes 3`] = `
-
+
@@ -12177,7 +12177,7 @@ exports[`Locale Provider should display the text as pt 1`] = `
-
set
+
Set
@@ -12199,43 +12199,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
28
- +
29
- +
30
- +
31
- +
01
- +
02
- +
03
@@ -12243,43 +12243,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
04
- +
05
- +
06
- +
07
- +
08
- +
09
- +
10
@@ -12287,43 +12287,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
11
- +
12
- +
13
- +
14
- +
15
- +
16
- +
17
@@ -12331,43 +12331,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
18
- +
19
- +
20
- +
21
- +
22
- +
23
- +
24
@@ -12375,43 +12375,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
25
- +
26
- +
27
- +
28
- +
29
- +
30
- +
01
@@ -12419,43 +12419,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
02
- +
03
- +
04
- +
05
- +
06
- +
07
- +
08
@@ -12576,7 +12576,7 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
-
set
+
Set
@@ -12598,43 +12598,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
27
- +
28
- +
29
- +
30
- +
31
- +
01
- +
02
@@ -12642,43 +12642,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
03
- +
04
- +
05
- +
06
- +
07
- +
08
- +
09
@@ -12686,43 +12686,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
10
- +
11
- +
12
- +
13
- +
14
- +
15
- +
16
@@ -12730,43 +12730,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
17
- +
18
- +
19
- +
20
- +
21
- +
22
- +
23
@@ -12774,43 +12774,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
24
- +
25
- +
26
- +
27
- +
28
- +
29
- +
30
@@ -12818,43 +12818,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
01
- +
02
- +
03
- +
04
- +
05
- +
06
- +
07
diff --git a/components/vc-calendar/assets/index/DecadePanel.less b/components/vc-calendar/assets/index/DecadePanel.less index b55d12f23..f83c591d0 100644 --- a/components/vc-calendar/assets/index/DecadePanel.less +++ b/components/vc-calendar/assets/index/DecadePanel.less @@ -7,6 +7,8 @@ z-index: 10; position: absolute; outline: none; + display: flex; + flex-direction: column; } .@{prefixClass}-decade-panel-hidden { @@ -37,15 +39,14 @@ } } -.@{prefixClass}-decade-panel-prev-century-btn, -.@{prefixClass}-decade-panel-next-century-btn { +.@{prefixClass}-decade-panel-prev-century-btn, .@{prefixClass}-decade-panel-next-century-btn { position: absolute; top: 0; } .@{prefixClass}-decade-panel-next-century-btn { &:after { - content: '»'; + content: '»' } } @@ -53,7 +54,7 @@ user-select: none; left: 0; &:after { - content: '«'; + content: '«' } } @@ -63,10 +64,13 @@ } .@{prefixClass}-decade-panel-body { + flex: 1; padding: 9px 10px 10px; - position: absolute; - bottom: 0; - top: 34px; +} + +.@{prefixClass}-decade-panel-footer { + border-top: 1px solid #ccc; + line-height: 38px; } .@{prefixClass}-decade-panel-table { @@ -107,11 +111,10 @@ } } -.@{prefixClass}-decade-panel-last-century-cell, -.@{prefixClass}-decade-panel-next-century-cell { - .@{prefixClass}-decade-panel-decade { +.@{prefixClass}-decade-panel-last-century-cell, .@{prefixClass}-decade-panel-next-century-cell { + .@{prefixClass}-decade-panel-decade{ user-select: none; -webkit-user-select: none; color: rgba(0, 0, 0, 0.25); } -} +} \ No newline at end of file diff --git a/components/vc-calendar/assets/index/MonthPanel.less b/components/vc-calendar/assets/index/MonthPanel.less index f5310ab92..1b35f0e6b 100644 --- a/components/vc-calendar/assets/index/MonthPanel.less +++ b/components/vc-calendar/assets/index/MonthPanel.less @@ -1,12 +1,18 @@ .@{prefixClass}-month-panel { left: 0; - top: 0; + top:0; bottom: 0; right: 0; background: #ffffff; z-index: 10; position: absolute; outline: none; + + > div { + height: 100%; + display: flex; + flex-direction: column; + } } .@{prefixClass}-month-panel-hidden { @@ -37,15 +43,14 @@ } } -.@{prefixClass}-month-panel-prev-year-btn, -.@{prefixClass}-month-panel-next-year-btn { +.@{prefixClass}-month-panel-prev-year-btn, .@{prefixClass}-month-panel-next-year-btn { position: absolute; top: 0; } .@{prefixClass}-month-panel-next-year-btn { &:after { - content: '»'; + content: '»' } } @@ -54,7 +59,7 @@ left: 0; &:after { - content: '«'; + content: '«' } } @@ -72,10 +77,13 @@ } .@{prefixClass}-month-panel-body { + flex: 1; padding: 9px 10px 10px; - position: absolute; - top: 34px; - bottom: 0; +} + +.@{prefixClass}-month-panel-footer { + border-top: 1px solid #ccc; + line-height: 38px; } .@{prefixClass}-month-panel-table { @@ -88,6 +96,8 @@ .@{prefixClass}-month-panel-cell { text-align: center; + + .@{prefixClass}-month-panel-month { display: block; width: 46px; @@ -106,7 +116,7 @@ } } - &-disabled { + &-disabled{ .@{prefixClass}-month-panel-month { color: #bfbfbf; @@ -131,4 +141,4 @@ .@{prefixClass}-month-header-wrap { position: relative; height: 308px; -} +} \ No newline at end of file diff --git a/components/vc-calendar/assets/index/YearPanel.less b/components/vc-calendar/assets/index/YearPanel.less index 32b45fd0f..6b31dc8ec 100644 --- a/components/vc-calendar/assets/index/YearPanel.less +++ b/components/vc-calendar/assets/index/YearPanel.less @@ -7,6 +7,12 @@ z-index: 10; position: absolute; outline: none; + + > div { + height: 100%; + display: flex; + flex-direction: column; + } } .@{prefixClass}-year-panel-hidden { @@ -37,15 +43,14 @@ } } -.@{prefixClass}-year-panel-prev-decade-btn, -.@{prefixClass}-year-panel-next-decade-btn { +.@{prefixClass}-year-panel-prev-decade-btn, .@{prefixClass}-year-panel-next-decade-btn { position: absolute; top: 0; } .@{prefixClass}-year-panel-next-decade-btn { &:after { - content: '»'; + content: '»' } } @@ -54,7 +59,7 @@ left: 0; &:after { - content: '«'; + content: '«' } } @@ -72,10 +77,13 @@ } .@{prefixClass}-year-panel-body { + flex: 1; padding: 9px 10px 10px; - position: absolute; - bottom: 0; - top: 34px; +} + +.@{prefixClass}-year-panel-footer { + border-top: 1px solid #ccc; + line-height: 38px; } .@{prefixClass}-year-panel-table { @@ -117,11 +125,10 @@ } } -.@{prefixClass}-year-panel-last-decade-cell, -.@{prefixClass}-year-panel-next-decade-cell { - .@{prefixClass}-year-panel-year { +.@{prefixClass}-year-panel-last-decade-cell, .@{prefixClass}-year-panel-next-decade-cell { + .@{prefixClass}-year-panel-year{ user-select: none; -webkit-user-select: none; color: rgba(0, 0, 0, 0.25); } -} +} \ No newline at end of file diff --git a/components/vc-calendar/demo/antd-calendar.vue b/components/vc-calendar/demo/antd-calendar.vue index 45138dda4..6cfa7ac4d 100644 --- a/components/vc-calendar/demo/antd-calendar.vue +++ b/components/vc-calendar/demo/antd-calendar.vue @@ -211,6 +211,7 @@ const DemoMultiFormat = { format={multiFormats} value={state.value} onChange={this.onChange} + focusablePanel={false} />
); }, @@ -251,7 +252,7 @@ export default { onChange={onStandaloneChange} disabledDate={disabledDate} onSelect={onStandaloneSelect} - renderFooter={() => 'extra footer'} + renderFooter={(mode) => ({mode} extra footer)} />
diff --git a/components/vc-calendar/index.js b/components/vc-calendar/index.js index 17cd8cdf3..3091680aa 100644 --- a/components/vc-calendar/index.js +++ b/components/vc-calendar/index.js @@ -1,3 +1,8 @@ // based on rc-calendar 9.8.2 +import Vue from 'vue'; +import ref from 'vue-ref'; import Calendar from './src/'; + +Vue.use(ref, { name: 'ant-ref' }); + export default Calendar; diff --git a/components/vc-calendar/src/Calendar.jsx b/components/vc-calendar/src/Calendar.jsx index 8d47ef69f..909d21ad5 100644 --- a/components/vc-calendar/src/Calendar.jsx +++ b/components/vc-calendar/src/Calendar.jsx @@ -3,27 +3,17 @@ import BaseMixin from '../../_util/BaseMixin'; import { getOptionProps, hasProp, getComponentFromProp } from '../../_util/props-util'; import { cloneElement } from '../../_util/vnode'; import KeyCode from '../../_util/KeyCode'; -import * as moment from 'moment'; +import moment from 'moment'; import DateTable from './date/DateTable'; import CalendarHeader from './calendar/CalendarHeader'; import CalendarFooter from './calendar/CalendarFooter'; -import CalendarMixin from './mixin/CalendarMixin'; +import CalendarMixin, {getNowByCurrentStateValue} from './mixin/CalendarMixin'; import CommonMixin from './mixin/CommonMixin'; import DateInput from './date/DateInput'; import enUs from './locale/en_US'; import { getTimeConfig, getTodayTime, syncTime } from './util'; import { goStartMonth, goEndMonth, goTime } from './util/toTime'; -function isMoment(value) { - if (Array.isArray(value)) { - return ( - value.length === 0 || value.findIndex(val => val === undefined || moment.isMoment(val)) !== -1 - ); - } else { - return value === undefined || moment.isMoment(value); - } -} -const MomentType = PropTypes.custom(isMoment); const Calendar = { props: { locale: PropTypes.object.def(enUs), @@ -31,9 +21,10 @@ const Calendar = { visible: PropTypes.bool.def(true), prefixCls: PropTypes.string.def('rc-calendar'), // prefixCls: PropTypes.string, - defaultValue: MomentType, - value: MomentType, - selectedValue: MomentType, + defaultValue: PropTypes.object, + value: PropTypes.object, + selectedValue: PropTypes.object, + defaultSelectedValue: PropTypes.object, mode: PropTypes.oneOf(['time', 'date', 'month', 'year', 'decade']), // locale: PropTypes.object, showDateInput: PropTypes.bool.def(true), @@ -54,21 +45,48 @@ const Calendar = { renderFooter: PropTypes.func.def(() => null), renderSidebar: PropTypes.func.def(() => null), clearIcon: PropTypes.any, + focusablePanel: PropTypes.bool.def(true), }, mixins: [BaseMixin, CommonMixin, CalendarMixin], data() { + const props = this.$props; return { sMode: this.mode || 'date', + sValue: props.value || props.defaultValue || moment(), + sSelectedValue: props.selectedValue || props.defaultSelectedValue, }; }, watch: { mode(val) { this.setState({ sMode: val }); }, + value(val) { + const sValue = val || this.defaultValue || getNowByCurrentStateValue(this.sValue); + this.setState({ + sValue, + }); + }, + selectedValue(val) { + this.setState({ + sSelectedValue: val, + }); + }, + }, + mounted(){ + this.$nextTick(()=>{ + this.saveFocusElement(DateInput.getInstance()); + }); }, methods: { + onPanelChange(value, mode) { + const { sValue } = this; + if (!hasProp(this, 'mode')) { + this.setState({ sMode: mode }); + } + this.__emit('panelChange', value || sValue, mode); + }, onKeyDown(event) { if (event.target.nodeName.toLowerCase() === 'input') { return undefined; @@ -149,6 +167,11 @@ const Calendar = { source: 'dateInput', }); }, + onDateInputSelect (value) { + this.onSelect(value, { + source: 'dateInputSelect', + }); + }, onDateTableSelect(value) { const { timePicker, sSelectedValue } = this; if (!sSelectedValue && timePicker) { @@ -167,13 +190,6 @@ const Calendar = { source: 'todayButton', }); }, - onPanelChange(value, mode) { - const { sValue } = this; - if (!hasProp(this, 'mode')) { - this.setState({ sMode: mode }); - } - this.__emit('panelChange', value || sValue, mode); - }, getRootDOMNode() { return this.$el; }, @@ -197,10 +213,10 @@ const Calendar = { timePicker, disabledTime, showDateInput, - renderSidebar, sValue, sSelectedValue, sMode, + renderFooter, $props: props, } = this; const clearIcon = getComponentFromProp(this, 'clearIcon'); @@ -250,19 +266,23 @@ const Calendar = { selectedValue={sSelectedValue} onChange={this.onDateInputChange} clearIcon={clearIcon} + onSelect={this.onDateInputSelect} /> ) : null; - const children = [ - renderSidebar(), -
+ const children =[]; + if (props.renderSidebar) { + children.push(props.renderSidebar()); + } + children.push(
{dateInputElement} -
+
@@ -286,6 +306,7 @@ const Calendar = {
-
, - ]; +
); return this.renderRoot({ children, diff --git a/components/vc-calendar/src/FullCalendar.jsx b/components/vc-calendar/src/FullCalendar.jsx index 2a0a7a387..b7c0a4b5c 100644 --- a/components/vc-calendar/src/FullCalendar.jsx +++ b/components/vc-calendar/src/FullCalendar.jsx @@ -1,9 +1,10 @@ +import moment from 'moment'; import PropTypes from '../../_util/vue-types'; import BaseMixin from '../../_util/BaseMixin'; import { getOptionProps, hasProp } from '../../_util/props-util'; import DateTable from './date/DateTable'; import MonthTable from './month/MonthTable'; -import CalendarMixin from './mixin/CalendarMixin'; +import CalendarMixin, {getNowByCurrentStateValue} from './mixin/CalendarMixin'; import CommonMixin from './mixin/CommonMixin'; import CalendarHeader from './full-calendar/CalendarHeader'; import enUs from './locale/en_US'; @@ -15,8 +16,6 @@ const FullCalendar = { prefixCls: PropTypes.string.def('rc-calendar'), defaultType: PropTypes.string.def('date'), type: PropTypes.string, - // locale: PropTypes.object, - // onTypeChange: PropTypes.func, fullscreen: PropTypes.bool.def(false), monthCellRender: PropTypes.func, dateCellRender: PropTypes.func, @@ -27,6 +26,10 @@ const FullCalendar = { headerRender: PropTypes.func, showHeader: PropTypes.bool.def(true), disabledDate: PropTypes.func, + value: PropTypes.object, + defaultValue: PropTypes.object, + selectedValue: PropTypes.object, + defaultSelectedValue: PropTypes.object, renderFooter: PropTypes.func.def(() => null), renderSidebar: PropTypes.func.def(() => null), }, @@ -38,8 +41,11 @@ const FullCalendar = { } else { type = this.defaultType; } + const props = this.$props; return { sType: type, + sValue: props.value || props.defaultValue || moment(), + sSelectedValue: props.selectedValue || props.defaultSelectedValue, }; }, watch: { @@ -48,6 +54,17 @@ const FullCalendar = { sType: val, }); }, + value(val) { + const sValue = val || this.defaultValue || getNowByCurrentStateValue(this.sValue); + this.setState({ + sValue, + }); + }, + selectedValue(val) { + this.setState({ + sSelectedValue: val, + }); + }, }, methods: { onMonthSelect(value) { diff --git a/components/vc-calendar/src/MonthCalendar.jsx b/components/vc-calendar/src/MonthCalendar.jsx index 87aa6ef91..2570f8d4a 100644 --- a/components/vc-calendar/src/MonthCalendar.jsx +++ b/components/vc-calendar/src/MonthCalendar.jsx @@ -1,3 +1,4 @@ +import moment from 'moment'; import PropTypes from '../../_util/vue-types'; import BaseMixin from '../../_util/BaseMixin'; import KeyCode from '../../_util/KeyCode'; @@ -14,6 +15,10 @@ const MonthCalendar = { prefixCls: PropTypes.string.def('rc-calendar'), monthCellRender: PropTypes.func, dateCellRender: PropTypes.func, + value: PropTypes.object, + defaultValue: PropTypes.object, + selectedValue: PropTypes.object, + defaultSelectedValue: PropTypes.object, disabledDate: PropTypes.func, monthCellContentRender: PropTypes.func, renderFooter: PropTypes.func.def(() => null), @@ -22,7 +27,12 @@ const MonthCalendar = { mixins: [BaseMixin, CommonMixin, CalendarMixin], data() { - return { mode: 'month' }; + const props = this.$props; + return { + mode: 'month', + sValue: props.value || props.defaultValue || moment(), + sSelectedValue: props.selectedValue || props.defaultSelectedValue, + }; }, methods: { onKeyDown(event) { diff --git a/components/vc-calendar/src/Picker.jsx b/components/vc-calendar/src/Picker.jsx index 0a8800c52..14246a9c3 100644 --- a/components/vc-calendar/src/Picker.jsx +++ b/components/vc-calendar/src/Picker.jsx @@ -98,6 +98,7 @@ const Picker = { const calendarProps = getOptionProps(props.calendar); if ( cause.source === 'keyboard' || + cause.source === 'dateInputSelect' || (!calendarProps.timePicker && cause.source !== 'dateInput') || cause.source === 'todayButton' ) { @@ -107,7 +108,7 @@ const Picker = { }, onKeyDown(event) { - if (event.keyCode === KeyCode.DOWN && !this.sOpen) { + if (!this.sOpen && (event.keyCode === KeyCode.DOWN || event.keyCode === KeyCode.ENTER)) { this.openCalendar(); event.preventDefault(); } diff --git a/components/vc-calendar/src/RangeCalendar.jsx b/components/vc-calendar/src/RangeCalendar.jsx index 4f7793bef..4bbb4dff4 100644 --- a/components/vc-calendar/src/RangeCalendar.jsx +++ b/components/vc-calendar/src/RangeCalendar.jsx @@ -79,6 +79,7 @@ const RangeCalendar = { visible: PropTypes.bool.def(true), prefixCls: PropTypes.string.def('rc-calendar'), dateInputPlaceholder: PropTypes.any, + seperator: PropTypes.string.def('~'), defaultValue: PropTypes.any, value: PropTypes.any, hoverValue: PropTypes.any, @@ -599,6 +600,8 @@ const RangeCalendar = { showClear, showToday, type, + seperator, + mode, } = props; const clearIcon = getComponentFromProp(this, 'clearIcon'); const { sHoverValue, sSelectedValue, sMode, showTimePicker, sValue, $listeners } = this; @@ -748,7 +751,7 @@ const RangeCalendar = { }); OkButtonNode = ; } - const extraFooter = this.renderFooter(); + const extraFooter = this.renderFooter(sMode); return (
{props.renderSidebar()} @@ -764,7 +767,7 @@ const RangeCalendar = { onMouseenter={type !== 'both' ? this.onDatePanelEnter : noop} > - ~ + {seperator}
diff --git a/components/vc-calendar/src/calendar/CalendarFooter.jsx b/components/vc-calendar/src/calendar/CalendarFooter.jsx index 883a3bd01..ee084aa8c 100644 --- a/components/vc-calendar/src/calendar/CalendarFooter.jsx +++ b/components/vc-calendar/src/calendar/CalendarFooter.jsx @@ -23,6 +23,7 @@ const CalendarFooter = { disabledDate: PropTypes.func, showTimePicker: PropTypes.bool, okDisabled: PropTypes.bool, + mode: PropTypes.string, }, methods: { onSelect(value) { @@ -37,9 +38,9 @@ const CalendarFooter = { render() { const props = getOptionProps(this); const { $listeners } = this; - const { value, prefixCls, showOk, timePicker, renderFooter, showToday } = props; + const { value, prefixCls, showOk, timePicker, renderFooter, showToday, mode } = props; let footerEl = null; - const extraFooter = renderFooter(); + const extraFooter = renderFooter && renderFooter(mode); if (showToday || timePicker || extraFooter) { const btnProps = { props: { diff --git a/components/vc-calendar/src/calendar/CalendarHeader.jsx b/components/vc-calendar/src/calendar/CalendarHeader.jsx index c0e41349f..d7e5bf94d 100644 --- a/components/vc-calendar/src/calendar/CalendarHeader.jsx +++ b/components/vc-calendar/src/calendar/CalendarHeader.jsx @@ -36,6 +36,7 @@ const CalendarHeader = { mode: PropTypes.any, monthCellRender: PropTypes.func, monthCellContentRender: PropTypes.func, + renderFooter: PropTypes.func, }, data() { this.nextMonth = goMonth.bind(this, 1); @@ -140,6 +141,7 @@ const CalendarHeader = { enableNext, enablePrev, disabledMonth, + renderFooter, } = props; let panel = null; @@ -154,6 +156,7 @@ const CalendarHeader = { disabledDate={disabledMonth} cellRender={props.monthCellRender} contentRender={props.monthCellContentRender} + renderFooter={renderFooter} /> ); } @@ -165,6 +168,7 @@ const CalendarHeader = { rootPrefixCls={prefixCls} onSelect={this.onYearSelect} onDecadePanelShow={this.showDecadePanel} + renderFooter={renderFooter} /> ); } @@ -175,6 +179,7 @@ const CalendarHeader = { defaultValue={value} rootPrefixCls={prefixCls} onSelect={this.onDecadeSelect} + renderFooter={renderFooter} /> ); } diff --git a/components/vc-calendar/src/date/DateInput.jsx b/components/vc-calendar/src/date/DateInput.jsx index 0c353face..a459467cb 100644 --- a/components/vc-calendar/src/date/DateInput.jsx +++ b/components/vc-calendar/src/date/DateInput.jsx @@ -3,6 +3,11 @@ import BaseMixin from '../../../_util/BaseMixin'; import { getComponentFromProp } from '../../../_util/props-util'; import moment from 'moment'; import { formatDate } from '../util'; +import KeyCode from '../../../_util/KeyCode'; + +let cachedSelectionStart; +let cachedSelectionEnd; +let dateInputInstance; const DateInput = { mixins: [BaseMixin], @@ -42,21 +47,27 @@ const DateInput = { updated() { this.$nextTick(() => { if ( + dateInputInstance && this.$data.hasFocus && !this.invalid && - !(this.cachedSelectionStart === 0 && this.cachedSelectionEnd === 0) + !(cachedSelectionStart === 0 && cachedSelectionEnd === 0) ) { - this.$refs.dateInputInstance.setSelectionRange( - this.cachedSelectionStart, - this.cachedSelectionEnd, + dateInputInstance.setSelectionRange( + cachedSelectionStart, + cachedSelectionEnd, ); } }); }, + getInstance() { + return dateInputInstance; + }, methods: { updateState() { - this.cachedSelectionStart = this.$refs.dateInputInstance.selectionStart; - this.cachedSelectionEnd = this.$refs.dateInputInstance.selectionEnd; + if (dateInputInstance) { + cachedSelectionStart = dateInputInstance.selectionStart; + cachedSelectionEnd = dateInputInstance.selectionEnd; + } // when popup show, click body will call this, bug! const selectedValue = this.selectedValue; if (!this.$data.hasFocus) { @@ -66,6 +77,12 @@ const DateInput = { }); } }, + onClear() { + this.setState({ + str: '', + }); + this.__emit('clear', null); + }, onInputChange(event) { const str = event.target.value; const { disabledDate, format, selectedValue } = this.$props; @@ -79,7 +96,8 @@ const DateInput = { }); return; } - + + // 不合法直接退出 const parsed = moment(str, format, true); if (!parsed.isValid()) { this.setState({ @@ -107,38 +125,38 @@ const DateInput = { if (selectedValue !== value || (selectedValue && value && !selectedValue.isSame(value))) { this.setState({ + invalid: false, str, }); this.__emit('change', value); } }, - - onClear() { - this.setState({ - str: '', - }); - this.__emit('clear', null); - }, - - getRootDOMNode() { - return this.$el; - }, - - focus() { - if (this.$refs.dateInputInstance) { - this.$refs.dateInputInstance.focus(); - } - }, onFocus() { this.setState({ hasFocus: true }); }, - onBlur() { this.setState((prevState, prevProps) => ({ hasFocus: false, str: formatDate(prevProps.value, prevProps.format), })); }, + onKeyDown ({ keyCode }) { + const { value } = this.$props; + if (keyCode === KeyCode.ENTER ) { + this.__emit('select', value.clone()); + } + }, + getRootDOMNode() { + return this.$el; + }, + focus() { + if (dateInputInstance) { + dateInputInstance.focus(); + } + }, + saveDateInput(dateInput) { + dateInputInstance = dateInput; + }, }, render() { @@ -149,12 +167,18 @@ const DateInput = {
diff --git a/components/vc-calendar/src/decade/DecadePanel.jsx b/components/vc-calendar/src/decade/DecadePanel.jsx index 42084df67..89c02d442 100644 --- a/components/vc-calendar/src/decade/DecadePanel.jsx +++ b/components/vc-calendar/src/decade/DecadePanel.jsx @@ -26,6 +26,7 @@ export default { value: PropTypes.object, defaultValue: PropTypes.object, rootPrefixCls: PropTypes.string, + renderFooter: PropTypes.func, }, data() { this.nextCentury = goYear.bind(this, 100); @@ -37,7 +38,7 @@ export default { render() { const value = this.sValue; - const locale = this.locale; + const { locale, renderFooter } = this.$props; const currentYear = value.year(); const startYear = parseInt(currentYear / 100, 10) * 100; const preYear = startYear - 10; @@ -59,6 +60,7 @@ export default { } } + const footer = renderFooter && renderFooter('decade'); const decadesEls = decades.map((row, decadeIndex) => { const tds = row.map(decadeData => { const dStartDecade = decadeData.startDecade; @@ -118,6 +120,10 @@ export default { {decadesEls}
+ {footer && ( +
+ {footer} +
)}
); }, diff --git a/components/vc-calendar/src/locale/hi_IN.js b/components/vc-calendar/src/locale/hi_IN.js new file mode 100644 index 000000000..a0b6b4e63 --- /dev/null +++ b/components/vc-calendar/src/locale/hi_IN.js @@ -0,0 +1,28 @@ +export default { + today: 'आज', + now: 'अभी', + backToToday: 'आज तक', + ok: 'ठीक', + clear: 'स्पष्ट', + month: 'महीना', + year: 'साल', + timeSelect: 'समय का चयन करें', + dateSelect: 'तारीख़ चुनें', + weekSelect: 'एक सप्ताह चुनें', + monthSelect: 'एक महीना चुनें', + yearSelect: 'एक वर्ष चुनें', + decadeSelect: 'एक दशक चुनें', + yearFormat: 'YYYY', + dateFormat: 'M/D/YYYY', + dayFormat: 'D', + dateTimeFormat: 'M/D/YYYY HH:mm:ss', + monthBeforeYear: true, + previousMonth: 'पिछला महीना (पेजअप)', + nextMonth: 'अगले महीने (पेजडाउन)', + previousYear: 'पिछले साल (Ctrl + बाएं)', + nextYear: 'अगले साल (Ctrl + दाहिना)', + previousDecade: 'पिछला दशक', + nextDecade: 'अगले दशक', + previousCentury: 'पीछ्ली शताब्दी', + nextCentury: 'अगली सदी', +}; diff --git a/components/vc-calendar/src/locale/kn_IN.js b/components/vc-calendar/src/locale/kn_IN.js new file mode 100644 index 000000000..5acf5d698 --- /dev/null +++ b/components/vc-calendar/src/locale/kn_IN.js @@ -0,0 +1,28 @@ +export default { + today: 'ಇಂದು', + now: 'ಈಗ', + backToToday: 'ಇಂದು ಹಿಂದಿರುಗಿ', + ok: 'ಸರಿ', + clear: 'ಸ್ಪಷ್ಟ', + month: 'ತಿಂಗಳು', + year: 'ವರ್ಷ', + timeSelect: 'ಸಮಯ ಆಯ್ಕೆಮಾಡಿ', + dateSelect: 'ದಿನಾಂಕವನ್ನು ಆಯ್ಕೆ ಮಾಡಿ', + weekSelect: 'ಒಂದು ವಾರದ ಆರಿಸಿ', + monthSelect: 'ಒಂದು ತಿಂಗಳು ಆಯ್ಕೆಮಾಡಿ', + yearSelect: 'ಒಂದು ವರ್ಷ ಆರಿಸಿ', + decadeSelect: 'ಒಂದು ದಶಕದ ಆಯ್ಕೆಮಾಡಿ', + yearFormat: 'YYYY', + dateFormat: 'M/D/YYYY', + dayFormat: 'D', + dateTimeFormat: 'M/D/YYYY HH:mm:ss', + monthBeforeYear: true, + previousMonth: 'ಹಿಂದಿನ ತಿಂಗಳು (ಪೇಜ್ಅಪ್)', + nextMonth: 'ಮುಂದಿನ ತಿಂಗಳು (ಪೇಜ್ಡೌನ್)', + previousYear: 'ಕಳೆದ ವರ್ಷ (Ctrl + ಎಡ)', + nextYear: 'ಮುಂದಿನ ವರ್ಷ (Ctrl + ಬಲ)', + previousDecade: 'ಕಳೆದ ದಶಕ', + nextDecade: 'ಮುಂದಿನ ದಶಕ', + previousCentury: 'ಕಳೆದ ಶತಮಾನ', + nextCentury: 'ಮುಂದಿನ ಶತಮಾನ', +}; diff --git a/components/vc-calendar/src/mixin/CalendarMixin.js b/components/vc-calendar/src/mixin/CalendarMixin.js index a0b8e43e6..cb6a388c9 100644 --- a/components/vc-calendar/src/mixin/CalendarMixin.js +++ b/components/vc-calendar/src/mixin/CalendarMixin.js @@ -4,16 +4,13 @@ import { hasProp } from '../../../_util/props-util'; import moment from 'moment'; import { isAllowedDate, getTodayTime } from '../util/index'; function noop() {} -function getNow() { - return moment(); -} -function getNowByCurrentStateValue(value) { +export function getNowByCurrentStateValue(value) { let ret; if (value) { ret = getTodayTime(value); } else { - ret = getNow(); + ret = moment(); } return ret; } @@ -29,6 +26,7 @@ function isMoment(value) { const MomentType = PropTypes.custom(isMoment); const CalendarMixin = { mixins: [BaseMixin], + name: 'CalendarMixinWrapper', props: { value: MomentType, defaultValue: MomentType, @@ -36,7 +34,7 @@ const CalendarMixin = { data() { const props = this.$props; - const sValue = props.value || props.defaultValue || getNow(); + const sValue = props.value || props.defaultValue || getNowByCurrentStateValue(); return { sValue, sSelectedValue: props.selectedValue || props.defaultSelectedValue, diff --git a/components/vc-calendar/src/mixin/CommonMixin.js b/components/vc-calendar/src/mixin/CommonMixin.js index e2f1000cf..fc80fa34f 100644 --- a/components/vc-calendar/src/mixin/CommonMixin.js +++ b/components/vc-calendar/src/mixin/CommonMixin.js @@ -30,11 +30,15 @@ export default { } return format; }, - focus() { - if (this.$refs.rootInstance) { + if (this.focusElement) { + this.focusElement.focus(); + } else if (this.$refs.rootInstance) { this.$refs.rootInstance.focus(); } }, + saveFocusElement (focusElement) { + this.focusElement = focusElement; + }, }, }; diff --git a/components/vc-calendar/src/month/MonthPanel.jsx b/components/vc-calendar/src/month/MonthPanel.jsx index 2726de40c..c55cdc3ab 100644 --- a/components/vc-calendar/src/month/MonthPanel.jsx +++ b/components/vc-calendar/src/month/MonthPanel.jsx @@ -23,6 +23,7 @@ const MonthPanel = { // onChange: PropTypes.func, disabledDate: PropTypes.func, // onSelect: PropTypes.func, + renderFooter: PropTypes.func, }, data() { @@ -69,10 +70,13 @@ const MonthPanel = { locale, rootPrefixCls, disabledDate, + renderFooter, $listeners = {}, } = this; const year = sValue.year(); const prefixCls = `${rootPrefixCls}-month-panel`; + + const footer = renderFooter && renderFooter('month'); return (
@@ -112,6 +116,10 @@ const MonthPanel = { prefixCls={prefixCls} />
+ {footer && ( +
+ {footer} +
)}
); diff --git a/components/vc-calendar/src/year/YearPanel.jsx b/components/vc-calendar/src/year/YearPanel.jsx index 9662092ae..f22d523a1 100644 --- a/components/vc-calendar/src/year/YearPanel.jsx +++ b/components/vc-calendar/src/year/YearPanel.jsx @@ -25,6 +25,7 @@ export default { value: PropTypes.object, defaultValue: PropTypes.object, locale: PropTypes.object, + renderFooter: PropTypes.func, }, data() { this.nextDecade = goYear.bind(this, 10); @@ -59,7 +60,7 @@ export default { }, render() { - const { sValue: value, locale, $listeners = {} } = this; + const { sValue: value, locale, renderFooter, $listeners = {} } = this; const decadePanelShow = $listeners.decadePanelShow || noop; const years = this.years(); const currentYear = value.year(); @@ -101,7 +102,7 @@ export default { ); }); - + const footer = renderFooter && renderFooter('year'); return (
@@ -136,6 +137,10 @@ export default { {yeasEls}
+ {footer && ( +
+ {footer} +
)}
); From 78c102378543081f8ea297fca24f71f3b444cfbf Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Fri, 25 Jan 2019 18:00:36 +0800 Subject: [PATCH 002/132] test: update test --- components/date-picker/__tests__/DatePicker.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/date-picker/__tests__/DatePicker.test.js b/components/date-picker/__tests__/DatePicker.test.js index 23dbafc93..a111b8417 100644 --- a/components/date-picker/__tests__/DatePicker.test.js +++ b/components/date-picker/__tests__/DatePicker.test.js @@ -117,6 +117,10 @@ describe('DatePicker', () => { await asyncExpect(() => { openPanel(wrapper); }); + await asyncExpect(() => { + // selectDateFromBody时(点击其它元素)没有触发input blur事件,强制执行blur + $$('.ant-calendar-input')[0].blur(); + }, 0); await asyncExpect(() => { selectDateFromBody(moment('2016-11-13')); }, 0); @@ -129,7 +133,6 @@ describe('DatePicker', () => { await asyncExpect(() => { expect($$('.ant-calendar-input')[0].value).toBe('2016-11-14 12:12:12'); }); - await asyncExpect(() => {}); }); it('triggers onChange only when date was selected', async () => { From 4df4424570b6c67fd90de72f98f17232d596f130 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 13 Feb 2019 22:11:27 +0800 Subject: [PATCH 003/132] perf: update to vue 2.6.x --- components/_util/props-util.js | 10 +++++++++- components/vc-align/Align.jsx | 5 +++-- package.json | 12 ++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/components/_util/props-util.js b/components/_util/props-util.js index 8e94a5474..e1141e6e7 100644 --- a/components/_util/props-util.js +++ b/components/_util/props-util.js @@ -60,6 +60,13 @@ const getSlots = ele => { }); return slots; }; +const getSlot = (self, name = 'default', options = {}) => { + return ( + (self.$scopedSlots && self.$scopedSlots[name] && self.$scopedSlots[name](options)) || + self.$slots[name] || + [] + ); +}; const getAllChildren = ele => { let componentOptions = ele.componentOptions || {}; if (ele.$vnode) { @@ -105,9 +112,9 @@ const getComponentFromProp = (instance, prop, options = instance, execute = true return typeof temp === 'function' && execute ? temp(h, options) : temp; } return ( - instance.$slots[prop] || (instance.$scopedSlots[prop] && execute && instance.$scopedSlots[prop](options)) || instance.$scopedSlots[prop] || + instance.$slots[prop] || undefined ); } else { @@ -289,6 +296,7 @@ export { isValidElement, camelize, getSlots, + getSlot, getAllProps, getAllChildren, }; diff --git a/components/vc-align/Align.jsx b/components/vc-align/Align.jsx index 4fecea4f1..a7922ac68 100644 --- a/components/vc-align/Align.jsx +++ b/components/vc-align/Align.jsx @@ -4,6 +4,7 @@ import addEventListener from '../_util/Dom/addEventListener'; import { isWindow, buffer, isSamePoint } from './util'; import { cloneElement } from '../_util/vnode.js'; import clonedeep from 'lodash/cloneDeep'; +import { getSlot } from '../_util/props-util'; function getElement(func) { if (typeof func !== 'function' || !func) return null; @@ -133,8 +134,8 @@ export default { render() { const { childrenProps } = this.$props; - const child = this.$slots.default[0]; - if (childrenProps) { + const child = getSlot(this)[0]; + if (child && childrenProps) { return cloneElement(child, { props: childrenProps }); } return child; diff --git a/package.json b/package.json index b0b803f96..ca0dc8a67 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,8 @@ "prettier" ], "peerDependencies": { - "vue": ">=2.5.0", - "vue-template-compiler": ">=2.5.0" + "vue": ">=2.6.6", + "vue-template-compiler": ">=2.6.6" }, "devDependencies": { "@commitlint/cli": "^6.2.0", @@ -153,17 +153,17 @@ "through2": "^2.0.3", "uglifyjs-webpack-plugin": "^2.1.1", "url-loader": "^1.1.2", - "vue": "^2.5.16", + "vue": "^2.6.6", "vue-antd-md-loader": "^1.1.0", "vue-clipboard2": "0.0.8", "vue-eslint-parser": "^5.0.0", "vue-i18n": "^8.3.2", "vue-infinite-scroll": "^2.0.2", "vue-jest": "^2.5.0", - "vue-loader": "^15.5.1", + "vue-loader": "^15.6.2", "vue-router": "^3.0.1", - "vue-server-renderer": "^2.5.16", - "vue-template-compiler": "^2.5.16", + "vue-server-renderer": "^2.6.6", + "vue-template-compiler": "^2.6.6", "vue-virtual-scroller": "^0.12.0", "vuex": "^3.1.0", "webpack": "^4.28.4", From 1d80cec3d758020497e1a085acf1554c86fa3a04 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 13 Feb 2019 22:12:00 +0800 Subject: [PATCH 004/132] style: format vc-calendar --- .../vc-calendar/assets/index/DecadePanel.less | 14 +++++----- .../vc-calendar/assets/index/MonthPanel.less | 15 +++++------ .../vc-calendar/assets/index/YearPanel.less | 14 +++++----- components/vc-calendar/src/Calendar.jsx | 16 ++++++----- components/vc-calendar/src/FullCalendar.jsx | 2 +- components/vc-calendar/src/MonthCalendar.jsx | 2 +- components/vc-calendar/src/date/DateInput.jsx | 27 +++++++++---------- .../vc-calendar/src/decade/DecadePanel.jsx | 5 +--- .../vc-calendar/src/mixin/CommonMixin.js | 2 +- .../vc-calendar/src/month/MonthPanel.jsx | 5 +--- components/vc-calendar/src/year/YearPanel.jsx | 5 +--- 11 files changed, 51 insertions(+), 56 deletions(-) diff --git a/components/vc-calendar/assets/index/DecadePanel.less b/components/vc-calendar/assets/index/DecadePanel.less index f83c591d0..b758eb57c 100644 --- a/components/vc-calendar/assets/index/DecadePanel.less +++ b/components/vc-calendar/assets/index/DecadePanel.less @@ -39,14 +39,15 @@ } } -.@{prefixClass}-decade-panel-prev-century-btn, .@{prefixClass}-decade-panel-next-century-btn { +.@{prefixClass}-decade-panel-prev-century-btn, +.@{prefixClass}-decade-panel-next-century-btn { position: absolute; top: 0; } .@{prefixClass}-decade-panel-next-century-btn { &:after { - content: '»' + content: '»'; } } @@ -54,7 +55,7 @@ user-select: none; left: 0; &:after { - content: '«' + content: '«'; } } @@ -111,10 +112,11 @@ } } -.@{prefixClass}-decade-panel-last-century-cell, .@{prefixClass}-decade-panel-next-century-cell { - .@{prefixClass}-decade-panel-decade{ +.@{prefixClass}-decade-panel-last-century-cell, +.@{prefixClass}-decade-panel-next-century-cell { + .@{prefixClass}-decade-panel-decade { user-select: none; -webkit-user-select: none; color: rgba(0, 0, 0, 0.25); } -} \ No newline at end of file +} diff --git a/components/vc-calendar/assets/index/MonthPanel.less b/components/vc-calendar/assets/index/MonthPanel.less index 1b35f0e6b..5bb3fc7a0 100644 --- a/components/vc-calendar/assets/index/MonthPanel.less +++ b/components/vc-calendar/assets/index/MonthPanel.less @@ -1,6 +1,6 @@ .@{prefixClass}-month-panel { left: 0; - top:0; + top: 0; bottom: 0; right: 0; background: #ffffff; @@ -43,14 +43,15 @@ } } -.@{prefixClass}-month-panel-prev-year-btn, .@{prefixClass}-month-panel-next-year-btn { +.@{prefixClass}-month-panel-prev-year-btn, +.@{prefixClass}-month-panel-next-year-btn { position: absolute; top: 0; } .@{prefixClass}-month-panel-next-year-btn { &:after { - content: '»' + content: '»'; } } @@ -59,7 +60,7 @@ left: 0; &:after { - content: '«' + content: '«'; } } @@ -96,8 +97,6 @@ .@{prefixClass}-month-panel-cell { text-align: center; - - .@{prefixClass}-month-panel-month { display: block; width: 46px; @@ -116,7 +115,7 @@ } } - &-disabled{ + &-disabled { .@{prefixClass}-month-panel-month { color: #bfbfbf; @@ -141,4 +140,4 @@ .@{prefixClass}-month-header-wrap { position: relative; height: 308px; -} \ No newline at end of file +} diff --git a/components/vc-calendar/assets/index/YearPanel.less b/components/vc-calendar/assets/index/YearPanel.less index 6b31dc8ec..77ba5c778 100644 --- a/components/vc-calendar/assets/index/YearPanel.less +++ b/components/vc-calendar/assets/index/YearPanel.less @@ -43,14 +43,15 @@ } } -.@{prefixClass}-year-panel-prev-decade-btn, .@{prefixClass}-year-panel-next-decade-btn { +.@{prefixClass}-year-panel-prev-decade-btn, +.@{prefixClass}-year-panel-next-decade-btn { position: absolute; top: 0; } .@{prefixClass}-year-panel-next-decade-btn { &:after { - content: '»' + content: '»'; } } @@ -59,7 +60,7 @@ left: 0; &:after { - content: '«' + content: '«'; } } @@ -125,10 +126,11 @@ } } -.@{prefixClass}-year-panel-last-decade-cell, .@{prefixClass}-year-panel-next-decade-cell { - .@{prefixClass}-year-panel-year{ +.@{prefixClass}-year-panel-last-decade-cell, +.@{prefixClass}-year-panel-next-decade-cell { + .@{prefixClass}-year-panel-year { user-select: none; -webkit-user-select: none; color: rgba(0, 0, 0, 0.25); } -} \ No newline at end of file +} diff --git a/components/vc-calendar/src/Calendar.jsx b/components/vc-calendar/src/Calendar.jsx index 909d21ad5..d4079f855 100644 --- a/components/vc-calendar/src/Calendar.jsx +++ b/components/vc-calendar/src/Calendar.jsx @@ -7,7 +7,7 @@ import moment from 'moment'; import DateTable from './date/DateTable'; import CalendarHeader from './calendar/CalendarHeader'; import CalendarFooter from './calendar/CalendarFooter'; -import CalendarMixin, {getNowByCurrentStateValue} from './mixin/CalendarMixin'; +import CalendarMixin, { getNowByCurrentStateValue } from './mixin/CalendarMixin'; import CommonMixin from './mixin/CommonMixin'; import DateInput from './date/DateInput'; import enUs from './locale/en_US'; @@ -74,8 +74,8 @@ const Calendar = { }); }, }, - mounted(){ - this.$nextTick(()=>{ + mounted() { + this.$nextTick(() => { this.saveFocusElement(DateInput.getInstance()); }); }, @@ -167,7 +167,7 @@ const Calendar = { source: 'dateInput', }); }, - onDateInputSelect (value) { + onDateInputSelect(value) { this.onSelect(value, { source: 'dateInputSelect', }); @@ -269,11 +269,12 @@ const Calendar = { onSelect={this.onDateInputSelect} /> ) : null; - const children =[]; + const children = []; if (props.renderSidebar) { children.push(props.renderSidebar()); } - children.push(
+ children.push( +
{dateInputElement}
-
); +
, + ); return this.renderRoot({ children, diff --git a/components/vc-calendar/src/FullCalendar.jsx b/components/vc-calendar/src/FullCalendar.jsx index b7c0a4b5c..a846823d5 100644 --- a/components/vc-calendar/src/FullCalendar.jsx +++ b/components/vc-calendar/src/FullCalendar.jsx @@ -4,7 +4,7 @@ import BaseMixin from '../../_util/BaseMixin'; import { getOptionProps, hasProp } from '../../_util/props-util'; import DateTable from './date/DateTable'; import MonthTable from './month/MonthTable'; -import CalendarMixin, {getNowByCurrentStateValue} from './mixin/CalendarMixin'; +import CalendarMixin, { getNowByCurrentStateValue } from './mixin/CalendarMixin'; import CommonMixin from './mixin/CommonMixin'; import CalendarHeader from './full-calendar/CalendarHeader'; import enUs from './locale/en_US'; diff --git a/components/vc-calendar/src/MonthCalendar.jsx b/components/vc-calendar/src/MonthCalendar.jsx index 2570f8d4a..d77c9eca6 100644 --- a/components/vc-calendar/src/MonthCalendar.jsx +++ b/components/vc-calendar/src/MonthCalendar.jsx @@ -28,7 +28,7 @@ const MonthCalendar = { data() { const props = this.$props; - return { + return { mode: 'month', sValue: props.value || props.defaultValue || moment(), sSelectedValue: props.selectedValue || props.defaultSelectedValue, diff --git a/components/vc-calendar/src/date/DateInput.jsx b/components/vc-calendar/src/date/DateInput.jsx index a459467cb..c146097ac 100644 --- a/components/vc-calendar/src/date/DateInput.jsx +++ b/components/vc-calendar/src/date/DateInput.jsx @@ -47,15 +47,12 @@ const DateInput = { updated() { this.$nextTick(() => { if ( - dateInputInstance && + dateInputInstance && this.$data.hasFocus && !this.invalid && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0) ) { - dateInputInstance.setSelectionRange( - cachedSelectionStart, - cachedSelectionEnd, - ); + dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd); } }); }, @@ -96,7 +93,7 @@ const DateInput = { }); return; } - + // 不合法直接退出 const parsed = moment(str, format, true); if (!parsed.isValid()) { @@ -140,9 +137,9 @@ const DateInput = { str: formatDate(prevProps.value, prevProps.format), })); }, - onKeyDown ({ keyCode }) { + onKeyDown({ keyCode }) { const { value } = this.$props; - if (keyCode === KeyCode.ENTER ) { + if (keyCode === KeyCode.ENTER) { this.__emit('select', value.clone()); } }, @@ -167,12 +164,14 @@ const DateInput = {
{decadesEls}
- {footer && ( -
- {footer} -
)} + {footer &&
{footer}
}
); }, diff --git a/components/vc-calendar/src/mixin/CommonMixin.js b/components/vc-calendar/src/mixin/CommonMixin.js index fc80fa34f..14d34c5dc 100644 --- a/components/vc-calendar/src/mixin/CommonMixin.js +++ b/components/vc-calendar/src/mixin/CommonMixin.js @@ -37,7 +37,7 @@ export default { this.$refs.rootInstance.focus(); } }, - saveFocusElement (focusElement) { + saveFocusElement(focusElement) { this.focusElement = focusElement; }, }, diff --git a/components/vc-calendar/src/month/MonthPanel.jsx b/components/vc-calendar/src/month/MonthPanel.jsx index c55cdc3ab..2bc34963e 100644 --- a/components/vc-calendar/src/month/MonthPanel.jsx +++ b/components/vc-calendar/src/month/MonthPanel.jsx @@ -116,10 +116,7 @@ const MonthPanel = { prefixCls={prefixCls} />
- {footer && ( -
- {footer} -
)} + {footer &&
{footer}
}
); diff --git a/components/vc-calendar/src/year/YearPanel.jsx b/components/vc-calendar/src/year/YearPanel.jsx index f22d523a1..f15c83632 100644 --- a/components/vc-calendar/src/year/YearPanel.jsx +++ b/components/vc-calendar/src/year/YearPanel.jsx @@ -137,10 +137,7 @@ export default { {yeasEls}
- {footer && ( -
- {footer} -
)} + {footer &&
{footer}
}
); From 9e9339c3b389fde0ad4d9dc53324521073ddba12 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Mon, 18 Feb 2019 22:13:29 +0800 Subject: [PATCH 005/132] feat: update rc-cascader to 0.17.1 --- components/vc-calendar/index.js | 2 +- components/vc-cascader/Cascader.jsx | 27 +++++++++++++++++---------- components/vc-cascader/Menus.jsx | 6 +++++- components/vc-cascader/index.js | 2 +- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/components/vc-calendar/index.js b/components/vc-calendar/index.js index 3091680aa..24744582f 100644 --- a/components/vc-calendar/index.js +++ b/components/vc-calendar/index.js @@ -1,4 +1,4 @@ -// based on rc-calendar 9.8.2 +// based on rc-calendar 9.10.8 import Vue from 'vue'; import ref from 'vue-ref'; import Calendar from './src/'; diff --git a/components/vc-cascader/Cascader.jsx b/components/vc-cascader/Cascader.jsx index a747dd2c5..8682e1b90 100644 --- a/components/vc-cascader/Cascader.jsx +++ b/components/vc-cascader/Cascader.jsx @@ -5,7 +5,7 @@ import Menus from './Menus'; import KeyCode from '../_util/KeyCode'; import arrayTreeFilter from 'array-tree-filter'; import shallowEqualArrays from 'shallow-equal/arrays'; -import { hasProp, getEvents } from '../_util/props-util'; +import { hasProp, getEvents, getSlot } from '../_util/props-util'; import BaseMixin from '../_util/BaseMixin'; import { cloneElement } from '../_util/vnode'; @@ -53,7 +53,7 @@ export default { props: { value: PropTypes.array, defaultValue: PropTypes.array, - options: PropTypes.array.def([]).isRequired, + options: PropTypes.array, // onChange: PropTypes.func, // onPopupVisibleChange: PropTypes.func, popupVisible: PropTypes.bool, @@ -96,12 +96,11 @@ export default { if (!shallowEqualArrays(val, oldValue)) { const newValues = { sValue: val || [], - sActiveValue: val || [], }; // allow activeValue diff from value // https://github.com/ant-design/ant-design/issues/2767 - if (hasProp(this, 'loadData')) { - delete newValues.sActiveValue; + if (!hasProp(this, 'loadData')) { + newValues.sActiveValue = val || []; } this.setState(newValues); } @@ -124,7 +123,7 @@ export default { return this.fieldNames; }, getCurrentLevelOptions() { - const { options, sActiveValue = [] } = this; + const { options = [], sActiveValue = [] } = this; const result = arrayTreeFilter( options, (o, level) => o[this.getFieldName('value')] === sActiveValue[level], @@ -137,7 +136,7 @@ export default { }, getActiveOptions(activeValue) { return arrayTreeFilter( - this.options, + this.options || [], (o, level) => o[this.getFieldName('value')] === activeValue[level], { childrenKeyName: this.getFieldName('children') }, ); @@ -214,6 +213,12 @@ export default { } this.setState(newState); }, + handleItemDoubleClick () { + const { changeOnSelect } = this.$props; + if (changeOnSelect) { + this.setPopupVisible(false); + } + }, handleKeyDown(e) { const { $slots } = this; const children = $slots.default && $slots.default[0]; @@ -313,7 +318,7 @@ export default { prefixCls, transitionName, popupClassName, - options, + options = [], disabled, builtinPlacements, popupPlacement, @@ -338,6 +343,7 @@ export default { on: { ...$listeners, select: handleMenuSelect, + itemDoubleClick: this.handleItemDoubleClick }, }; menus = ; @@ -362,10 +368,11 @@ export default { }, ref: 'trigger', }; + const children = getSlot(this, 'default')[0] return ( - {$slots.default && - cloneElement($slots.default[0], { + {children && + cloneElement(children[0], { on: { keydown: handleKeyDown, }, diff --git a/components/vc-cascader/Menus.jsx b/components/vc-cascader/Menus.jsx index 6ea9cca6d..cb8e53101 100644 --- a/components/vc-cascader/Menus.jsx +++ b/components/vc-cascader/Menus.jsx @@ -9,7 +9,7 @@ export default { props: { value: PropTypes.array.def([]), activeValue: PropTypes.array.def([]), - options: PropTypes.array.isRequired, + options: PropTypes.array, prefixCls: PropTypes.string.def('rc-cascader-menus'), expandTrigger: PropTypes.string.def('click'), // onSelect: PropTypes.func, @@ -51,11 +51,15 @@ export default { const onSelect = e => { this.__emit('select', option, menuIndex, e); }; + const onItemDoubleClick = e => { + this.__emit('itemDoubleClick', option, menuIndex, e); + }; const key = option[this.getFieldName('value')]; const expandProps = { attrs: {}, on: { click: onSelect, + doubleclick: onItemDoubleClick, }, key: Array.isArray(key) ? key.join('__ant__') : key, }; diff --git a/components/vc-cascader/index.js b/components/vc-cascader/index.js index bb97eb555..e3d0e9b3a 100644 --- a/components/vc-cascader/index.js +++ b/components/vc-cascader/index.js @@ -1,3 +1,3 @@ -// based on rc-cascader 0.16.2 +// based on rc-cascader 0.17.1 import Cascader from './Cascader'; export default Cascader; From a10711d9aeaeb3b47864c5cd38921b63cc50de60 Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Mon, 18 Feb 2019 23:33:39 +0800 Subject: [PATCH 006/132] feat: vc-upload to 2.6.2 --- components/vc-upload/demo/index.vue | 12 +++---- components/vc-upload/demo/simple.jsx | 3 +- components/vc-upload/index.js | 2 +- components/vc-upload/src/traverseFileTree.js | 33 ++++++++++++++++---- site/dev.js | 2 +- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/components/vc-upload/demo/index.vue b/components/vc-upload/demo/index.vue index 5f285d8fa..10fbdf53c 100644 --- a/components/vc-upload/demo/index.vue +++ b/components/vc-upload/demo/index.vue @@ -1,10 +1,10 @@ + +``` + + diff --git a/components/empty/demo/customize.md b/components/empty/demo/customize.md new file mode 100644 index 000000000..7e94955ca --- /dev/null +++ b/components/empty/demo/customize.md @@ -0,0 +1,22 @@ + +#### 自定义 +自定义图片、描述、附属内容。 + + + +#### Customize +Customize image, description and extra content. + + +```html + +``` diff --git a/components/empty/index.jsx b/components/empty/index.jsx index 2649db7a8..aca4831db 100644 --- a/components/empty/index.jsx +++ b/components/empty/index.jsx @@ -1,5 +1,5 @@ import PropTypes from '../_util/vue-types'; -import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; +import { ConfigConsumerProps } from '../config-provider'; import { getComponentFromProp } from '../_util/props-util'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import emptyImg from './empty.svg'; @@ -29,10 +29,7 @@ const Empty = { prefixCls: customizePrefixCls, ...restProps } = this.$props; - - // todo - // const prefixCls = getPrefixCls('empty', customizePrefixCls); - const prefixCls = customizePrefixCls || 'ant-empty'; + const prefixCls = ConfigConsumerProps.getPrefixCls('empty', customizePrefixCls); const image = getComponentFromProp(this, 'image'); const description = getComponentFromProp(this, 'description'); @@ -54,7 +51,7 @@ const Empty = {

{des}

- {this.$slots.default &&
{this.$slots.default[0]}
} + {this.$slots.default &&
{this.$slots.default}
}
); }, diff --git a/components/vc-cascader/Cascader.jsx b/components/vc-cascader/Cascader.jsx index 456f6c76b..a3510ebfa 100644 --- a/components/vc-cascader/Cascader.jsx +++ b/components/vc-cascader/Cascader.jsx @@ -372,7 +372,7 @@ export default { return ( {children && - cloneElement(children[0], { + cloneElement(children, { on: { keydown: handleKeyDown, }, diff --git a/components/vc-select/Select.jsx b/components/vc-select/Select.jsx index 3165d01cd..f4663523b 100644 --- a/components/vc-select/Select.jsx +++ b/components/vc-select/Select.jsx @@ -1488,7 +1488,6 @@ const Select = { }, render() { - console.log('12'); const props = this.$props; const multiple = isMultipleOrTags(props); // Default set showArrow to true if not set (not set directly in defaultProps to handle multiple case) From d112e2d9a2a73400b8fd0feb8a19336ffaf05104 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 10 Mar 2019 22:10:58 +0800 Subject: [PATCH 027/132] cr vc-upload and vc-progress --- components/vc-progress/src/Circle.js | 3 +- components/vc-progress/src/Line.js | 4 +-- components/vc-progress/src/enhancer.js | 32 ++++++++++----------- components/vc-upload/src/IframeUploader.jsx | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/components/vc-progress/src/Circle.js b/components/vc-progress/src/Circle.js index b07bfa175..503b5ffae 100644 --- a/components/vc-progress/src/Circle.js +++ b/components/vc-progress/src/Circle.js @@ -20,9 +20,8 @@ Vue.use(ref, { name: 'ant-ref' }); const Circle = { props: initDefaultProps(circlePropTypes, circleDefaultProps), - data() { + created() { this.paths = {}; - return {}; }, methods: { getPathStyles(offset, percent, strokeColor, strokeWidth, gapDegree = 0, gapPosition) { diff --git a/components/vc-progress/src/Line.js b/components/vc-progress/src/Line.js index c728c481f..ff2956866 100644 --- a/components/vc-progress/src/Line.js +++ b/components/vc-progress/src/Line.js @@ -8,9 +8,8 @@ Vue.use(ref, { name: 'ant-ref' }); const Line = { props: initDefaultProps(propTypes, defaultProps), - data() { + created() { this.paths = {}; - return {}; }, render() { const { @@ -67,6 +66,7 @@ const Line = { stackPtg += ptg; const pathProps = { + key: index, attrs: { d: pathString, 'stroke-linecap': strokeLinecap, diff --git a/components/vc-progress/src/enhancer.js b/components/vc-progress/src/enhancer.js index 6b9ed1f0c..ff515472a 100644 --- a/components/vc-progress/src/enhancer.js +++ b/components/vc-progress/src/enhancer.js @@ -2,29 +2,27 @@ function enhancer(Component) { return { mixins: [Component], updated() { - this.$nextTick(() => { - const now = Date.now(); - let updated = false; + const now = Date.now(); + let updated = false; - Object.keys(this.paths).forEach(key => { - const path = this.paths[key]; + Object.keys(this.paths).forEach(key => { + const path = this.paths[key]; - if (!path) { - return; - } + if (!path) { + return; + } - updated = true; - const pathStyle = path.style; - pathStyle.transitionDuration = '.3s, .3s, .3s, .06s'; + updated = true; + const pathStyle = path.style; + pathStyle.transitionDuration = '.3s, .3s, .3s, .06s'; - if (this.prevTimeStamp && now - this.prevTimeStamp < 100) { - pathStyle.transitionDuration = '0s, 0s'; - } - }); - if (updated) { - this.prevTimeStamp = Date.now(); + if (this.prevTimeStamp && now - this.prevTimeStamp < 100) { + pathStyle.transitionDuration = '0s, 0s'; } }); + if (updated) { + this.prevTimeStamp = Date.now(); + } }, }; } diff --git a/components/vc-upload/src/IframeUploader.jsx b/components/vc-upload/src/IframeUploader.jsx index 49368d224..431af946e 100644 --- a/components/vc-upload/src/IframeUploader.jsx +++ b/components/vc-upload/src/IframeUploader.jsx @@ -70,7 +70,7 @@ const IframeUploader = { name: target.value && target.value.substring(target.value.lastIndexOf('\\') + 1, target.value.length), - });; + }); this.startUpload(); const { $props: props } = this; if (!props.beforeUpload) { From 75cc96eefd6bfaa9fe6afe902077ee89ea92b713 Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Mon, 11 Mar 2019 11:54:14 +0800 Subject: [PATCH 028/132] feat: update affix --- components/affix/index.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/affix/index.jsx b/components/affix/index.jsx index e35990c35..380042469 100644 --- a/components/affix/index.jsx +++ b/components/affix/index.jsx @@ -6,6 +6,7 @@ import omit from 'omit.js'; import getScroll from '../_util/getScroll'; import BaseMixin from '../_util/BaseMixin'; import throttleByAnimationFrame from '../_util/throttleByAnimationFrame'; +import { ConfigConsumerProps } from '../config-provider'; function getTargetRect(target) { return target !== window ? target.getBoundingClientRect() : { top: 0, left: 0, bottom: 0 }; @@ -54,6 +55,9 @@ const Affix = { name: 'AAffix', props: AffixProps, mixins: [BaseMixin], + inject: { + configProvider: { default: () => ({}) }, + }, data() { this.events = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load']; this.eventHandlers = {}; @@ -166,7 +170,8 @@ const Affix = { const targetRect = getTargetRect(targetNode); const targetInnerHeight = targetNode.innerHeight || targetNode.clientHeight; - if (scrollTop > elemOffset.top - offsetTop && offsetMode.top) { + // ref: https://github.com/ant-design/ant-design/issues/13662 + if (scrollTop >= elemOffset.top - offsetTop && offsetMode.top) { // Fixed Top const width = `${elemOffset.width}px`; const top = `${targetRect.top + offsetTop}px`; @@ -181,7 +186,7 @@ const Affix = { height: `${elemSize.height}px`, }); } else if ( - scrollTop < elemOffset.top + elemSize.height + offsetBottom - targetInnerHeight && + scrollTop <= elemOffset.top + elemSize.height + offsetBottom - targetInnerHeight && offsetMode.bottom ) { // Fixed Bottom @@ -240,8 +245,9 @@ const Affix = { render() { const { prefixCls, affixStyle, placeholderStyle, $slots, $props } = this; + const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls; const className = classNames({ - [prefixCls || 'ant-affix']: affixStyle, + [getPrefixCls('affix', prefixCls)]: affixStyle, }); const props = { From 08821561ab4e96e052ffcbe5c12a7f27df79097d Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Mon, 11 Mar 2019 14:43:23 +0800 Subject: [PATCH 029/132] feat: update alert && update anchor --- components/alert/index.jsx | 11 +++++++++-- components/anchor/Anchor.jsx | 17 ++++++++++++----- components/anchor/AnchorLink.jsx | 9 +++++++-- components/anchor/demo/basic.md | 2 +- components/anchor/demo/onClick.md | 2 +- components/anchor/demo/static.md | 2 +- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/components/alert/index.jsx b/components/alert/index.jsx index 422744ec1..65c6ce12b 100644 --- a/components/alert/index.jsx +++ b/components/alert/index.jsx @@ -5,6 +5,7 @@ import PropTypes from '../_util/vue-types'; import getTransitionProps from '../_util/getTransitionProps'; import { getComponentFromProp, isValidElement } from '../_util/props-util'; import { cloneElement } from '../_util/vnode'; +import { ConfigConsumerProps } from '../config-provider'; function noop() {} export const AlertProps = { /** @@ -32,9 +33,12 @@ export const AlertProps = { }; const Alert = { + name: 'AAlert', props: AlertProps, mixins: [BaseMixin], - name: 'AAlert', + inject: { + configProvider: { default: () => ({}) }, + }, data() { return { closing: true, @@ -65,7 +69,10 @@ const Alert = { }, render() { - const { prefixCls = 'ant-alert', banner, closing, closed } = this; + const { prefixCls: customizePrefixCls, banner, closing, closed } = this; + const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls; + const prefixCls = getPrefixCls('alert', customizePrefixCls); + let { closable, type, showIcon, iconType } = this; const closeText = getComponentFromProp(this, 'closeText'); const description = getComponentFromProp(this, 'description'); diff --git a/components/anchor/Anchor.jsx b/components/anchor/Anchor.jsx index 0c8dad778..0c98648de 100644 --- a/components/anchor/Anchor.jsx +++ b/components/anchor/Anchor.jsx @@ -6,6 +6,7 @@ import getScroll from '../_util/getScroll'; import raf from 'raf'; import { initDefaultProps } from '../_util/props-util'; import BaseMixin from '../_util/BaseMixin'; +import { ConfigConsumerProps } from '../config-provider'; function getDefaultContainer() { return window; @@ -91,14 +92,16 @@ export default { mixins: [BaseMixin], inheritAttrs: false, props: initDefaultProps(AnchorProps, { - prefixCls: 'ant-anchor', affix: true, showInkInFixed: false, getContainer: getDefaultContainer, }), - + inject: { + configProvider: { default: () => ({}) }, + }, data() { this.links = []; + this._sPrefixCls = ''; return { activeLink: null, }; @@ -200,8 +203,8 @@ export default { if (typeof document === 'undefined') { return; } - const { prefixCls } = this; - const linkNode = this.$el.getElementsByClassName(`${prefixCls}-link-title-active`)[0]; + const { _sPrefixCls } = this; + const linkNode = this.$el.getElementsByClassName(`${_sPrefixCls}-link-title-active`)[0]; if (linkNode) { this.$refs.linkNode.style.top = `${linkNode.offsetTop + linkNode.clientHeight / 2 - 4.5}px`; } @@ -209,7 +212,11 @@ export default { }, render() { - const { prefixCls, offsetTop, affix, showInkInFixed, activeLink, $slots, getContainer } = this; + const { prefixCls: customizePrefixCls, offsetTop, affix, showInkInFixed, activeLink, $slots, getContainer } = this; + + const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls; + const prefixCls = getPrefixCls('anchor', customizePrefixCls); + this._sPrefixCls = prefixCls; const inkClass = classNames(`${prefixCls}-ink-ball`, { visible: activeLink, diff --git a/components/anchor/AnchorLink.jsx b/components/anchor/AnchorLink.jsx index c683e69e5..6410a2a28 100644 --- a/components/anchor/AnchorLink.jsx +++ b/components/anchor/AnchorLink.jsx @@ -1,6 +1,7 @@ import PropTypes from '../_util/vue-types'; import { initDefaultProps, getComponentFromProp } from '../_util/props-util'; import classNames from 'classnames'; +import { ConfigConsumerProps } from '../config-provider'; export const AnchorLinkProps = { prefixCls: PropTypes.string, @@ -11,12 +12,12 @@ export const AnchorLinkProps = { export default { name: 'AAnchorLink', props: initDefaultProps(AnchorLinkProps, { - prefixCls: 'ant-anchor', href: '#', }), inject: { antAnchor: { default: () => ({}) }, antAnchorContext: { default: () => ({}) }, + configProvider: { default: () => ({}) }, }, watch: { href(val, oldVal) { @@ -44,7 +45,11 @@ export default { }, }, render() { - const { prefixCls, href, $slots } = this; + const { prefixCls: customizePrefixCls, href, $slots } = this; + + const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls; + const prefixCls = getPrefixCls('anchor', customizePrefixCls); + const title = getComponentFromProp(this, 'title'); const active = this.antAnchor.$data.activeLink === href; const wrapperClassName = classNames(`${prefixCls}-link`, { diff --git a/components/anchor/demo/basic.md b/components/anchor/demo/basic.md index 0dcc0ed6a..9f8f44b66 100644 --- a/components/anchor/demo/basic.md +++ b/components/anchor/demo/basic.md @@ -12,7 +12,7 @@ The simplest usage. ``` - diff --git a/components/button/demo/block.md b/components/button/demo/block.md index fab314eb9..d1c3c5d60 100644 --- a/components/button/demo/block.md +++ b/components/button/demo/block.md @@ -1,4 +1,3 @@ - #### block 按钮 `block`属性将使按钮适合其父宽度。 @@ -20,4 +19,3 @@
``` - diff --git a/components/button/demo/button-group.md b/components/button/demo/button-group.md index 78c14db1c..798b2e98c 100644 --- a/components/button/demo/button-group.md +++ b/components/button/demo/button-group.md @@ -32,12 +32,8 @@ The `size` can be set to `large`, `small` or left unset resulting in a default s

With Icon

- - Go back - - - Go forward - + Go back + Go forward @@ -46,17 +42,17 @@ The `size` can be set to `large`, `small` or left unset resulting in a default s
``` diff --git a/components/button/demo/disabled.md b/components/button/demo/disabled.md index 315688845..dc9d2bec7 100644 --- a/components/button/demo/disabled.md +++ b/components/button/demo/disabled.md @@ -1,4 +1,3 @@ - #### 不可用状态 添加 `disabled` 属性即可让按钮处于不可用状态,同时按钮样式也会改变。 diff --git a/components/button/demo/index.vue b/components/button/demo/index.vue index dfcf95363..aa0b11bd6 100644 --- a/components/button/demo/index.vue +++ b/components/button/demo/index.vue @@ -39,22 +39,22 @@ export default { zhType: '通用', title: 'Button', subtitle: '按钮', - render () { + render() { return (
- + - + - - + +
); @@ -62,11 +62,11 @@ export default { }; diff --git a/components/button/demo/loading.md b/components/button/demo/loading.md index 3cda8a2e3..a244cb16f 100644 --- a/components/button/demo/loading.md +++ b/components/button/demo/loading.md @@ -30,21 +30,21 @@ A loading indicator can be added to a button by setting the `loading` property o
``` diff --git a/components/button/demo/multiple.md b/components/button/demo/multiple.md index 31c533664..fca2c4118 100644 --- a/components/button/demo/multiple.md +++ b/components/button/demo/multiple.md @@ -19,19 +19,17 @@ If you need several buttons, we recommend that you use 1 primary button + n seco 2nd item 3rd item - - Actions - + Actions
``` diff --git a/components/button/demo/size.md b/components/button/demo/size.md index eb787420b..4e220e765 100644 --- a/components/button/demo/size.md +++ b/components/button/demo/size.md @@ -30,27 +30,23 @@ If a large or small button is desired, set the `size` property to either `large` Download
- - Backward - - - Forward - + Backward + Forward
``` diff --git a/components/button/index.en-US.md b/components/button/index.en-US.md index 0e14ef23c..dee7dfc81 100644 --- a/components/button/index.en-US.md +++ b/components/button/index.en-US.md @@ -3,7 +3,7 @@ To get a customized button, just set `type`/`shape`/`size`/`loading`/`disabled`. | Property | Description | Type | Default | -| -------- | ----------- | ---- | ------- | +| --- | --- | --- | --- | | disabled | disabled state of button | boolean | `false` | | ghost | make background transparent and invert text and border colors, added in 2.7 | boolean | false | | htmlType | set the original html `type` of `button`, see: [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | @@ -15,16 +15,15 @@ To get a customized button, just set `type`/`shape`/`size`/`loading`/`disabled`. | block | option to fit button width to its parent width | boolean | `false` | ### events -| Events Name | Description | Arguments | -| --- | --- | --- | -| click | set the handler to handle `click` event | (event) => void | -`` will be rendered into ``, and all the properties which are not listed above will be transferred to the `` will be rendered into `Hello world!`. +| Events Name | Description | Arguments | +| ----------- | --------------------------------------- | --------------- | +| click | set the handler to handle `click` event | (event) => void | + +`` will be rendered into ``, and all the properties which are not listed above will be transferred to the `` will be rendered into `Hello world!`. ## FAQ ### How to remove space between 2 chinese characters Use [ConfigProvider](/components/config-provider/#API) to set `autoInsertSpaceInButton` as `false`. - diff --git a/components/button/index.zh-CN.md b/components/button/index.zh-CN.md index c3b071d75..f61819d1c 100644 --- a/components/button/index.zh-CN.md +++ b/components/button/index.zh-CN.md @@ -11,22 +11,21 @@ | htmlType | 设置 `button` 原生的 `type` 值,可选值请参考 [HTML 标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | | icon | 设置按钮的图标类型 | string | - | | loading | 设置按钮载入状态 | boolean \| { delay: number } | `false` | -| shape | 设置按钮形状,可选值为 `circle`、 `round` 或者不设 | string | - | +| shape | 设置按钮形状,可选值为 `circle`、 `round` 或者不设 | string | - | | size | 设置按钮大小,可选值为 `small` `large` 或者不设 | string | `default` | -| type | 设置按钮类型,可选值为 `primary` `dashed` `danger` `link` 或者不设| string | `default` | +| type | 设置按钮类型,可选值为 `primary` `dashed` `danger` `link` 或者不设 | string | `default` | | block | 将按钮宽度调整为其父宽度的选项 | boolean | `false` | ### 事件 -| 事件名称 | 说明 | 回调参数 | -| --- | --- | --- | -| click | 点击按钮时的回调 | (event) => void | -`Hello world!` 最终会被渲染为 ``,并且除了上表中的属性,其它属性都会直接传到原生 button 上。 -`` 则会渲染为 `Hello world!`。 +| 事件名称 | 说明 | 回调参数 | +| -------- | ---------------- | --------------- | +| click | 点击按钮时的回调 | (event) => void | + +`Hello world!` 最终会被渲染为 ``,并且除了上表中的属性,其它属性都会直接传到原生 button 上。 `` 则会渲染为 `Hello world!`。 ## FAQ ### 如何移除 2 个汉字之间的空格 设置 [ConfigProvider](/components/config-provider/#API) 的 `autoInsertSpaceInButton` 为 `false`。 - diff --git a/components/calendar/demo/basic.md b/components/calendar/demo/basic.md index b5e011db7..58d7dd8b8 100644 --- a/components/calendar/demo/basic.md +++ b/components/calendar/demo/basic.md @@ -13,12 +13,12 @@ A basic calendar component with Year/Month switch. ``` diff --git a/components/calendar/demo/card.md b/components/calendar/demo/card.md index 8e4c69deb..723ee4b22 100644 --- a/components/calendar/demo/card.md +++ b/components/calendar/demo/card.md @@ -15,13 +15,12 @@ Nested inside a container element for rendering in limited space.
``` - diff --git a/components/calendar/demo/index.vue b/components/calendar/demo/index.vue index 6fffabbe9..265c681bf 100644 --- a/components/calendar/demo/index.vue +++ b/components/calendar/demo/index.vue @@ -32,17 +32,17 @@ export default { subtitle: '日历', cols: 1, title: 'Calendar', - render () { + render() { return (
- + -   - Monitor window resize + +   Monitor window resize

diff --git a/components/vc-calendar/demo/antd-calendar.vue b/components/vc-calendar/demo/antd-calendar.vue index bcbe5086f..70f84df06 100644 --- a/components/vc-calendar/demo/antd-calendar.vue +++ b/components/vc-calendar/demo/antd-calendar.vue @@ -24,32 +24,32 @@ if (cn) { now.locale('en-gb').utcOffset(0); } -function getFormat (time) { +function getFormat(time) { return time ? format : 'YYYY-MM-DD'; } const defaultCalendarValue = now.clone(); defaultCalendarValue.add(-1, 'month'); -const timePickerElement = (h) => ; +const timePickerElement = h => ; -function disabledTime (date) { +function disabledTime(date) { console.log('disabledTime', date); - if (date && (date.date() === 15)) { + if (date && date.date() === 15) { return { - disabledHours () { + disabledHours() { return [3, 4]; }, }; } return { - disabledHours () { + disabledHours() { return [1, 2]; }, }; } -function disabledDate (current) { +function disabledDate(current) { if (!current) { // allow empty select return false; @@ -67,7 +67,7 @@ const Demo = { defaultCalendarValue: PropTypes.object, }, mixins: [BaseMixin], - data () { + data() { return { showTime: true, showDateInput: true, @@ -76,109 +76,105 @@ const Demo = { }; }, methods: { - onChange (value) { - console.log('DatePicker change: ', (value && value.format(format))); + onChange(value) { + console.log('DatePicker change: ', value && value.format(format)); this.setState({ value, }); }, - onShowTimeChange (e) { + onShowTimeChange(e) { this.setState({ showTime: e.target.checked, }); }, - onShowDateInputChange (e) { + onShowDateInputChange(e) { this.setState({ showDateInput: e.target.checked, }); }, - toggleDisabled () { + toggleDisabled() { this.setState({ disabled: !this.disabled, }); }, }, - render (h) { + render(h) { const state = this.$data; - const calendar = (); - return (
-
- -      - -      - -
-
- { - return ( - - - - ); - }, + const calendar = ( + + ); + return ( +
+
+ +      + +      + +
+
- + { + return ( + + + + ); + }, + }} + > +
-
); + ); }, }; @@ -189,45 +185,47 @@ const DemoMultiFormat = { value: now, }), methods: { - onChange (value) { - console.log('Calendar change: ', (value && value.format(format))); + onChange(value) { + console.log('Calendar change: ', value && value.format(format)); this.value = value; }, }, - render () { + render() { const state = this.$data; - return (
-
- Accepts multiple input formats -
- {multiFormats.join(', ')} + return ( +
+
+ Accepts multiple input formats +
+ {multiFormats.join(', ')} +
+
- -
); + ); }, }; -function onStandaloneSelect (value) { +function onStandaloneSelect(value) { console.log('onStandaloneSelect'); console.log(value && value.format(format)); } -function onStandaloneChange (value) { +function onStandaloneChange(value) { console.log('onStandaloneChange'); console.log(value && value.format(format)); } export default { - render (h) { + render(h) { return (
({mode} extra footer)} + renderFooter={mode => {mode} extra footer} />
@@ -269,5 +267,4 @@ export default { ); }, }; - diff --git a/components/vc-calendar/demo/antd-month-calendar.vue b/components/vc-calendar/demo/antd-month-calendar.vue index f9a3fd3aa..c914cf7d0 100644 --- a/components/vc-calendar/demo/antd-month-calendar.vue +++ b/components/vc-calendar/demo/antd-month-calendar.vue @@ -33,7 +33,7 @@ const Demo = { defaultValue: PropTypes.object, }, - data () { + data() { return { showTime: true, disabled: false, @@ -41,96 +41,91 @@ const Demo = { }; }, methods: { - onChange (value) { + onChange(value) { console.log(`DatePicker change: ${value && value.format(format)}`); this.setState({ value, }); }, - onShowTimeChange (e) { + onShowTimeChange(e) { this.setState({ showTime: e.target.checked, }); }, - toggleDisabled () { + toggleDisabled() { this.setState({ disabled: !this.disabled, }); }, }, - render () { + render() { const state = this.$data; - const calendar = (); - return (
-
-      - -
-
- { - return ( - - ); - }, + const calendar = ; + return ( +
+
+      + +
+
- + { + return ( + + ); + }, + }} + > +
-
); + ); }, }; -function onStandaloneSelect (value) { - console.log('month-calendar select', (value && value.format(format))); +function onStandaloneSelect(value) { + console.log('month-calendar select', value && value.format(format)); } -function onStandaloneChange (value) { - console.log('month-calendar change', (value && value.format(format))); +function onStandaloneChange(value) { + console.log('month-calendar change', value && value.format(format)); } -function disabledDate (value) { - return value.year() > now.year() || - value.year() === now.year() && value.month() > now.month(); +function disabledDate(value) { + return value.year() > now.year() || (value.year() === now.year() && value.month() > now.month()); } -function onMonthCellContentRender (value) { +function onMonthCellContentRender(value) { // console.log('month-calendar onMonthCellContentRender', (value && value.format(format))); return `${value.month() + 1}月`; } export default { - render () { + render() { return (
; +const timePickerElement = h => ( + +); -function newArray (start, end) { +function newArray(start, end) { const result = []; for (let i = start; i < end; i++) { result.push(i); @@ -44,7 +48,7 @@ function newArray (start, end) { return result; } -function disabledDate (current) { +function disabledDate(current) { const date = moment(); date.hour(0); date.minute(0); @@ -52,16 +56,16 @@ function disabledDate (current) { return current.isBefore(date); // can not select days before today } -function disabledTime (time, type) { +function disabledTime(time, type) { console.log('disabledTime', time, type); if (type === 'start') { return { - disabledHours () { + disabledHours() { const hours = newArray(0, 60); hours.splice(20, 4); return hours; }, - disabledMinutes (h) { + disabledMinutes(h) { if (h === 20) { return newArray(0, 31); } else if (h === 23) { @@ -69,18 +73,18 @@ function disabledTime (time, type) { } return []; }, - disabledSeconds () { + disabledSeconds() { return [55, 56]; }, }; } return { - disabledHours () { + disabledHours() { const hours = newArray(0, 60); hours.splice(2, 6); return hours; }, - disabledMinutes (h) { + disabledMinutes(h) { if (h === 20) { return newArray(0, 31); } else if (h === 23) { @@ -88,50 +92,50 @@ function disabledTime (time, type) { } return []; }, - disabledSeconds () { + disabledSeconds() { return [55, 56]; }, }; } const formatStr = 'YYYY-MM-DD HH:mm:ss'; -function format (v) { +function format(v) { return v ? v.format(formatStr) : ''; } -function isValidRange (v) { +function isValidRange(v) { return v && v[0] && v[1]; } -function onStandaloneChange (value) { +function onStandaloneChange(value) { console.log('onChange'); console.log(value[0] && format(value[0]), value[1] && format(value[1])); } -function onStandaloneSelect (value) { +function onStandaloneSelect(value) { console.log('onSelect'); console.log(format(value[0]), format(value[1])); } const Demo = { mixins: [BaseMixin], - data () { + data() { return { value: [], hoverValue: [], }; }, methods: { - onChange (value) { + onChange(value) { console.log('onChange', value); this.setState({ value }); }, - onHoverChange (hoverValue) { + onHoverChange(hoverValue) { this.setState({ hoverValue }); }, }, - render (h) { + render(h) { const state = this.$data; const calendar = ( ); return ( - - { - ({ value }) => { - return ( + + {({ value }) => { + return ( + - ); - } - } - ); + + ); + }} + + ); }, }; export default { - render (h) { + render(h) { return (

calendar

@@ -201,5 +201,4 @@ export default { ); }, }; - diff --git a/components/vc-calendar/demo/full-calendar.vue b/components/vc-calendar/demo/full-calendar.vue index 5d0eae482..b0a4dbc1d 100644 --- a/components/vc-calendar/demo/full-calendar.vue +++ b/components/vc-calendar/demo/full-calendar.vue @@ -28,26 +28,26 @@ if (cn) { const defaultCalendarValue = now.clone(); defaultCalendarValue.add(-1, 'month'); -function onSelect (value) { +function onSelect(value) { console.log('select', value.format(format)); } export default { mixins: [BaseMixin], - data () { + data() { return { type: 'month', }; }, methods: { - onTypeChange (type) { + onTypeChange(type) { this.setState({ type, }); }, }, - render () { + render() { return (
\ No newline at end of file + diff --git a/components/vc-cascader/demo/animation.vue b/components/vc-cascader/demo/animation.vue index 7604d0a00..b7b7c4b23 100644 --- a/components/vc-cascader/demo/animation.vue +++ b/components/vc-cascader/demo/animation.vue @@ -3,60 +3,76 @@ import '../assets/index.less'; import Cascader from '../index'; -const addressOptions = [{ - label: '福建', - value: 'fj', - children: [{ - label: '福州', - value: 'fuzhou', - children: [{ - label: '马尾', - value: 'mawei', - }], - }, { - label: '泉州', - value: 'quanzhou', - }], -}, { - label: '浙江', - value: 'zj', - children: [{ - label: '杭州', - value: 'hangzhou', - children: [{ - label: '余杭', - value: 'yuhang', - }], - }], -}, { - label: '北京', - value: 'bj', - children: [{ - label: '朝阳区', - value: 'chaoyang', - }, { - label: '海淀区', - value: 'haidian', - }], -}]; +const addressOptions = [ + { + label: '福建', + value: 'fj', + children: [ + { + label: '福州', + value: 'fuzhou', + children: [ + { + label: '马尾', + value: 'mawei', + }, + ], + }, + { + label: '泉州', + value: 'quanzhou', + }, + ], + }, + { + label: '浙江', + value: 'zj', + children: [ + { + label: '杭州', + value: 'hangzhou', + children: [ + { + label: '余杭', + value: 'yuhang', + }, + ], + }, + ], + }, + { + label: '北京', + value: 'bj', + children: [ + { + label: '朝阳区', + value: 'chaoyang', + }, + { + label: '海淀区', + value: 'haidian', + }, + ], + }, +]; export default { - data () { + data() { return { inputValue: '', }; }, methods: { - onChange (value, selectedOptions) { + onChange(value, selectedOptions) { console.log(value, selectedOptions); this.inputValue = selectedOptions.map(o => o.label).join(', '); }, }, - render () { + render() { return ( - - + + ); }, diff --git a/components/vc-cascader/demo/custom-field-name.vue b/components/vc-cascader/demo/custom-field-name.vue index d7922cdcc..b49fa5786 100644 --- a/components/vc-cascader/demo/custom-field-name.vue +++ b/components/vc-cascader/demo/custom-field-name.vue @@ -3,71 +3,83 @@ import '../assets/index.less'; import Cascader from '../index'; -const addressOptions = [{ - name: '福建', - code: 'fj', - nodes: [{ - name: '福州', - code: 'fuzhou', - nodes: [{ - name: '马尾', - code: 'mawei', - }], - }, { - name: '泉州', - code: 'quanzhou', - }], -}, { - name: '浙江', - code: 'zj', - nodes: [{ - name: '杭州', - code: 'hangzhou', - nodes: [{ - name: '余杭', - code: 'yuhang', - }], - }], -}, { - name: '北京', - code: 'bj', - nodes: [{ - name: '朝阳区', - code: 'chaoyang', - }, { - name: '海淀区', - code: 'haidian', - disabled: true, - }], -}]; +const addressOptions = [ + { + name: '福建', + code: 'fj', + nodes: [ + { + name: '福州', + code: 'fuzhou', + nodes: [ + { + name: '马尾', + code: 'mawei', + }, + ], + }, + { + name: '泉州', + code: 'quanzhou', + }, + ], + }, + { + name: '浙江', + code: 'zj', + nodes: [ + { + name: '杭州', + code: 'hangzhou', + nodes: [ + { + name: '余杭', + code: 'yuhang', + }, + ], + }, + ], + }, + { + name: '北京', + code: 'bj', + nodes: [ + { + name: '朝阳区', + code: 'chaoyang', + }, + { + name: '海淀区', + code: 'haidian', + disabled: true, + }, + ], + }, +]; export default { - data () { + data() { return { inputValue: '', }; }, methods: { - onChange (value, selectedOptions) { + onChange(value, selectedOptions) { console.log(value, selectedOptions); this.inputValue = selectedOptions.map(o => o.name).join(', '); }, }, - render () { + render() { return ( - + ); }, }; - diff --git a/components/vc-dialog/demo/ant-design.vue b/components/vc-dialog/demo/ant-design.vue index 42e9c134a..9237d4b66 100644 --- a/components/vc-dialog/demo/ant-design.vue +++ b/components/vc-dialog/demo/ant-design.vue @@ -5,14 +5,15 @@ import '../assets/index.less'; // use import Dialog from 'rc-dialog' import Dialog from '../index'; -const clearPath = 'M793 242H366v-74c0-6.7-7.7-10.4-12.9' + +const clearPath = + 'M793 242H366v-74c0-6.7-7.7-10.4-12.9' + '-6.3l-142 112c-4.1 3.2-4.1 9.4 0 12.6l142 112c' + '5.2 4.1 12.9 0.4 12.9-6.3v-74h415v470H175c-4.4' + ' 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h618c35.3 0 64-' + '28.7 64-64V306c0-35.3-28.7-64-64-64z'; export default { - data () { + data() { return { visible: false, width: 600, @@ -24,22 +25,22 @@ export default { }; }, methods: { - getSvg (path, props = {}, align = false) { + getSvg(path, props = {}, align = false) { return ( - + ); }, - onClick (e) { + onClick(e) { this.visible = true; this.mousePosition = { x: e.pageX, @@ -47,32 +48,32 @@ export default { }; }, - onClose () { - // console.log(e); + onClose() { + // console.log(e); this.visible = false; }, - onDestroyOnCloseChange (e) { + onDestroyOnCloseChange(e) { this.destroyOnClose = e.target.checked; }, - onForceRenderChange (e) { + onForceRenderChange(e) { this.forceRender = e.target.checked; }, - changeWidth () { + changeWidth() { this.width = this.width === 600 ? 800 : 600; }, - handleCenter (e) { + handleCenter(e) { this.center = e.target.checked; }, - toggleCloseIcon () { + toggleCloseIcon() { this.useIcon = !this.useIcon; }, }, - render () { + render() { const style = { width: this.width + 'px', }; @@ -85,8 +86,8 @@ export default { // getContainer={() => this.$refs.container} visible={this.visible} wrapClassName={wrapClassName} - animation='zoom' - maskAnimation='fade' + animation="zoom" + maskAnimation="fade" onClose={this.onClose} style={style} mousePosition={this.mousePosition} @@ -94,11 +95,11 @@ export default { closeIcon={this.useIcon ? this.getSvg(clearPath, {}, true) : undefined} forceRender={this.forceRender} > - +

basic modal

@@ -106,7 +107,7 @@ export default { return (

ant-design dialog

-
+

- -   +   -   +     - +

{dialog}
diff --git a/components/vc-input-number/demo/index.vue b/components/vc-input-number/demo/index.vue index 131eb2adf..ee33d839e 100644 --- a/components/vc-input-number/demo/index.vue +++ b/components/vc-input-number/demo/index.vue @@ -8,19 +8,18 @@ import Simple from './simple.jsx'; import SmallStep from './small-step.jsx'; export default { - render () { + render() { return (
- - - - + + + +
); }, }; - diff --git a/components/vc-pagination/demo/default.vue b/components/vc-pagination/demo/default.vue index c1ffbb3cd..a97e39772 100644 --- a/components/vc-pagination/demo/default.vue +++ b/components/vc-pagination/demo/default.vue @@ -3,25 +3,19 @@ import VcPagination from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { current: 3, }; }, methods: { - onChange (page) { + onChange(page) { console.log(page); this.current = page; }, }, - render () { - return ( - - ); + render() { + return ; }, }; diff --git a/components/vc-pagination/demo/itemRender.vue b/components/vc-pagination/demo/itemRender.vue index 755529c26..ed3441e68 100644 --- a/components/vc-pagination/demo/itemRender.vue +++ b/components/vc-pagination/demo/itemRender.vue @@ -3,17 +3,17 @@ import VcPagination from '../index'; import '../assets/index.less'; export default { - data () { + data() { return {}; }, methods: { - itemRender (current, type, element) { + itemRender(current, type, element) { if (type === 'page') { return {current}; } return element; }, - textItemRender (current, type, element) { + textItemRender(current, type, element) { if (type === 'prev') { return 'Prev'; } @@ -23,17 +23,11 @@ export default { return element; }, }, - render () { + render() { return (
- - + +
); }, diff --git a/components/vc-pagination/demo/jumper.vue b/components/vc-pagination/demo/jumper.vue index 0d472c218..9294ddbd7 100644 --- a/components/vc-pagination/demo/jumper.vue +++ b/components/vc-pagination/demo/jumper.vue @@ -5,44 +5,44 @@ import '../assets/index.less'; import '../../vc-select/assets/index.less'; export default { - data () { + data() { return {}; }, methods: { - onShowSizeChange (current, pageSize) { + onShowSizeChange(current, pageSize) { console.log(current); console.log(pageSize); }, - onChange (current, pageSize) { + onChange(current, pageSize) { console.log('onChange:current=', current); console.log('onChange:pageSize=', pageSize); }, }, - render () { + render() { return (
- -
- + +
+
); }, diff --git a/components/vc-pagination/demo/jumperWithGoButton.vue b/components/vc-pagination/demo/jumperWithGoButton.vue index 534630fc9..2d8fa71c0 100644 --- a/components/vc-pagination/demo/jumperWithGoButton.vue +++ b/components/vc-pagination/demo/jumperWithGoButton.vue @@ -5,20 +5,20 @@ import '../assets/index.less'; import '../../vc-select/assets/index.less'; export default { - data () { + data() { return {}; }, methods: { - onShowSizeChange (current, pageSize) { + onShowSizeChange(current, pageSize) { console.log(current); console.log(pageSize); }, - onChange (current, pageSize) { + onChange(current, pageSize) { console.log('onChange:current=', current); console.log('onChange:pageSize=', pageSize); }, }, - render () { + render() { return (

customize node

diff --git a/components/vc-pagination/demo/lessPages.vue b/components/vc-pagination/demo/lessPages.vue index c83e9fa1e..9f728f50e 100644 --- a/components/vc-pagination/demo/lessPages.vue +++ b/components/vc-pagination/demo/lessPages.vue @@ -3,26 +3,21 @@ import VcPagination from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { current: 3, }; }, methods: { - onChange (page) { + onChange(page) { console.log(page); this.current = page; }, }, - render () { + render() { return (
- +
); diff --git a/components/vc-pagination/demo/more.vue b/components/vc-pagination/demo/more.vue index f456df5ce..181ba2de8 100644 --- a/components/vc-pagination/demo/more.vue +++ b/components/vc-pagination/demo/more.vue @@ -3,10 +3,10 @@ import VcPagination from '../index'; import '../assets/index.less'; export default { - data () { + data() { return {}; }, - render () { + render() { return (
diff --git a/components/vc-pagination/demo/showTitle.vue b/components/vc-pagination/demo/showTitle.vue index dd0f487b2..9d3d42373 100644 --- a/components/vc-pagination/demo/showTitle.vue +++ b/components/vc-pagination/demo/showTitle.vue @@ -3,18 +3,18 @@ import VcPagination from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { current: 3, }; }, methods: { - onChange (page) { + onChange(page) { console.log(page); this.current = page; }, }, - render () { + render() { return (
- `Total ${total} items`} - total={455} - /> + `Total ${total} items`} total={455} /> `${range[0]} - ${range[1]} of ${total} items`} total={455} diff --git a/components/vc-pagination/demo/simple.vue b/components/vc-pagination/demo/simple.vue index 00f1954bd..bb1a358ca 100644 --- a/components/vc-pagination/demo/simple.vue +++ b/components/vc-pagination/demo/simple.vue @@ -3,16 +3,13 @@ import VcPagination from '../index'; import '../assets/index.less'; export default { - data () { + data() { return {}; }, - render () { + render() { return (
- +
); }, diff --git a/components/vc-pagination/demo/sizer.vue b/components/vc-pagination/demo/sizer.vue index e692f9521..ce58b56a8 100644 --- a/components/vc-pagination/demo/sizer.vue +++ b/components/vc-pagination/demo/sizer.vue @@ -5,18 +5,18 @@ import '../assets/index.less'; import '../../vc-select/assets/index.less'; export default { - data () { + data() { return { pageSize: 20, }; }, methods: { - onShowSizeChange (current, pageSize) { + onShowSizeChange(current, pageSize) { console.log(current); this.pageSize = pageSize; }, }, - render () { + render() { return (
- +
); }, diff --git a/components/vc-pagination/demo/styles.vue b/components/vc-pagination/demo/styles.vue index 26fef396b..6286b9f25 100644 --- a/components/vc-pagination/demo/styles.vue +++ b/components/vc-pagination/demo/styles.vue @@ -3,17 +3,13 @@ import VcPagination from '../index'; import '../assets/index.less'; export default { - data () { + data() { return {}; }, - render () { + render() { return (
- +
); }, diff --git a/components/vc-select/demo/combobox.vue b/components/vc-select/demo/combobox.vue index 07b500b9d..839ff2187 100644 --- a/components/vc-select/demo/combobox.vue +++ b/components/vc-select/demo/combobox.vue @@ -3,62 +3,66 @@ import Select, { Option } from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { disabled: false, value: '', }; }, methods: { - onChange (value, option) { + onChange(value, option) { console.log('onChange', value, option); this.value = value; }, - onKeyDown (e) { + onKeyDown(e) { if (e.keyCode === 13) { console.log('onEnter', this.value); } }, - onSelect (v, option) { + onSelect(v, option) { console.log('onSelect', v, option); }, - toggleDisabled () { + toggleDisabled() { this.disabled = !this.disabled; }, }, - render () { - return (
-

combobox

-

- -

-
- + render() { + return ( +
+

combobox

+

+ +

+
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/email.vue b/components/vc-select/demo/email.vue index 391ebed15..df0e7108d 100644 --- a/components/vc-select/demo/email.vue +++ b/components/vc-select/demo/email.vue @@ -3,21 +3,21 @@ import Select, { Option } from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { disabled: false, options: [], }; }, methods: { - onChange (value) { + onChange(value) { console.log('onChange', value); let options = []; if (value) { if (value.indexOf('@') >= 0) { options = ; } else { - options = ['gmail.com', 'yahoo.com', 'outlook.com'].map((domain) => { + options = ['gmail.com', 'yahoo.com', 'outlook.com'].map(domain => { const email = `${value}@${domain}`; return ; }); @@ -25,22 +25,24 @@ export default { } this.options = options; }, - onSelect (v) { + onSelect(v) { console.log('onSelect', v); }, }, - render () { - return (); + render() { + return ( + + ); }, }; diff --git a/components/vc-select/demo/force-suggest.vue b/components/vc-select/demo/force-suggest.vue index 082487616..2fa1bf7e3 100644 --- a/components/vc-select/demo/force-suggest.vue +++ b/components/vc-select/demo/force-suggest.vue @@ -4,7 +4,7 @@ import { fetch } from './tbFetchSuggest'; import '../assets/index.less'; export default { - data () { + data() { return { disabled: false, data: [], @@ -12,14 +12,14 @@ export default { }; }, methods: { - onChange (value) { + onChange(value) { console.log('select ', value); // value.label = value.key this.value = value; }, - fetchData (value) { + fetchData(value) { if (value) { - fetch(value, (data) => { + fetch(value, data => { this.data = data; }); } else { @@ -27,38 +27,44 @@ export default { } }, - toggleDisabled () { + toggleDisabled() { this.disabled = !this.disabled; }, }, - render () { + render() { const data = this.data; - const options = data.map((d) => { - return ; + const options = data.map(d => { + return ( + + ); }); - return (
-

force suggest

-

- -

+ return (
- +

force suggest

+

+ +

+
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/mul-suggest.vue b/components/vc-select/demo/mul-suggest.vue index 8ca1e888e..9f94251aa 100644 --- a/components/vc-select/demo/mul-suggest.vue +++ b/components/vc-select/demo/mul-suggest.vue @@ -4,50 +4,56 @@ import '../assets/index.less'; import { fetch } from './tbFetchSuggest'; export default { - data () { + data() { return { data: [], value: [], }; }, methods: { - onChange (value) { + onChange(value) { console.log('onChange ', value); this.value = value; }, - fetchData (value) { - fetch(value, (data) => { + fetchData(value) { + fetch(value, data => { this.data = data; }); }, }, - render () { + render() { const data = this.data; - const options = data.map((d) => { - return ; + const options = data.map(d => { + return ( + + ); }); - return (
-

multiple suggest

- + return (
- +

multiple suggest

+ +
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/mul-tag-suggest.vue b/components/vc-select/demo/mul-tag-suggest.vue index 4f245eb99..124d74451 100644 --- a/components/vc-select/demo/mul-tag-suggest.vue +++ b/components/vc-select/demo/mul-tag-suggest.vue @@ -4,53 +4,59 @@ import '../assets/index.less'; import { fetch } from './tbFetchSuggest'; export default { - data () { + data() { return { data: [], value: [], }; }, methods: { - onChange (value) { + onChange(value) { console.log('onChange ', value); this.value = value; }, - onSelect (value) { + onSelect(value) { console.log('select ', value); }, - fetchData (value) { - fetch(value, (data) => { + fetchData(value) { + fetch(value, data => { this.data = data; }); }, }, - render () { + render() { const data = this.data; - const options = data.map((d) => { - return ; + const options = data.map(d => { + return ( + + ); }); - return (
-

multiple suggest

- + return (
- +

multiple suggest

+ +
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/multiple-readonly.vue b/components/vc-select/demo/multiple-readonly.vue index 147fe96b2..04ff2d774 100644 --- a/components/vc-select/demo/multiple-readonly.vue +++ b/components/vc-select/demo/multiple-readonly.vue @@ -4,55 +4,61 @@ import '../assets/index.less'; import { fetch } from './tbFetchSuggest'; export default { - data () { + data() { return { data: [], value: ['b11'], }; }, methods: { - onChange (value) { + onChange(value) { console.log('onChange ', value); this.value = value; }, - onSelect (value) { + onSelect(value) { console.log('select ', value); }, - fetchData (value) { - fetch(value, (data) => { + fetchData(value) { + fetch(value, data => { this.data = data; }); }, }, - render () { + render() { const children = []; for (let i = 10; i < 36; i++) { // 11 => readonly selected item - children.push(); + children.push( + , + ); } const dropdownMenuStyle = { maxHeight: '200px', }; - return (
-

multiple readonly default selected item

+ return (
- +

multiple readonly default selected item

+
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/multiple.vue b/components/vc-select/demo/multiple.vue index 6eeaf4d98..53252525a 100644 --- a/components/vc-select/demo/multiple.vue +++ b/components/vc-select/demo/multiple.vue @@ -3,72 +3,74 @@ import Select, { Option } from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { useAnim: 0, value: ['a10'], }; }, methods: { - onChange (value, options) { + onChange(value, options) { console.log('onChange', value, options); this.value = value; }, - onSelect (...args) { + onSelect(...args) { console.log('select ', args); }, - onDeselect (...args) { + onDeselect(...args) { console.log('deselect ', args); }, - useAnimation (e) { + useAnimation(e) { this.useAnim = e.target.checked; }, }, - render () { + render() { const children = []; for (let i = 10; i < 36; i++) { children.push( + 中文{i} + , ); } const dropdownMenuStyle = { maxHeight: '200px', }; - return (
-

multiple select(scroll the menu)

+ return ( +
+

multiple select(scroll the menu)

-

-

+ -

+ + +

-
- +
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/optgroup.vue b/components/vc-select/demo/optgroup.vue index f6df100cb..49fcfc326 100644 --- a/components/vc-select/demo/optgroup.vue +++ b/components/vc-select/demo/optgroup.vue @@ -4,41 +4,47 @@ import '../assets/index.less'; export default { methods: { - onChange (value, option) { + onChange(value, option) { console.log(`selected ${value}`, option); }, }, - render () { - return (
-

Select OptGroup

-
- + render() { + return ( +
+

Select OptGroup

+
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/optionFilterProp.vue b/components/vc-select/demo/optionFilterProp.vue index e2bf44e57..ad226373e 100644 --- a/components/vc-select/demo/optionFilterProp.vue +++ b/components/vc-select/demo/optionFilterProp.vue @@ -4,28 +4,36 @@ import '../assets/index.less'; export default { methods: { - onChange (value) { + onChange(value) { console.log(`selected ${value}`); }, }, - render () { - return (
-

Select optionFilterProp

-
- + render() { + return ( +
+

Select optionFilterProp

+
+ +
-
); + ); }, }; diff --git a/components/vc-select/demo/optionLabelProp.vue b/components/vc-select/demo/optionLabelProp.vue index bfce64d9f..01c8bdc79 100644 --- a/components/vc-select/demo/optionLabelProp.vue +++ b/components/vc-select/demo/optionLabelProp.vue @@ -4,27 +4,29 @@ import '../assets/index.less'; export default { methods: { - onChange (value) { + onChange(value) { console.log(`selected ${value}`); }, }, - render () { + render() { const cases = { 0: { name: 'Case 1' }, 1: { name: 'Case 2' }, 2: { name: 'Case 3' }, }; - return (
-

Select optionLabelProp

- -
); + return ( +
+

Select optionLabelProp

+ +
+ ); }, }; diff --git a/components/vc-select/demo/single.vue b/components/vc-select/demo/single.vue index fd6dd516b..8eec484b4 100644 --- a/components/vc-select/demo/single.vue +++ b/components/vc-select/demo/single.vue @@ -3,14 +3,14 @@ import Select, { Option } from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { destroy: false, value: 9, }; }, methods: { - onChange (e) { + onChange(e) { let value; if (e && e.target) { value = e.target.value; @@ -21,81 +21,95 @@ export default { this.value = value; }, - onDestroy () { + onDestroy() { this.destroy = 1; }, - onBlur (v) { + onBlur(v) { console.log('onBlur', v); }, - onFocus () { + onFocus() { console.log('onFocus'); }, }, - render () { + render() { if (this.destroy) { return null; } - return (
-
+ return ( +
+
-

Single Select

+

Single Select

-
- + - - - - {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => { - return ; + + + + + + {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(i => { + return ( + + ); + })} + +
+ +

native select

+ + + +

+ +

- -

native select

- - -

- -

-
); + ); }, }; diff --git a/components/vc-select/demo/suggest.vue b/components/vc-select/demo/suggest.vue index 102f4d5c7..ed716fdc3 100644 --- a/components/vc-select/demo/suggest.vue +++ b/components/vc-select/demo/suggest.vue @@ -3,64 +3,66 @@ import Select, { Option } from '../index'; import '../assets/index.less'; import { fetch } from './tbFetchSuggest'; export default { - data () { + data() { return { data: [], value: [], }; }, methods: { - onKeyDown (e) { + onKeyDown(e) { if (e.keyCode === 13) { console.log('onEnter', this.value); this.jump(this.value); } }, - onSelect (value) { + onSelect(value) { console.log('select ', value); this.jump(value); }, - jump (v) { + jump(v) { console.log('jump ', v); - // location.href = 'https://s.taobao.com/search?q=' + encodeURIComponent(v); + // location.href = 'https://s.taobao.com/search?q=' + encodeURIComponent(v); }, - fetchData (value) { + fetchData(value) { this.value = value; - fetch(value, (data) => { + fetch(value, data => { this.data = data; }); }, }, - render () { + render() { const data = this.data; - const options = data.map((d) => { + const options = data.map(d => { return ; }); - return (
-

suggest

+ return ( +
+

suggest

-
- } - showArrow={false} - notFoundContent='' - onChange={this.fetchData} - onSelect={this.onSelect} - filterOption={false} - > - {options} - +
+ } + showArrow={false} + notFoundContent="" + onChange={this.fetchData} + onSelect={this.onSelect} + filterOption={false} + > + {options} + +
-
); + ); }, }; diff --git a/components/vc-select/demo/tags.vue b/components/vc-select/demo/tags.vue index 97dc4fe2c..3dabe1c2b 100644 --- a/components/vc-select/demo/tags.vue +++ b/components/vc-select/demo/tags.vue @@ -3,7 +3,7 @@ import Select, { Option } from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { disabled: false, value: ['name2', 'name3'], @@ -11,60 +11,66 @@ export default { }; }, methods: { - onChange (value, option) { + onChange(value, option) { console.log(`changed ${value}`, option); this.value = value; }, - onSelect (value, option) { + onSelect(value, option) { console.log(`selected ${value}`, option.props); }, - onDeselect (value, option) { + onDeselect(value, option) { console.log(`deselected ${value}`, option); }, - toggleDisabled () { + toggleDisabled() { this.disabled = !this.disabled; }, - toggleMaxTagCount (count) { + toggleMaxTagCount(count) { this.maxTagCount = count; }, }, - render () { + render() { const children = []; for (let i = 10; i < 36; i++) { - children.push(); + children.push( + , + ); } - return (
-

tags select(scroll the menu)

- + return (
- +

tags select(scroll the menu)

+ +
+ +
+

+ + + +

-

- - - -

-
); + ); }, }; diff --git a/components/vc-steps/demo/alternativeLabel.vue b/components/vc-steps/demo/alternativeLabel.vue index bf10453f2..19904f8fd 100644 --- a/components/vc-steps/demo/alternativeLabel.vue +++ b/components/vc-steps/demo/alternativeLabel.vue @@ -4,20 +4,21 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - description: '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', + description: + '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', }; }, - render () { + render() { const { description } = this; return ( - - - - - - + + + + + + ); }, diff --git a/components/vc-steps/demo/composable.vue b/components/vc-steps/demo/composable.vue index a3e6fb115..a6956707d 100644 --- a/components/vc-steps/demo/composable.vue +++ b/components/vc-steps/demo/composable.vue @@ -4,19 +4,24 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - description: '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', + description: + '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', }; }, - render () { + render() { const { description } = this; return ( - - - - + + + + ); }, diff --git a/components/vc-steps/demo/customIcon.vue b/components/vc-steps/demo/customIcon.vue index be55d59ab..9454a28be 100644 --- a/components/vc-steps/demo/customIcon.vue +++ b/components/vc-steps/demo/customIcon.vue @@ -4,19 +4,17 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { - return { - - }; + data() { + return {}; }, - render () { + render() { return ( - - + + - - + + ); }, diff --git a/components/vc-steps/demo/dynamic.vue b/components/vc-steps/demo/dynamic.vue index a61472a36..95fa51853 100644 --- a/components/vc-steps/demo/dynamic.vue +++ b/components/vc-steps/demo/dynamic.vue @@ -4,36 +4,49 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - steps: [{ - title: '已完成', - description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', - }, { - title: '进行中', - description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', - }, { - title: '待运行', - description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', - }, { - title: '待运行', - description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', - }], + steps: [ + { + title: '已完成', + description: + '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', + }, + { + title: '进行中', + description: + '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', + }, + { + title: '待运行', + description: + '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', + }, + { + title: '待运行', + description: + '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶', + }, + ], }; }, methods: { - addStep () { + addStep() { this.steps.push({ title: '待运行', description: '新的节点', }); }, }, - render () { + render() { return (
- {this.steps.map((step, i) => )} + + {this.steps.map((step, i) => ( + + ))} +
); }, diff --git a/components/vc-steps/demo/errorStep.vue b/components/vc-steps/demo/errorStep.vue index 64d35b362..29f3ed31f 100644 --- a/components/vc-steps/demo/errorStep.vue +++ b/components/vc-steps/demo/errorStep.vue @@ -4,19 +4,20 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - description: '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', + description: + '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', }; }, - render () { + render() { const { description } = this; return ( - - - - - + + + + + ); }, diff --git a/components/vc-steps/demo/nextStep.vue b/components/vc-steps/demo/nextStep.vue index 944d679ec..5018bbf3f 100644 --- a/components/vc-steps/demo/nextStep.vue +++ b/components/vc-steps/demo/nextStep.vue @@ -3,25 +3,25 @@ import Steps, { Step } from '../index'; import '../assets/index.less'; import '../assets/iconfont.less'; -function generateRandomSteps () { +function generateRandomSteps() { const n = Math.floor(Math.random() * 3) + 3; const arr = []; for (let i = 0; i < n; i++) { arr.push({ - title: `步骤${(i + 1)}`, + title: `步骤${i + 1}`, }); } return arr; } const steps = generateRandomSteps(); export default { - data () { + data() { return { currentStep: Math.floor(Math.random() * steps.length), }; }, methods: { - nextStep () { + nextStep() { let s = this.currentStep + 1; if (s === steps.length) { s = 0; @@ -29,28 +29,25 @@ export default { this.currentStep = s; }, }, - render () { + render() { const cs = this.currentStep; return ( -
+
这个demo随机生成3~6个步骤,初始随机进行到其中一个步骤
当前正在执行第{cs + 1}步
-
+
- { - steps.map((s, i) => { - return ( - - ); - }) - } + {steps.map((s, i) => { + return ; + })}
-
+
+ +
); }, @@ -67,4 +64,3 @@ export default { width: 100%; } - diff --git a/components/vc-steps/demo/progressDot.vue b/components/vc-steps/demo/progressDot.vue index f2a299dae..2d55e9efe 100644 --- a/components/vc-steps/demo/progressDot.vue +++ b/components/vc-steps/demo/progressDot.vue @@ -4,20 +4,21 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - description: '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', + description: + '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', }; }, - render () { + render() { const { description } = this; return ( - - - - - - + + + + + + ); }, diff --git a/components/vc-steps/demo/simple.vue b/components/vc-steps/demo/simple.vue index 3172b28cb..420c8b873 100644 --- a/components/vc-steps/demo/simple.vue +++ b/components/vc-steps/demo/simple.vue @@ -4,32 +4,33 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - description: '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', + description: + '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', }; }, - render () { + render() { const { description } = this; return (
- - - - + + + + - - - - + + + + - - - - - + + + + +
); diff --git a/components/vc-steps/demo/smallSize.vue b/components/vc-steps/demo/smallSize.vue index be7e58303..4aa67a2c3 100644 --- a/components/vc-steps/demo/smallSize.vue +++ b/components/vc-steps/demo/smallSize.vue @@ -4,24 +4,24 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return {}; }, - render () { + render() { return (
- - - - - + + + + + - - + + - - + +
); diff --git a/components/vc-steps/demo/vertical.vue b/components/vc-steps/demo/vertical.vue index 57f50ef8b..60ffeb021 100644 --- a/components/vc-steps/demo/vertical.vue +++ b/components/vc-steps/demo/vertical.vue @@ -4,20 +4,21 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - description: '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', + description: + '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', }; }, - render () { + render() { const { description } = this; return ( - - - - - - + + + + + + ); }, diff --git a/components/vc-steps/demo/verticalSmall.vue b/components/vc-steps/demo/verticalSmall.vue index bee192d84..e1289a7df 100644 --- a/components/vc-steps/demo/verticalSmall.vue +++ b/components/vc-steps/demo/verticalSmall.vue @@ -4,20 +4,21 @@ import '../assets/index.less'; import '../assets/iconfont.less'; export default { - data () { + data() { return { - description: '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', + description: + '这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊这里是多信息的描述啊', }; }, - render () { + render() { const { description } = this; return ( - - - - - - + + + + + + ); }, diff --git a/components/vc-switch/demo/simple.vue b/components/vc-switch/demo/simple.vue index d322cb070..99dd757a0 100644 --- a/components/vc-switch/demo/simple.vue +++ b/components/vc-switch/demo/simple.vue @@ -3,29 +3,29 @@ import VcSwitch from '../index'; import '../assets/index.less'; export default { - data () { + data() { return { disabled: false, }; }, methods: { - toggle () { + toggle() { this.disabled = !this.disabled; }, - onChange (value) { + onChange(value) { console.log(`switch checked: ${value}`); // eslint-disable-line }, }, - render () { + render() { return ( -
+
-
+
diff --git a/components/vc-time-picker/demo/all.vue b/components/vc-time-picker/demo/all.vue index b153918ef..d8a73e58a 100644 --- a/components/vc-time-picker/demo/all.vue +++ b/components/vc-time-picker/demo/all.vue @@ -7,18 +7,22 @@ import TimePicker from '../index'; const format = 'h:mm a'; -const now = moment().hour(0).minute(0); +const now = moment() + .hour(0) + .minute(0); -function onChange (value) { +function onChange(value) { console.log(value && value.format(format)); } const showSecond = true; const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; -const now1 = moment().hour(14).minute(30); +const now1 = moment() + .hour(14) + .minute(30); -function generateOptions (length, excludedOptions) { +function generateOptions(length, excludedOptions) { const arr = []; for (let value = 0; value < length; value++) { if (excludedOptions.indexOf(value) < 0) { @@ -28,15 +32,15 @@ function generateOptions (length, excludedOptions) { return arr; } -function onChange1 (value) { +function onChange1(value) { console.log(value && value.format(str)); } -function disabledHours () { +function disabledHours() { return [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]; } -function disabledMinutes (h) { +function disabledMinutes(h) { switch (h) { case 9: return generateOptions(60, [30]); @@ -47,58 +51,54 @@ function disabledMinutes (h) { } } -function disabledSeconds (h, m) { - return [h + m % 60]; +function disabledSeconds(h, m) { + return [h + (m % 60)]; } -export default{ - data () { +export default { + data() { return { open: false, value: moment(), }; }, methods: { - setOpen ({ open }) { + setOpen({ open }) { this.open = open; }, - toggleOpen () { + toggleOpen() { this.open = !this.open; }, - handleValueChange (value) { + handleValueChange(value) { console.log(value && value.format('HH:mm:ss')); this.value = value; }, - clear () { + clear() { this.value = undefined; }, }, - render () { + render() { return (
-
-
+
+

Disabled picker

- +

Disabled options

- +
[0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} disabledMinutes={() => [0, 2, 4, 6, 8]} @@ -127,30 +127,19 @@ export default{ />
- +
- - + +
diff --git a/components/vc-tree/demo/animation.vue b/components/vc-tree/demo/animation.vue index 5ae6490a5..85176cbfb 100644 --- a/components/vc-tree/demo/animation.vue +++ b/components/vc-tree/demo/animation.vue @@ -4,10 +4,10 @@ import Tree, { TreeNode } from '../index'; import '../assets/index.less'; import cssAnimation from '../../_util/css-animation'; -function animate (node, show, done) { +function animate(node, show, done) { let height = node.offsetHeight; return cssAnimation(node, 'collapse', { - start () { + start() { if (!show) { node.style.height = `${node.offsetHeight}px`; } else { @@ -15,10 +15,10 @@ function animate (node, show, done) { node.style.height = 0; } }, - active () { + active() { node.style.height = `${show ? height : 0}px`; }, - end () { + end() { node.style.height = ''; done(); }, @@ -26,31 +26,31 @@ function animate (node, show, done) { } const animation = { - enter (node, done) { + enter(node, done) { return animate(node, true, done); }, - leave (node, done) { + leave(node, done) { return animate(node, false, done); }, }; export default { - render () { + render() { return (

expanded

- - - - - - + + + + + + - + @@ -58,7 +58,6 @@ export default { ); }, }; - - ## Features - An enterprise-class UI design language for web applications. @@ -31,8 +28,8 @@ Following the Ant Design specification, we developed a Vue UI library `antd` tha ## Environment Support -* Modern browsers and Internet Explorer 9+ (with [polyfills](https://vue.ant.design/docs/vue/getting-started/#Compatibility)) -* Server-side Rendering +- Modern browsers and Internet Explorer 9+ (with [polyfills](https://vue.ant.design/docs/vue/getting-started/#Compatibility)) +- Server-side Rendering ## Version @@ -79,39 +76,38 @@ Vue.use(DatePicker); And import stylesheets manually: ```jsx -import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less' +import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less' ``` ### Use modularized antd - Use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) (Recommended) - ```js - // .babelrc or babel-loader option - { - "plugins": [ - ["import", { "libraryName": "ant-design-vue", "libraryDirectory": "es", "style": "css" }] // `style: true` for less - ] - } - ``` + ```js + // .babelrc or babel-loader option + { + "plugins": [ + ["import", { "libraryName": "ant-design-vue", "libraryDirectory": "es", "style": "css" }] // `style: true` for less + ] + } + ``` - > Note: Don't set `libraryDirectory` if you are using webpack 1. + > Note: Don't set `libraryDirectory` if you are using webpack 1. - This allows you to import components from antd without having to manually import the corresponding stylesheet. The antd babel plugin will automatically import stylesheets. + This allows you to import components from antd without having to manually import the corresponding stylesheet. The antd babel plugin will automatically import stylesheets. - ```jsx - // import js and css modularly, parsed by babel-plugin-import - import { DatePicker } from 'ant-design-vue'; - ``` + ```jsx + // import js and css modularly, parsed by babel-plugin-import + import { DatePicker } from 'ant-design-vue'; + ``` - Manually import - ```jsx - import DatePicker from 'ant-design-vue/lib/date-picker'; // for js - import 'ant-design-vue/lib/date-picker/style/css'; // for css - // import 'ant-design-vue/lib/date-picker/style'; // that will import less - ``` - + ```jsx + import DatePicker from 'ant-design-vue/lib/date-picker'; // for js + import 'ant-design-vue/lib/date-picker/style/css'; // for css + // import 'ant-design-vue/lib/date-picker/style'; // that will import less + ``` ## Links @@ -127,10 +123,9 @@ import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less' ## Contributing - If you'd like to help us improve antd, just create a [Pull Request](https://github.com/vueComponent/ant-design-vue/pulls). Feel free to report bugs and issues [here](https://vuecomponent.github.io/issue-helper/). -> If you're new to posting issues, we ask that you read [*How To Ask Questions The Smart Way*](http://www.catb.org/~esr/faqs/smart-questions.html) and [How to Ask a Question in Open Source Community](https://github.com/seajs/seajs/issues/545) and [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) prior to posting. Well written bug reports help us help you! +> If you're new to posting issues, we ask that you read [_How To Ask Questions The Smart Way_](http://www.catb.org/~esr/faqs/smart-questions.html) and [How to Ask a Question in Open Source Community](https://github.com/seajs/seajs/issues/545) and [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) prior to posting. Well written bug reports help us help you! ## THANK YOU diff --git a/docs/vue/introduce.zh-CN.md b/docs/vue/introduce.zh-CN.md index 7c4e38dba..7c6bed880 100644 --- a/docs/vue/introduce.zh-CN.md +++ b/docs/vue/introduce.zh-CN.md @@ -1,4 +1,3 @@ - # Ant Design of Vue 这里是 Ant Design 的 Vue 实现,开发和服务于企业级后台产品。 @@ -21,7 +20,6 @@ } - ## 特性 - 提炼自企业级中后台产品的交互语言和视觉风格。 @@ -30,8 +28,8 @@ ## 支持环境 -* 现代浏览器和 IE9 及以上(需要 [polyfills](https://vue.ant.design/docs/vue/getting-started-cn/#兼容性))。 -* 支持服务端渲染。 +- 现代浏览器和 IE9 及以上(需要 [polyfills](https://vue.ant.design/docs/vue/getting-started-cn/#兼容性))。 +- 支持服务端渲染。 ## 版本 @@ -55,14 +53,13 @@ $ yarn add ant-design-vue 如果你的网络环境不佳,推荐使用 [cnpm](https://github.com/cnpm/cnpm)。 -> **组件库使用了 vue 的新特性`slot-scope`(2.5.0新增), `provide / inject`(2.2.0新增)** +> **组件库使用了 vue 的新特性`slot-scope`(2.5.0 新增), `provide / inject`(2.2.0 新增)** ### 浏览器引入 在浏览器中使用 `script` 和 `link` 标签直接引入文件,并使用全局变量 `antd`。 -我们在 npm 发布包内的 `ant-design-vue/dist` 目录下提供了 `antd.js` `antd.css` 以及 `antd.min.js` `antd.min.css`。你也可以通过 [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/ant-design-vue/badge)](https://www.jsdelivr.com/package/npm/ant-design-vue) - 或 [UNPKG](https://unpkg.com/ant-design-vue/dist/) 进行下载。 +我们在 npm 发布包内的 `ant-design-vue/dist` 目录下提供了 `antd.js` `antd.css` 以及 `antd.min.js` `antd.min.css`。你也可以通过 [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/ant-design-vue/badge)](https://www.jsdelivr.com/package/npm/ant-design-vue) 或 [UNPKG](https://unpkg.com/ant-design-vue/dist/) 进行下载。 > **强烈不推荐使用已构建文件**,这样无法按需加载,而且难以获得底层依赖模块的 bug 快速修复支持。 @@ -79,7 +76,7 @@ Vue.use(DatePicker); 引入样式: ```jsx -import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less' +import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less' ``` ### 按需加载 @@ -88,31 +85,31 @@ import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less' - 使用 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)(推荐)。 - ```js - // .babelrc or babel-loader option - { - "plugins": [ - ["import", { "libraryName": "ant-design-vue", "libraryDirectory": "es", "style": "css" }] // `style: true` 会加载 less 文件 - ] - } - ``` + ```js + // .babelrc or babel-loader option + { + "plugins": [ + ["import", { "libraryName": "ant-design-vue", "libraryDirectory": "es", "style": "css" }] // `style: true` 会加载 less 文件 + ] + } + ``` - > 注意:webpack 1 无需设置 `libraryDirectory`。 + > 注意:webpack 1 无需设置 `libraryDirectory`。 - 然后只需从 ant-design-vue 引入模块即可,无需单独引入样式。等同于下面手动引入的方式。 + 然后只需从 ant-design-vue 引入模块即可,无需单独引入样式。等同于下面手动引入的方式。 - ```jsx - // babel-plugin-import 会帮助你加载 JS 和 CSS - import { DatePicker } from 'ant-design-vue'; - ``` + ```jsx + // babel-plugin-import 会帮助你加载 JS 和 CSS + import { DatePicker } from 'ant-design-vue'; + ``` - 手动引入 - ```jsx - import DatePicker from 'ant-design-vue/lib/date-picker'; // 加载 JS - import 'ant-design-vue/lib/date-picker/style/css'; // 加载 CSS - // import 'ant-design-vue/lib/date-picker/style'; // 加载 LESS - ``` + ```jsx + import DatePicker from 'ant-design-vue/lib/date-picker'; // 加载 JS + import 'ant-design-vue/lib/date-picker/style/css'; // 加载 CSS + // import 'ant-design-vue/lib/date-picker/style'; // 加载 LESS + ``` ## 链接 @@ -126,22 +123,20 @@ import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less' - [支持我们](/docs/vue/sponsor-cn) - [Awesome Ant Design](https://github.com/vueComponent/ant-design-vue-awesome) - ## 如何贡献 如果你希望参与贡献,欢迎 [Pull Request](https://github.com/vueComponent/ant-design-vue/pulls),或给我们 [报告 Bug](https://vuecomponent.github.io/issue-helper/)([国内镜像](http://ant-design-vue.gitee.io/issue-helper/))。 > 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。 -## 关于ant-design-vue +## 关于 ant-design-vue -众所周知,Ant Design作为一门设计语言面世,经历过多年的迭代和积累,它对UI的设计思想已经成为一套事实标准,受到众多前端开发者及企业的追捧和喜爱,也是React开发者手中的神兵利器。希望ant-design-vue能够让Vue开发者也享受到Ant Design的优秀设计。 +众所周知,Ant Design 作为一门设计语言面世,经历过多年的迭代和积累,它对 UI 的设计思想已经成为一套事实标准,受到众多前端开发者及企业的追捧和喜爱,也是 React 开发者手中的神兵利器。希望 ant-design-vue 能够让 Vue 开发者也享受到 Ant Design 的优秀设计。 -ant-design-vue 是 Ant Design 的Vue实现,组件的风格与Ant Design保持同步,组件的html结构和css样式也保持一致,真正做到了样式0修改,组件API也尽量保持了一致。 +ant-design-vue 是 Ant Design 的 Vue 实现,组件的风格与 Ant Design 保持同步,组件的 html 结构和 css 样式也保持一致,真正做到了样式 0 修改,组件 API 也尽量保持了一致。 Ant Design Vue 致力于提供给程序员**愉悦**的开发体验。 ## 特别感谢 [Ant Design Team](https://github.com/ant-design/ant-design/blob/master/AUTHORS.txt) - diff --git a/docs/vue/sponsor.en-US.md b/docs/vue/sponsor.en-US.md index 02de87748..d4c18d3f6 100644 --- a/docs/vue/sponsor.en-US.md +++ b/docs/vue/sponsor.en-US.md @@ -5,6 +5,7 @@ ant-design-vue is an MIT licensed open source project and completely free to use ## One-time Donations We accept donations through these channels: +
PayPal
@@ -14,6 +15,7 @@ We accept donations through these channels: ## Recurring Pledges Recurring pledges come with exclusive perks, e.g. having your name listed in the Vue GitHub repository, or have your company logo placed on this website. +
Patreon
@@ -24,13 +26,12 @@ Recurring pledges come with exclusive perks, e.g. having your name listed in the You can consult me by email [415800467@qq.com](415800467@qq.com). - - ## Current sponsors ### Sponsors Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/ant-design-vue#sponsor)] +
diff --git a/docs/vue/sponsor.zh-CN.md b/docs/vue/sponsor.zh-CN.md index 9a09e8815..27bd84ab2 100644 --- a/docs/vue/sponsor.zh-CN.md +++ b/docs/vue/sponsor.zh-CN.md @@ -5,6 +5,7 @@ ant-design-vue 是采用 MIT 许可的开源项目,使用完全免费。 但 ## 一次性赞助 你可以通过以下任意一种方式赞助: +
PayPal
@@ -14,6 +15,7 @@ ant-design-vue 是采用 MIT 许可的开源项目,使用完全免费。 但 ## 周期性赞助 周期性赞助可以获得额外的回报,比如你的名字会出现在 Vue 的 GitHub 仓库中,再比如你的公司 logo 会出现在我们的官网上。 +
Patreon
@@ -24,8 +26,6 @@ ant-design-vue 是采用 MIT 许可的开源项目,使用完全免费。 但 您可以通过邮件咨询[415800467@qq.com](415800467@qq.com)。 - - ## 当前的赞助商 ### Sponsors diff --git a/docs/vue/use-with-vue-cli.en-US.md b/docs/vue/use-with-vue-cli.en-US.md index 161d474c5..6332ee37f 100644 --- a/docs/vue/use-with-vue-cli.en-US.md +++ b/docs/vue/use-with-vue-cli.en-US.md @@ -20,8 +20,7 @@ $ vue create antd-demo And, setup your vue project configuration. -The tool will create and initialize environment and dependencies automatically, -please try config your proxy setting or use another npm registry if any network errors happen during it. +The tool will create and initialize environment and dependencies automatically, please try config your proxy setting or use another npm registry if any network errors happen during it. Then we go inside `antd-demo` and start it. @@ -62,10 +61,10 @@ $ yarn add ant-design-vue Modify `src/main.js`, import Button component from `antd`. ```jsx -import Vue from "vue"; -import Button from "ant-design-vue/lib/button"; -import "ant-design-vue/dist/antd.css"; -import App from "./App"; +import Vue from 'vue'; +import Button from 'ant-design-vue/lib/button'; +import 'ant-design-vue/dist/antd.css'; +import App from './App'; Vue.component(Button.name, Button); @@ -73,9 +72,9 @@ Vue.config.productionTip = false; /* eslint-disable no-new */ new Vue({ - el: "#app", + el: '#app', components: { App }, - template: "" + template: '', }); ``` @@ -96,8 +95,7 @@ Ok, you should now see a blue primary button displayed on the page. Next you can ## Advanced Guides -We are successfully running antd components now but in the real world, there are still lots of problems about antd-demo. -For instance, we actually import all styles of components in the project which may be a network performance issue. +We are successfully running antd components now but in the real world, there are still lots of problems about antd-demo. For instance, we actually import all styles of components in the project which may be a network performance issue. Now we need to customize the default webpack config. diff --git a/docs/vue/use-with-vue-cli.zh-CN.md b/docs/vue/use-with-vue-cli.zh-CN.md index 7c6994b70..7fae3a306 100644 --- a/docs/vue/use-with-vue-cli.zh-CN.md +++ b/docs/vue/use-with-vue-cli.zh-CN.md @@ -61,18 +61,18 @@ $ yarn add ant-design-vue 修改 `src/main.js`,引入 antd 的按钮组件以及全部样式文件。 ```jsx -import Vue from "vue"; -import Button from "ant-design-vue/lib/button"; -import "ant-design-vue/dist/antd.css"; -import App from "./App"; +import Vue from 'vue'; +import Button from 'ant-design-vue/lib/button'; +import 'ant-design-vue/dist/antd.css'; +import App from './App'; Vue.component(Button.name, Button); Vue.config.productionTip = false; new Vue({ - render: h => h(App) -}).$mount("#app"); + render: h => h(App), +}).$mount('#app'); ``` 修改 `src/App.vue`的 template 内容。 diff --git a/package.json b/package.json index f97a18d0f..63d869883 100644 --- a/package.json +++ b/package.json @@ -54,10 +54,6 @@ "url": "https://github.com/vueComponent/ant-design-vue/issues" }, "homepage": "https://vue.ant.design/", - "pre-commit": [ - "lint", - "prettier" - ], "husky": { "hooks": { "pre-commit": "pretty-quick --staged" @@ -223,4 +219,4 @@ "lib/**/style/*", "*.less" ] -} \ No newline at end of file +} diff --git a/site/404.html b/site/404.html index 1ecc2dcaa..ad5c76db0 100644 --- a/site/404.html +++ b/site/404.html @@ -1,84 +1,86 @@ - + - - - - - - - - - + + + + + + + + Ant Design Vue - + - - + var hm = document.createElement('script'); + hm.src = src; + var s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(hm, s); + })(); + + - +
-
-
-

404

-

你要找的页面不存在返回首页

-
- -
+
+
+

404

+

你要找的页面不存在返回首页

+
+ +
- - + diff --git a/site/components/api.vue b/site/components/api.vue index 6333436d0..426f9d2eb 100644 --- a/site/components/api.vue +++ b/site/components/api.vue @@ -1,9 +1,6 @@ @@ -12,9 +9,9 @@ import { isZhCN } from '../util'; export default { name: 'Api', inject: { - demoContext: { default: {}}, + demoContext: { default: {} }, }, - data () { + data() { return { isZhCN: isZhCN(this.demoContext.name), }; diff --git a/site/components/demoBox.vue b/site/components/demoBox.vue index 891f441a4..dd80b537f 100644 --- a/site/components/demoBox.vue +++ b/site/components/demoBox.vue @@ -1,15 +1,9 @@