diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 135820499..3f49287fe 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -41,16 +41,15 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 - with: - token: ${{ secrets.ACCESS_TOKEN }} - - - name: Checkout submodules - uses: actions/checkout@v2 - with: - repository: tangjinzhou/antdv-demo - token: ${{ secrets.ACCESS_TOKEN }} - path: antdv-demo - submodules: true + # with: + # token: ${{ secrets.ACCESS_TOKEN }} + # - name: Checkout submodules + # uses: actions/checkout@v2 + # with: + # repository: tangjinzhou/antdv-demo + # token: ${{ secrets.ACCESS_TOKEN }} + # path: antdv-demo + # submodules: true - name: restore cache from package-lock.json uses: actions/cache@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c67b8bf2..262dfb2ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -97,16 +97,16 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 - with: - token: ${{ secrets.ACCESS_TOKEN }} - - name: Checkout submodules - uses: actions/checkout@v2 - with: - repository: tangjinzhou/antdv-demo - token: ${{ secrets.ACCESS_TOKEN }} - path: antdv-demo - submodules: true + # with: + # token: ${{ secrets.ACCESS_TOKEN }} + # - name: Checkout submodules + # uses: actions/checkout@v2 + # with: + # repository: tangjinzhou/antdv-demo + # token: ${{ secrets.ACCESS_TOKEN }} + # path: antdv-demo + # submodules: true - name: restore cache from package-lock.json uses: actions/cache@v1 diff --git a/.jest.js b/.jest.js index a1dd53c46..d35db6229 100644 --- a/.jest.js +++ b/.jest.js @@ -6,13 +6,16 @@ const transformIgnorePatterns = [ // Update: @babel/runtime should also be transformed 'node_modules/(?!.*(@babel|lodash-es))[^/]+?/(?!(es|node_modules)/)', ]; - +const testPathIgnorePatterns = ['/node_modules/', 'node']; +if (process.env.WORKFLOW === 'true') { + testPathIgnorePatterns.push('demo\\.test*'); +} module.exports = { testURL: 'http://localhost/', setupFiles: ['./tests/setup.js'], moduleFileExtensions: ['js', 'jsx', 'json', 'vue', 'md', 'jpg'], modulePathIgnorePatterns: ['/_site/'], - testPathIgnorePatterns: ['/node_modules/', 'node'], + testPathIgnorePatterns: testPathIgnorePatterns, transform: { '^.+\\.(vue|md)$': '/node_modules/vue-jest', '^.+\\.(js|jsx)$': '/node_modules/babel-jest', diff --git a/antdv-demo b/antdv-demo index cd4d03a89..05da262e3 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit cd4d03a897a0ab0224f4a631481e73cb05540f4a +Subproject commit 05da262e31f9c6cc524154df13f5e2b05c20c1c8 diff --git a/babel.config.js b/babel.config.js index 58c70b70a..10f5a0440 100644 --- a/babel.config.js +++ b/babel.config.js @@ -3,7 +3,7 @@ module.exports = { test: { presets: [['@babel/preset-env', { targets: { node: true } }]], plugins: [ - ['@vue/babel-plugin-jsx'], + '@vue/babel-plugin-jsx', '@babel/plugin-proposal-optional-chaining', '@babel/plugin-transform-object-assign', '@babel/plugin-proposal-object-rest-spread', diff --git a/components/_util/PortalWrapper.ts b/components/_util/PortalWrapper.ts index 84170c206..2ae3f6b29 100644 --- a/components/_util/PortalWrapper.ts +++ b/components/_util/PortalWrapper.ts @@ -2,7 +2,6 @@ import PropTypes from './vue-types'; import switchScrollingEffect from './switchScrollingEffect'; import setStyle from './setStyle'; import Portal from './Portal'; -import syncWatch from './syncWatch'; let openCount = 0; const windowIsUndefined = !( @@ -33,9 +32,9 @@ export default { this.setWrapperClassName(); }, watch: { - visible: syncWatch(function(val) { + visible(val) { openCount = val ? openCount + 1 : openCount - 1; - }), + }, getContainer(getContainer, prevGetContainer) { const getContainerIsFunc = typeof getContainer === 'function' && typeof prevGetContainer === 'function'; diff --git a/components/_util/antInputDirective.ts b/components/_util/antInputDirective.ts index f07fd01ab..c8ccf2d58 100644 --- a/components/_util/antInputDirective.ts +++ b/components/_util/antInputDirective.ts @@ -1,21 +1,3 @@ -/** - * Not type checking this file because flow doesn't like attaching - * properties to Elements. - */ - -export const inBrowser = typeof window !== 'undefined'; -export const UA = inBrowser && window.navigator.userAgent.toLowerCase(); -export const isIE9 = UA && UA.indexOf('msie 9.0') > 0; -function makeMap(str, expectsLowerCase) { - const map = Object.create(null); - const list = str.split(','); - for (let i = 0; i < list.length; i++) { - map[list[i]] = true; - } - return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val]; -} -const isTextInputType = makeMap('text,number,password,search,email,tel,url'); - function onCompositionStart(e) { e.target.composing = true; } @@ -33,40 +15,21 @@ function trigger(el, type) { el.dispatchEvent(e); } -/* istanbul ignore if */ -if (isIE9) { - // http://www.matts411.com/post/internet-explorer-9-oninput/ - document.addEventListener('selectionchange', () => { - const el = document.activeElement; - if (el && el.vmodel) { - trigger(el, 'input'); - } - }); +export function addEventListener(el, event, handler, options) { + el.addEventListener(event, handler, options); } - -export const antInput = { - mounted(el, binding, vnode) { - if (vnode.type === 'textarea' || isTextInputType(el.type)) { - if (!binding.modifiers || !binding.modifiers.lazy) { - el.addEventListener('compositionstart', onCompositionStart); - el.addEventListener('compositionend', onCompositionEnd); - // Safari < 10.2 & UIWebView doesn't fire compositionend when - // switching focus before confirming composition choice - // this also fixes the issue where some browsers e.g. iOS Chrome - // fires "change" instead of "input" on autocomplete. - el.addEventListener('change', onCompositionEnd); - /* istanbul ignore if */ - if (isIE9) { - el.vmodel = true; - } - } +const antInput = { + created(el, binding) { + if (!binding.modifiers || !binding.modifiers.lazy) { + addEventListener(el, 'compositionstart', onCompositionStart); + addEventListener(el, 'compositionend', onCompositionEnd); + // Safari < 10.2 & UIWebView doesn't fire compositionend when + // switching focus before confirming composition choice + // this also fixes the issue where some browsers e.g. iOS Chrome + // fires "change" instead of "input" on autocomplete. + addEventListener(el, 'change', onCompositionEnd); } }, }; -export default { - install: app => { - antInput(app); - app.directive('ant-input', antInput); - }, -}; +export default antInput; diff --git a/components/_util/getTransitionProps.ts b/components/_util/getTransitionProps.ts index 6481bf4d1..e0b79623c 100644 --- a/components/_util/getTransitionProps.ts +++ b/components/_util/getTransitionProps.ts @@ -1,5 +1,8 @@ import animate from './css-animation'; const getTransitionProps = (transitionName, opt = {}) => { + if (process.env.NODE_ENV === 'test') { + return { css: false, ...opt }; + } const transitionProps = { appear: true, css: false, diff --git a/components/alert/__tests__/__snapshots__/demo.test.js.snap b/components/alert/__tests__/__snapshots__/demo.test.js.snap index 0ddccef29..62ac9a025 100644 --- a/components/alert/__tests__/__snapshots__/demo.test.js.snap +++ b/components/alert/__tests__/__snapshots__/demo.test.js.snap @@ -99,7 +99,7 @@ exports[`renders ./antdv-demo/docs/alert/demo/icon.md correctly 1`] = `
Error
-
Success TipsDetailed description and advices about successful copywriting. +
Success TipsDetailed description and advices about successful copywriting.
Informational NotesAdditional description and informations about copywriting. diff --git a/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap b/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap index cf32af5e8..dca2b54df 100644 --- a/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap +++ b/components/auto-complete/__tests__/__snapshots__/demo.test.js.snap @@ -12,7 +12,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/basic.md correctly 1`] = `
- +
`; @@ -30,7 +30,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/certain-category.md correc - + @@ -44,11 +44,11 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/custom.md correctly 1`] = - + `; @@ -65,7 +65,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/non-case-sensitive.md corr - + `; @@ -82,7 +82,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/options.md correctly 1`] = - + `; @@ -100,7 +100,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/uncertain-category.md corr - + diff --git a/components/badge/ScrollNumber.jsx b/components/badge/ScrollNumber.jsx index f91f71d99..4fbcde2e2 100644 --- a/components/badge/ScrollNumber.jsx +++ b/components/badge/ScrollNumber.jsx @@ -5,7 +5,6 @@ import omit from 'omit.js'; import { cloneElement } from '../_util/vnode'; import { ConfigConsumerProps } from '../config-provider'; import { inject } from 'vue'; -import syncWatch from '../_util/syncWatch'; function getNumberArray(num) { return num @@ -47,12 +46,12 @@ export default { }; }, watch: { - count: syncWatch(function() { + count() { this.lastCount = this.sCount; this.setState({ animateStarted: true, }); - }), + }, }, updated() { const { animateStarted, count } = this; diff --git a/components/badge/__tests__/__snapshots__/index.test.js.snap b/components/badge/__tests__/__snapshots__/index.test.js.snap index 0274af1fb..db5754c14 100644 --- a/components/badge/__tests__/__snapshots__/index.test.js.snap +++ b/components/badge/__tests__/__snapshots__/index.test.js.snap @@ -42,7 +42,7 @@ exports[`Badge should render when count is changed 5`] = ` `; exports[`Badge should support offset when count is a VueNode 1`] = ` -head +head `; diff --git a/components/calendar/__tests__/__snapshots__/demo.test.js.snap b/components/calendar/__tests__/__snapshots__/demo.test.js.snap index 3e1a066d4..aac3bde42 100644 --- a/components/calendar/__tests__/__snapshots__/demo.test.js.snap +++ b/components/calendar/__tests__/__snapshots__/demo.test.js.snap @@ -10,7 +10,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/basic.md correctly 1`] = `
2016
- + @@ -20,7 +20,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/basic.md correctly 1`] = `
Nov
- +
@@ -414,7 +414,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/card.md correctly 1`] = `
2016
- + @@ -424,7 +424,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/card.md correctly 1`] = `
Nov
- +
@@ -825,7 +825,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/customize-header.md correctly 1
2016
- + @@ -837,7 +837,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/customize-header.md correctly 1
Nov
- + @@ -1232,7 +1232,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/notice-calendar.md correctly 1`
2016
- + @@ -1242,7 +1242,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/notice-calendar.md correctly 1`
Nov
- +
@@ -1647,7 +1647,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/notice-calendar.md correctly 1` `; exports[`renders ./antdv-demo/docs/calendar/demo/select.md correctly 1`] = ` -
+
You selected date: 2017-01-25
@@ -1661,7 +1661,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/select.md correctly 1`] = `
2017
- + @@ -1671,7 +1671,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/select.md correctly 1`] = `
Jan
- +
@@ -2063,7 +2063,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/select.md correctly 1`] = `
2016
- + @@ -2073,7 +2073,7 @@ exports[`renders ./antdv-demo/docs/calendar/demo/select.md correctly 1`] = `
Nov
- +
diff --git a/components/calendar/__tests__/__snapshots__/index.test.js.snap b/components/calendar/__tests__/__snapshots__/index.test.js.snap index e5c7415b6..b36454cf8 100644 --- a/components/calendar/__tests__/__snapshots__/index.test.js.snap +++ b/components/calendar/__tests__/__snapshots__/index.test.js.snap @@ -10,7 +10,7 @@ exports[`Calendar Calendar should support locale 1`] = `
2018年
- + @@ -20,7 +20,7 @@ exports[`Calendar Calendar should support locale 1`] = `
Oct
- +
diff --git a/components/carousel/__tests__/__snapshots__/demo.test.js.snap b/components/carousel/__tests__/__snapshots__/demo.test.js.snap index d2b9470a9..92b958e1f 100644 --- a/components/carousel/__tests__/__snapshots__/demo.test.js.snap +++ b/components/carousel/__tests__/__snapshots__/demo.test.js.snap @@ -248,7 +248,7 @@ exports[`renders ./antdv-demo/docs/carousel/demo/customArrows.md correctly 1`] = exports[`renders ./antdv-demo/docs/carousel/demo/customPaging.md correctly 1`] = ` - + `; diff --git a/components/date-picker/__tests__/other.test.js b/components/date-picker/__tests__/other.test.js index 260fe85bb..0d8e5f6a3 100644 --- a/components/date-picker/__tests__/other.test.js +++ b/components/date-picker/__tests__/other.test.js @@ -72,6 +72,6 @@ describe('MonthPicker and WeekPicker', () => { await sleep(50); await asyncExpect(() => { expect(document.body.innerHTML).toMatchSnapshot(); - }); + }, 0); }); }); diff --git a/components/empty/__tests__/__snapshots__/demo.test.js.snap b/components/empty/__tests__/__snapshots__/demo.test.js.snap index 8a01c712a..c8ad0a5a7 100644 --- a/components/empty/__tests__/__snapshots__/demo.test.js.snap +++ b/components/empty/__tests__/__snapshots__/demo.test.js.snap @@ -39,7 +39,7 @@ exports[`renders ./antdv-demo/docs/empty/demo/config-provider.md correctly 1`] = - +

