diff --git a/components/util/isCssAnimationSupported.js b/components/_util/isCssAnimationSupported.js similarity index 100% rename from components/util/isCssAnimationSupported.js rename to components/_util/isCssAnimationSupported.js diff --git a/components/util/openAnimation.js b/components/_util/openAnimation.js similarity index 100% rename from components/util/openAnimation.js rename to components/_util/openAnimation.js diff --git a/components/badge/ScrollNumber.jsx b/components/badge/ScrollNumber.jsx index 59034fcbba..0b4d2ea29f 100644 --- a/components/badge/ScrollNumber.jsx +++ b/components/badge/ScrollNumber.jsx @@ -1,6 +1,6 @@ import React, { createElement } from 'react'; import { findDOMNode } from 'react-dom'; -import isCssAnimationSupported from '../util/isCssAnimationSupported'; +import isCssAnimationSupported from '../_util/isCssAnimationSupported'; function getNumberArray(num) { return num ? diff --git a/components/menu/index.jsx b/components/menu/index.jsx index 74c2b6d0a6..b4c7c65bd1 100644 --- a/components/menu/index.jsx +++ b/components/menu/index.jsx @@ -1,6 +1,6 @@ import React from 'react'; import RcMenu, { Item, Divider, SubMenu, ItemGroup } from 'rc-menu'; -import animation from '../util/openAnimation'; +import animation from '../_util/openAnimation'; function noop() { } diff --git a/components/spin/index.jsx b/components/spin/index.jsx index e1148da259..e41bb76611 100644 --- a/components/spin/index.jsx +++ b/components/spin/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { findDOMNode } from 'react-dom'; import classNames from 'classnames'; -import isCssAnimationSupported from '../util/isCssAnimationSupported'; +import isCssAnimationSupported from '../_util/isCssAnimationSupported'; import warning from 'warning'; export default class Spin extends React.Component { diff --git a/components/tree/index.jsx b/components/tree/index.jsx index ad4b69674f..b0dddf49fb 100644 --- a/components/tree/index.jsx +++ b/components/tree/index.jsx @@ -1,6 +1,6 @@ import React from 'react'; import RcTree from 'rc-tree'; -import animation from '../util/openAnimation'; +import animation from '../_util/openAnimation'; export default class Tree extends React.Component { static TreeNode = RcTree.TreeNode; diff --git a/index.js b/index.js index 2aff55a107..771609e87f 100644 --- a/index.js +++ b/index.js @@ -1,22 +1,22 @@ /* eslint no-console:0 */ // this file is not used if use https://github.com/ant-design/babel-plugin-antd -import { - Rate, Affix, DatePicker, Tooltip, Tag, Carousel, Tabs, Modal, Dropdown, Progress, Popover, Select, - Breadcrumb, Popconfirm, Pagination, Steps, InputNumber, Switch, Checkbox, Table, Collapse, message, - Slider, QueueAnim, Radio, notification, Alert, Validation, Tree, TreeSelect, Upload, - Badge, Menu, Timeline, Button, Icon, Row, Col, Spin, Form, Input, Calendar, TimePicker, - Card, LocaleProvider, Transfer, Cascader, -} from 'antd'; +function camelCase(name) { + return name.charAt(0).toUpperCase() + + name.slice(1).replace(/-(\w)/g, (m, n) => { + return n.toUpperCase(); + }); +} -// copy from above -export { - Rate, Affix, DatePicker, Tooltip, Tag, Carousel, Tabs, Modal, Dropdown, Progress, Popover, Select, - Breadcrumb, Popconfirm, Pagination, Steps, InputNumber, Switch, Checkbox, Table, Collapse, message, - Slider, QueueAnim, Radio, notification, Alert, Validation, Tree, TreeSelect, Upload, - Badge, Menu, Timeline, Button, Icon, Row, Col, Spin, Form, Input, Calendar, TimePicker, - Card, LocaleProvider, Transfer, Cascader, -}; +const req = require.context('./components', true, /^\.\/[^_][\w-]+\/(style\/)?index\.jsx?$/); + +req.keys().forEach((mod) => { + const v = req(mod); + const match = mod.match(/^\.\/([^_][\w-]+)\/index\.jsx?$/); + if (match && match[1]) { + exports[camelCase(match[1])] = v; + } +}); if (process.env.NODE_ENV !== 'production') { if (typeof console !== 'undefined' && console.warn) { diff --git a/site/theme/template/Layout/index.jsx b/site/theme/template/Layout/index.jsx index 57facb48bb..ee29d6b8b7 100644 --- a/site/theme/template/Layout/index.jsx +++ b/site/theme/template/Layout/index.jsx @@ -1,5 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; +import * as antd from '../../../../index'; import { addLocaleData, IntlProvider } from 'react-intl'; import Header from './Header'; import Footer from './Footer'; @@ -10,7 +11,7 @@ import '../../static/style'; // Expose to iframe window.react = React; window['react-dom'] = ReactDOM; -window.antd = require('antd'); +window.antd = antd; // Enable Google Analytics if (!location.port) {