diff --git a/.dumirc.ts b/.dumirc.ts index bd80941..d8e2b76 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,23 +1,12 @@ import { defineConfig } from 'dumi'; -import path from 'path'; export default defineConfig({ - alias: { - 'rc-trigger$': path.resolve('src'), - 'rc-trigger/es': path.resolve('src'), - }, mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], themeConfig: { - name: 'Trigger', + name: 'cssinjs-util', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, - styles: [ - ` - .dumi-default-previewer-demo { - position: relative; - min-height: 300px; - } - `, - ] }); + + diff --git a/.fatherrc.js b/.fatherrc.js index 4ddbafd..96268ae 100644 --- a/.fatherrc.js +++ b/.fatherrc.js @@ -2,4 +2,4 @@ import { defineConfig } from 'father'; export default defineConfig({ plugins: ['@rc-component/father-plugin'], -}); \ No newline at end of file +}); diff --git a/.gitignore b/.gitignore index 65899cf..009d7ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ +~* .storybook *.iml *.log -.idea +.idea/ .ipr .iws *~ @@ -13,28 +14,31 @@ Thumbs.db .project .*proj -.svn +.svn/ *.swp *.swo *.pyc *.pyo +.build node_modules .cache -*.css +assets/**/*.css build lib es -coverage +dist yarn.lock package-lock.json +coverage/ +.doc -# dumi +# umi .umi .umi-production .umi-test -.docs - +.env.local # dumi .dumi/tmp -.dumi/tmp-production \ No newline at end of file +.dumi/tmp-production +.dumi/tmp-test diff --git a/HISTORY.md b/HISTORY.md index 7ee63c8..ab24a71 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,58 +1,2 @@ # History ---- - -## 4.1.0 / 2020-05-08 - -- upgrade rc-animate to `3.x` - -## 2.5.0 / 2018-06-05 - -- support `alignPoint` - -## 2.1.0 / 2017-10-16 - -- add action `contextMenu` - -## 2.0.0 / 2017-09-25 - -- support React 16 - -## 1.11.0 / 2017-06-07 - -- add es - -## 1.9.0 / 2017-02-27 - -- add getDocument prop - -## 1.8.2 / 2017-02-24 - -- change default container to absolute to fix scrollbar change problem - -## 1.7.0 / 2016-07-18 - -- use getContainerRenderMixin from 'rc-util' - -## 1.6.0 / 2016-05-26 - -- support popup as function - -## 1.5.0 / 2016-05-26 - -- add forcePopupAlign method - -## 1.4.0 / 2016-04-06 - -- support onPopupAlign - -## 1.3.0 / 2016-03-25 - -- support mask/maskTransitionName/zIndex - -## 1.2.0 / 2016-03-01 - -- add showAction/hideAction - -## 1.1.0 / 2016-01-06 - -- add root trigger node as parameter of getPopupContainer diff --git a/README.md b/README.md index e479e56..26eeed6 100644 --- a/README.md +++ b/README.md @@ -1,258 +1,30 @@ -# @rc-component/trigger - -React Trigger Component - -[![NPM version][npm-image]][npm-url] -[![npm download][download-image]][download-url] -[![build status][github-actions-image]][github-actions-url] -[![Test coverage][codecov-image]][codecov-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] - -[npm-image]: http://img.shields.io/npm/v/rc-checkbox.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-checkbox -[github-actions-image]: https://github.com/react-component/checkbox/workflows/CI/badge.svg -[github-actions-url]: https://github.com/react-component/checkbox/actions -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/checkbox/master.svg?style=flat-square -[codecov-url]: https://codecov.io/gh/react-component/checkbox/branch/master -[david-url]: https://david-dm.org/react-component/checkbox -[david-image]: https://david-dm.org/react-component/checkbox/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/checkbox?type=dev -[david-dev-image]: https://david-dm.org/react-component/checkbox/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/rc-checkbox.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-checkbox -[bundlephobia-url]: https://bundlephobia.com/result?p=rc-checkbox -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-checkbox -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -[dumi-url]: https://github.com/umijs/dumi +# @ant-design/cssinjs-util +A cssinjs util library to support Ant Design (antd) and its ecosystem libraries. ## Install - -[![@rc-component/trigger](https://nodei.co/npm/@rc-component/trigger.png)](https://npmjs.org/package/@rc-component/trigger) - -## Usage - -Include the default [styling](https://github.com/react-component/trigger/blob/master/assets/index.less#L4:L11) and then: - -```js -import React from 'react'; -import ReactDOM from 'react-dom'; -import Trigger from '@rc-component/trigger'; - -ReactDOM.render(( - popup} - popupAlign={{ - points: ['tl', 'bl'], - offset: [0, 3] - }} - > - hover - -), container); +``` bash +npm i @ant-design/cssinjs-util --save ``` -## Compatibility - -| [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | -| --- | --- | --- | --- | --- | -| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +## Usage ## Example - -http://localhost:9001 +http://localhost:8000 ## Development - -``` +``` bash npm install npm start ``` ## API -### props - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nametypedefaultdescription
alignPointboolfalsePopup will align with mouse position (support action of 'click', 'hover' and 'contextMenu')
popupClassNamestringadditional className added to popup
forceRenderbooleanfalsewhether render popup before first show
destroyPopupOnHidebooleanfalsewhether destroy popup when hide
getPopupClassNameFromAligngetPopupClassNameFromAlign(align: Object):Stringadditional className added to popup according to align
actionstring[]['hover']which actions cause popup shown. enum of 'hover','click','focus','contextMenu'
mouseEnterDelaynumber0delay time to show when mouse enter. unit: s.
mouseLeaveDelaynumber0.1delay time to hide when mouse leave. unit: s.
popupStyleObjectadditional style of popup
prefixClsStringrc-trigger-popupprefix class name
popupTransitionNameString|Objecthttps://github.com/react-component/animate
maskTransitionNameString|Objecthttps://github.com/react-component/animate
onPopupVisibleChangeFunctioncall when popup visible is changed
maskbooleanfalsewhether to support mask
maskClosablebooleantruewhether to support click mask to hide
popupVisiblebooleanwhether popup is visible
zIndexnumberpopup's zIndex
defaultPopupVisiblebooleanwhether popup is visible initially
popupAlignObject: alignConfig of [dom-align](https://github.com/yiminghe/dom-align)popup 's align config
onPopupAlignfunction(popupDomNode, align)callback when popup node is aligned
popupReact.Element | function() => React.Elementpopup content
getPopupContainergetPopupContainer(): HTMLElementfunction returning html node which will act as popup container
getDocumentgetDocument(): HTMLElementfunction returning document node which will be attached click event to close trigger
popupPlacementstringuse preset popup align config from builtinPlacements, can be merged by popupAlign prop
builtinPlacementsobjectbuiltin placement align map. used by placement prop
stretchstringLet popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')
- - ## Test Case - ``` npm test npm run coverage ``` - open coverage/ dir ## License - -rc-trigger is released under the MIT license. +cssinjs-util is released under the MIT license. diff --git a/assets/.gitkeep b/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/assets/index.less b/assets/index.less deleted file mode 100644 index e13a125..0000000 --- a/assets/index.less +++ /dev/null @@ -1,79 +0,0 @@ -@triggerPrefixCls: rc-trigger-popup; - -.@{triggerPrefixCls} { - position: absolute; - top: -9999px; - left: -9999px; - z-index: 1050; - - &-hidden { - display: none; - } - - .effect() { - animation-duration: 0.3s; - animation-fill-mode: both; - } - - &-zoom-enter, - &-zoom-appear { - opacity: 0; - animation-play-state: paused; - animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28); - .effect(); - } - - &-zoom-leave { - .effect(); - animation-play-state: paused; - animation-timing-function: cubic-bezier(0.6, -0.3, 0.74, 0.05); - } - - &-zoom-enter&-zoom-enter-active, - &-zoom-appear&-zoom-appear-active { - animation-name: rcTriggerZoomIn; - animation-play-state: running; - } - - &-zoom-leave&-zoom-leave-active { - animation-name: rcTriggerZoomOut; - animation-play-state: running; - } - - &-arrow { - z-index: 1; - width: 0px; - height: 0px; - background: #000; - border-radius: 100vw; - box-shadow: 0 0 0 3px black; - } - - @keyframes rcTriggerZoomIn { - 0% { - transform: scale(0, 0); - transform-origin: var(--arrow-x, 50%) var(--arrow-y, 50%); - opacity: 0; - } - 100% { - transform: scale(1, 1); - transform-origin: var(--arrow-x, 50%) var(--arrow-y, 50%); - opacity: 1; - } - } - @keyframes rcTriggerZoomOut { - 0% { - transform: scale(1, 1); - transform-origin: var(--arrow-x, 50%) var(--arrow-y, 50%); - opacity: 1; - } - 100% { - transform: scale(0, 0); - transform-origin: var(--arrow-x, 50%) var(--arrow-y, 50%); - opacity: 0; - } - } -} - -@import './index/Mask'; -@import './index/Mobile'; diff --git a/assets/index/Mask.less b/assets/index/Mask.less deleted file mode 100644 index 81692e6..0000000 --- a/assets/index/Mask.less +++ /dev/null @@ -1,63 +0,0 @@ -.@{triggerPrefixCls} { - &-mask { - position: fixed; - top: 0; - right: 0; - left: 0; - bottom: 0; - background-color: rgb(55, 55, 55); - background-color: rgba(55, 55, 55, 0.6); - height: 100%; - filter: alpha(opacity=50); - z-index: 1050; - - &-hidden { - display: none; - } - } - - .fade-effect() { - animation-duration: 0.3s; - animation-fill-mode: both; - animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); - } - - &-fade-enter,&-fade-appear { - opacity: 0; - .fade-effect(); - animation-play-state: paused; - } - - &-fade-leave { - .fade-effect(); - animation-play-state: paused; - } - - &-fade-enter&-fade-enter-active,&-fade-appear&-fade-appear-active { - animation-name: rcTriggerMaskFadeIn; - animation-play-state: running; - } - - &-fade-leave&-fade-leave-active { - animation-name: rcDialogFadeOut; - animation-play-state: running; - } - - @keyframes rcTriggerMaskFadeIn { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - - @keyframes rcDialogFadeOut { - 0% { - opacity: 1; - } - 100% { - opacity: 0; - } - } -} diff --git a/assets/index/Mobile.less b/assets/index/Mobile.less deleted file mode 100644 index 3c302ca..0000000 --- a/assets/index/Mobile.less +++ /dev/null @@ -1,25 +0,0 @@ -.@{triggerPrefixCls} { - &-mobile { - transition: all 0.3s; - position: fixed; - left: 0; - right: 0; - bottom: 0; - top: auto; - - &-fade { - &-appear, - &-enter { - &-start { - transform: translateY(100%); - } - } - - &-leave { - &-active { - transform: translateY(100%); - } - } - } - } -} diff --git a/docs/demos/.gitkeep b/docs/demos/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/demos/body-overflow.md b/docs/demos/body-overflow.md deleted file mode 100644 index 6f6f9c4..0000000 --- a/docs/demos/body-overflow.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Body Overflow -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/case.md b/docs/demos/case.md deleted file mode 100644 index 053a1bc..0000000 --- a/docs/demos/case.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Case -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/click-nested.md b/docs/demos/click-nested.md deleted file mode 100644 index c67236d..0000000 --- a/docs/demos/click-nested.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Click Nested -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/clip.md b/docs/demos/clip.md deleted file mode 100644 index e2798ee..0000000 --- a/docs/demos/clip.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Clip -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/container.md b/docs/demos/container.md deleted file mode 100644 index a4860cb..0000000 --- a/docs/demos/container.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Container -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/inside.md b/docs/demos/inside.md deleted file mode 100644 index a9853c3..0000000 --- a/docs/demos/inside.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Inside -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/large-popup.md b/docs/demos/large-popup.md deleted file mode 100644 index 048c77a..0000000 --- a/docs/demos/large-popup.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Large Popup -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/nested.md b/docs/demos/nested.md deleted file mode 100644 index 5daf43b..0000000 --- a/docs/demos/nested.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Nested -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/point.md b/docs/demos/point.md deleted file mode 100644 index 073a89b..0000000 --- a/docs/demos/point.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Point -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/shadow.md b/docs/demos/shadow.md deleted file mode 100644 index 379812b..0000000 --- a/docs/demos/shadow.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Shadow -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/simple.md b/docs/demos/simple.md deleted file mode 100644 index dbb7c35..0000000 --- a/docs/demos/simple.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Simple -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/demos/static-scroll.md b/docs/demos/static-scroll.md deleted file mode 100644 index 14a1846..0000000 --- a/docs/demos/static-scroll.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Static Scroll -nav: - title: Demo - path: /demo ---- - - diff --git a/docs/demos/visible-fallback.md b/docs/demos/visible-fallback.md deleted file mode 100644 index cb5a8f2..0000000 --- a/docs/demos/visible-fallback.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Visible Fallback -nav: - title: Demo - path: /demo ---- - - \ No newline at end of file diff --git a/docs/examples/.gitkeep b/docs/examples/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/examples/body-overflow.tsx b/docs/examples/body-overflow.tsx deleted file mode 100644 index 744e86a..0000000 --- a/docs/examples/body-overflow.tsx +++ /dev/null @@ -1,248 +0,0 @@ -/* eslint no-console:0 */ -import Trigger from 'rc-trigger'; -import React from 'react'; -import { createPortal } from 'react-dom'; -import '../../assets/index.less'; - -const PortalDemo = () => { - return createPortal( -
- PortalNode -
, - document.body, - ); -}; - -export default () => { - const [open, setOpen] = React.useState(false); - const [open1, setOpen1] = React.useState(false); - const [open2, setOpen2] = React.useState(false); - const [open3, setOpen3] = React.useState(false); - return ( - -