Wei Zhu
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with
28 additions and
22 deletions
-
components/calendar/index.tsx
-
components/date-picker/__tests__/MonthPicker.test.js
-
components/date-picker/__tests__/RangePicker.test.js
-
components/date-picker/__tests__/WeekPicker.test.js
-
components/date-picker/__tests__/other.test.js
-
components/date-picker/__tests__/showTime.test.js
-
components/date-picker/wrapPicker.tsx
-
index-with-locales.js
-
package.json
-
site/bisheng.config.js
-
tests/shared/demoTest.js
|
|
@ -6,8 +6,7 @@ import LocaleReceiver from '../locale-provider/LocaleReceiver'; |
|
|
|
import { PREFIX_CLS } from './Constants'; |
|
|
|
import Header from './Header'; |
|
|
|
import callMoment from '../_util/callMoment'; |
|
|
|
|
|
|
|
declare const require: Function; |
|
|
|
import enUS from './locale/en_US'; |
|
|
|
|
|
|
|
export { HeaderProps } from './Header'; |
|
|
|
|
|
|
@ -122,11 +121,6 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
getDefaultLocale() { |
|
|
|
const locale = require('./locale/en_US'); |
|
|
|
return locale.default || locale; |
|
|
|
} |
|
|
|
|
|
|
|
setValue = (value: moment.Moment, way: 'select' | 'changePanel') => { |
|
|
|
if (!('value' in this.props)) { |
|
|
|
this.setState({ value }); |
|
|
@ -215,7 +209,7 @@ export default class Calendar extends React.Component<CalendarProps, CalendarSta |
|
|
|
return ( |
|
|
|
<LocaleReceiver |
|
|
|
componentName="Calendar" |
|
|
|
defaultLocale={this.getDefaultLocale} |
|
|
|
defaultLocale={enUS} |
|
|
|
> |
|
|
|
{this.renderCalendar} |
|
|
|
</LocaleReceiver> |
|
|
|
|
|
@ -1,6 +1,8 @@ |
|
|
|
import { MonthPicker } from '..'; |
|
|
|
import DatePicker from '..'; |
|
|
|
import focusTest from '../../../tests/shared/focusTest'; |
|
|
|
|
|
|
|
const { MonthPicker } = DatePicker; |
|
|
|
|
|
|
|
describe('MonthPicker', () => { |
|
|
|
focusTest(MonthPicker); |
|
|
|
}); |
|
|
|
|
|
@ -1,9 +1,11 @@ |
|
|
|
import React from 'react'; |
|
|
|
import { mount, render } from 'enzyme'; |
|
|
|
import moment from 'moment'; |
|
|
|
import { RangePicker } from '../'; |
|
|
|
import DatePicker from '../'; |
|
|
|
import focusTest from '../../../tests/shared/focusTest'; |
|
|
|
|
|
|
|
const { RangePicker } = DatePicker; |
|
|
|
|
|
|
|
describe('RangePicker', () => { |
|
|
|
focusTest(RangePicker); |
|
|
|
|
|
|
|
|
|
@ -1,6 +1,8 @@ |
|
|
|
import { WeekPicker } from '..'; |
|
|
|
import DatePicker from '..'; |
|
|
|
import focusTest from '../../../tests/shared/focusTest'; |
|
|
|
|
|
|
|
const { WeekPicker } = DatePicker; |
|
|
|
|
|
|
|
describe('WeekPicker', () => { |
|
|
|
focusTest(WeekPicker); |
|
|
|
}); |
|
|
|
|
|
@ -1,7 +1,9 @@ |
|
|
|
import React from 'react'; |
|
|
|
import { mount, render } from 'enzyme'; |
|
|
|
import moment from 'moment'; |
|
|
|
import { MonthPicker, WeekPicker } from '../'; |
|
|
|
import DatePicker from '../'; |
|
|
|
|
|
|
|
const { MonthPicker, WeekPicker } = DatePicker; |
|
|
|
|
|
|
|
describe('MonthPicker and WeekPicker', () => { |
|
|
|
it('render MonthPicker', () => { |
|
|
|
|
|
@ -1,6 +1,8 @@ |
|
|
|
import React from 'react'; |
|
|
|
import { mount } from 'enzyme'; |
|
|
|
import DatePicker, { RangePicker } from '../'; |
|
|
|
import DatePicker from '../'; |
|
|
|
|
|
|
|
const { RangePicker } = DatePicker; |
|
|
|
|
|
|
|
describe('DatePicker with showTime', () => { |
|
|
|
it('should trigger onChange when select value', () => { |
|
|
|
|
|
@ -3,8 +3,7 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel'; |
|
|
|
import classNames from 'classnames'; |
|
|
|
import LocaleReceiver from '../locale-provider/LocaleReceiver'; |
|
|
|
import { generateShowHourMinuteSecond } from '../time-picker'; |
|
|
|
|
|
|
|
declare const require: Function; |
|
|
|
import enUS from './locale/en_US'; |
|
|
|
|
|
|
|
function getColumns({ showHour, showMinute, showSecond, use12Hours }: any) { |
|
|
|
let column = 0; |
|
|
@ -81,10 +80,8 @@ export default function wrapPicker(Picker: React.ComponentClass<any>, defaultFor |
|
|
|
} |
|
|
|
|
|
|
|
getDefaultLocale = () => { |
|
|
|
const locale = require('./locale/en_US'); |
|
|
|
const defaultlocale = (locale.default || locale); |
|
|
|
const result = { |
|
|
|
...defaultlocale, |
|
|
|
...enUS, |
|
|
|
...this.props.locale, |
|
|
|
}; |
|
|
|
result.lang = { |
|
|
|
|
|
@ -5,7 +5,7 @@ antd.locales = {}; |
|
|
|
|
|
|
|
req.keys().forEach((mod) => { |
|
|
|
const match = mod.match(/\/([^/]+).tsx$/); |
|
|
|
antd.locales[match[1]] = req(mod); |
|
|
|
antd.locales[match[1]] = req(mod).default; |
|
|
|
}); |
|
|
|
|
|
|
|
module.exports = antd; |
|
|
|
|
|
@ -87,7 +87,7 @@ |
|
|
|
"@types/react": "^16.0.0", |
|
|
|
"@types/react-dom": "^16.0.0", |
|
|
|
"ansi-styles": "^3.2.0", |
|
|
|
"antd-tools": "^4.0.6", |
|
|
|
"antd-tools": "^5.0.0", |
|
|
|
"babel-cli": "^6.18.0", |
|
|
|
"babel-eslint": "^8.1.1", |
|
|
|
"babel-plugin-import": "^1.0.0", |
|
|
|
|
|
@ -8,7 +8,12 @@ const usePreact = process.env.REACT_ENV === 'preact'; |
|
|
|
function alertBabelConfig(rules) { |
|
|
|
rules.forEach((rule) => { |
|
|
|
if (rule.loader && rule.loader === 'babel-loader') { |
|
|
|
rule.options.plugins.push(replaceLib); |
|
|
|
if (rule.options.plugins.indexOf(replaceLib) === -1) { |
|
|
|
rule.options.plugins.push(replaceLib); |
|
|
|
} |
|
|
|
rule.options.plugins = rule.options.plugins.filter(plugin => |
|
|
|
!plugin.indexOf || plugin.indexOf('babel-plugin-add-module-exports') === -1 |
|
|
|
); |
|
|
|
} else if (rule.use) { |
|
|
|
alertBabelConfig(rule.use); |
|
|
|
} |
|
|
|
|
|
@ -12,7 +12,7 @@ export default function demoTest(component, options = {}) { |
|
|
|
} |
|
|
|
testMethod(`renders ${file} correctly`, () => { |
|
|
|
MockDate.set(new Date('2016-11-22').getTime() + (new Date().getTimezoneOffset() * 60 * 1000)); |
|
|
|
const demo = require(`../.${file}`); // eslint-disable-line global-require, import/no-dynamic-require
|
|
|
|
const demo = require(`../.${file}`).default; // eslint-disable-line global-require, import/no-dynamic-require
|
|
|
|
const wrapper = render(demo); |
|
|
|
expect(wrapper).toMatchSnapshot(); |
|
|
|
MockDate.reset(); |
|
|
|