diff --git a/components/_util/styleChecker.js b/components/_util/styleChecker.js new file mode 100644 index 000000000..f54c1f7a9 --- /dev/null +++ b/components/_util/styleChecker.js @@ -0,0 +1,13 @@ +function isStyleSupport(styleName) { + if (typeof window !== 'undefined' && window.document && window.document.documentElement) { + const styleNameList = Array.isArray(styleName) ? styleName : [styleName]; + const { documentElement } = window.document; + + return styleNameList.some(name => name in documentElement.style); + } + return false; +} + +export const isFlexSupported = isStyleSupport(['flex', 'webkitFlex', 'Flex', 'msFlex']); + +export default isStyleSupport; diff --git a/components/config-provider/index.en-US.md b/components/config-provider/index.en-US.md index 52629e520..198948ae1 100644 --- a/components/config-provider/index.en-US.md +++ b/components/config-provider/index.en-US.md @@ -9,8 +9,23 @@ This component provides a configuration to all Vue components underneath itself ```` +### Content Security Policy + +Some component use dynamic style to support wave effect. You can config `csp` prop if Content Security Policy (CSP) is enabled: + +```html + + My Button + +``` + ## API | Property | Description | Type | Default | | -------- | ----------- | ---- | ------- | +| autoInsertSpaceInButton | Set `false` to remove space between 2 chinese characters on Button | boolean | true | +| csp | Set [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) config | { nonce: string } | - | +| renderEmpty | set empty content of components. Ref [Empty](/components/empty/) | slot-scope \| Function(componentName: string): ReactNode | - | | getPopupContainer | to set the container of the popup element. The default is to create a `div` element in `body`. | Function(triggerNode) | `() => document.body` | +| prefixCls | set prefix class | string | ant | + diff --git a/components/config-provider/index.zh-CN.md b/components/config-provider/index.zh-CN.md index 5beed7964..356ac386e 100644 --- a/components/config-provider/index.zh-CN.md +++ b/components/config-provider/index.zh-CN.md @@ -2,14 +2,31 @@ ConfigProvider 使用 Vue 的 [provide / inject](https://vuejs.org/v2/api/#provide-inject) 特性,只需在应用外围包裹一次即可全局生效。 + + + ````html ```` +### Content Security Policy + +部分组件为了支持波纹效果,使用了动态样式。如果开启了 Content Security Policy (CSP),你可以通过 `csp` 属性来进行配置: + +```html + + My Button + +``` + ## API | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | +| autoInsertSpaceInButton | 设置为 `false` 时,移除按钮中 2 个汉字之间的空格 | boolean | true | +| csp | 设置 [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) 配置 | { nonce: string } | - | +| renderEmpty | 自定义组件空状态。参考 [空状态](/components/empty/) | slot-scope \| Function(componentName: string): VNode | - | | getPopupContainer | 弹出框(Select, Tooltip, Menu 等等)渲染父节点,默认渲染到 body 上。 | Function(triggerNode) | () => document.body | +| prefixCls | 设置统一样式前缀 | string | ant | \ No newline at end of file diff --git a/components/config-provider/renderEmpty.jsx b/components/config-provider/renderEmpty.jsx index 61140ee9a..414fd24e8 100644 --- a/components/config-provider/renderEmpty.jsx +++ b/components/config-provider/renderEmpty.jsx @@ -1,7 +1,7 @@ import PropTypes from '../_util/vue-types'; import Empty from '../empty'; import emptyImg from './empty.svg'; -import { ConfigConsumerProps } from '.'; +import { ConfigConsumerProps } from './'; const RenderEmpty = { functional: true,