TreeSelect

diff --git a/components/form/__tests__/__snapshots__/demo.test.js.snap b/components/form/__tests__/__snapshots__/demo.test.js.snap index 845ffd75d..3f08020f8 100644 --- a/components/form/__tests__/__snapshots__/demo.test.js.snap +++ b/components/form/__tests__/__snapshots__/demo.test.js.snap @@ -14,7 +14,7 @@ exports[`renders ./antdv-demo/docs/form/demo/basic.md correctly 1`] = `
-
+
@@ -232,6 +232,168 @@ exports[`renders ./antdv-demo/docs/form/demo/layout.md correctly 1`] = ` `; +exports[`renders ./antdv-demo/docs/form/demo/useForm-basic.md correctly 1`] = ` +
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+`; + +exports[`renders ./antdv-demo/docs/form/demo/useForm-merge.md correctly 1`] = ` +
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+`; + +exports[`renders ./antdv-demo/docs/form/demo/useForm-nested.md correctly 1`] = ` +
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+`; + +exports[`renders ./antdv-demo/docs/form/demo/useForm-trigger.md correctly 1`] = ` +
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+`; + exports[`renders ./antdv-demo/docs/form/demo/validation.md correctly 1`] = `
@@ -246,7 +408,7 @@ exports[`renders ./antdv-demo/docs/form/demo/validation.md correctly 1`] = `
-
+
diff --git a/components/input/Input.jsx b/components/input/Input.jsx index 1dc080a69..8c6a24700 100644 --- a/components/input/Input.jsx +++ b/components/input/Input.jsx @@ -1,11 +1,11 @@ -import { inject } from 'vue'; +import { inject, withDirectives } from 'vue'; +import antInputDirective from '../_util/antInputDirective'; import classNames from '../_util/classNames'; import omit from 'omit.js'; import inputProps from './inputProps'; import { hasProp, getComponent, getOptionProps } from '../_util/props-util'; import { ConfigConsumerProps } from '../config-provider'; import ClearableLabeledInput from './ClearableLabeledInput'; -import syncWatch from '../_util/syncWatch'; export function fixControlledValue(value) { if (typeof value === 'undefined' || value === null) { @@ -67,9 +67,9 @@ export default { }; }, watch: { - value: syncWatch(function(val) { + value(val) { this.stateValue = val; - }), + }, }, mounted() { this.$nextTick(() => { @@ -164,7 +164,7 @@ export default { if (!inputProps.autofocus) { delete inputProps.autofocus; } - return ; + return withDirectives(, [[antInputDirective]]); }, clearPasswordValueAttribute() { // https://github.com/ant-design/ant-design/issues/20541 diff --git a/components/input/ResizableTextArea.jsx b/components/input/ResizableTextArea.jsx index 369d603d3..b62e7d21e 100644 --- a/components/input/ResizableTextArea.jsx +++ b/components/input/ResizableTextArea.jsx @@ -8,7 +8,8 @@ import BaseMixin from '../_util/BaseMixin'; import inputProps from './inputProps'; import PropTypes from '../_util/vue-types'; import { getOptionProps } from '../_util/props-util'; -import syncWatch from '../_util/syncWatch'; +import { withDirectives } from 'vue'; +import antInput from '../_util/antInputDirective'; const RESIZE_STATUS_NONE = 0; const RESIZE_STATUS_RESIZING = 1; @@ -39,11 +40,11 @@ const ResizableTextArea = { raf.cancel(this.resizeFrameId); }, watch: { - value: syncWatch(function() { + value() { this.$nextTick(() => { this.resizeTextarea(); }); - }), + }, }, methods: { saveTextArea(textArea) { @@ -140,7 +141,7 @@ const ResizableTextArea = { } return ( -