From 92f9444378ea757b2314d1cafb73290053c39599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sun, 16 Jun 2024 15:50:52 +0800 Subject: [PATCH 1/2] feat: initial commit --- .dumirc.ts | 15 +- .fatherrc.js | 9 +- HISTORY.md | 56 +- README.md | 226 +--- docs/demos/basic.md | 8 + docs/demos/body-overflow.md | 8 - docs/demos/case.md | 8 - docs/demos/click-nested.md | 8 - docs/demos/clip.md | 8 - docs/demos/container.md | 8 - docs/demos/customStyle.md | 8 + docs/demos/download.md | 8 + docs/demos/inside.md | 8 - docs/demos/large-popup.md | 8 - docs/demos/level.md | 8 + docs/demos/nested.md | 8 - docs/demos/point.md | 8 - docs/demos/shadow.md | 8 - docs/demos/simple.md | 8 - docs/demos/static-scroll.md | 8 - docs/demos/visible-fallback.md | 8 - docs/demos/withLogo.md | 8 + docs/examples/basic.tsx | 21 + docs/examples/body-overflow.tsx | 248 ----- docs/examples/case.less | 109 -- docs/examples/case.tsx | 241 ----- docs/examples/click-nested.tsx | 94 -- docs/examples/clip.tsx | 108 -- docs/examples/container.tsx | 198 ---- docs/examples/customStyle.tsx | 28 + docs/examples/download.tsx | 45 + docs/examples/inside.tsx | 180 ---- docs/examples/large-popup.tsx | 103 -- docs/examples/level.tsx | 39 + docs/examples/nested.tsx | 132 --- docs/examples/point.less | 3 - docs/examples/point.tsx | 83 -- docs/examples/shadow.tsx | 75 -- docs/examples/simple.tsx | 409 -------- docs/examples/static-scroll.tsx | 64 -- docs/examples/visible-fallback.tsx | 109 -- docs/examples/withLogo.tsx | 30 + docs/index.md | 4 +- index.js | 3 - index.ts | 1 + jest.config.js | 10 +- now.json | 4 +- package.json | 27 +- src/Popup/Arrow.tsx | 66 -- src/Popup/Mask.tsx | 40 - src/Popup/PopupContent.tsx | 17 - src/Popup/index.tsx | 285 ----- src/QRCodeCanvas.tsx | 176 ++++ src/QRCodeSVG.tsx | 97 ++ src/TriggerWrapper.tsx | 38 - src/context.ts | 9 - src/hooks/useAction.ts | 37 - src/hooks/useAlign.ts | 746 -------------- src/hooks/useQRCode.tsx | 53 + src/hooks/useWatch.ts | 48 - src/hooks/useWinClick.ts | 70 -- src/index.tsx | 767 +------------- src/interface.ts | 158 +-- src/libs/qrcodegen.ts | 1025 ++++++++++++++++++ src/mock.tsx | 34 - src/util.ts | 222 ---- src/utils.tsx | 160 +++ tests/__snapshots__/mobile.test.tsx.snap | 14 - tests/_utils.ts | 22 + tests/align.test.tsx | 297 ------ tests/arrow.test.jsx | 212 ---- tests/basic.test.jsx | 1201 ---------------------- tests/basic.test.tsx | 82 ++ tests/flip-visibleFirst.test.tsx | 309 ------ tests/flip.test.tsx | 547 ---------- tests/flipShift.test.tsx | 225 ---- tests/mask.test.jsx | 38 - tests/mobile.test.tsx | 137 --- tests/motion.test.jsx | 143 --- tests/point.test.jsx | 190 ---- tests/portal.test.jsx | 73 -- tests/ref.test.tsx | 53 - tests/setup.js | 3 - tests/setup.ts | 4 + tests/setupAfterEnv.ts | 1 + tests/shadow.test.tsx | 106 -- tests/util.test.jsx | 68 -- tests/util.tsx | 105 -- tsconfig.json | 2 +- 89 files changed, 1912 insertions(+), 8786 deletions(-) create mode 100644 docs/demos/basic.md delete mode 100644 docs/demos/body-overflow.md delete mode 100644 docs/demos/case.md delete mode 100644 docs/demos/click-nested.md delete mode 100644 docs/demos/clip.md delete mode 100644 docs/demos/container.md create mode 100644 docs/demos/customStyle.md create mode 100644 docs/demos/download.md delete mode 100644 docs/demos/inside.md delete mode 100644 docs/demos/large-popup.md create mode 100644 docs/demos/level.md delete mode 100644 docs/demos/nested.md delete mode 100644 docs/demos/point.md delete mode 100644 docs/demos/shadow.md delete mode 100644 docs/demos/simple.md delete mode 100644 docs/demos/static-scroll.md delete mode 100644 docs/demos/visible-fallback.md create mode 100644 docs/demos/withLogo.md create mode 100644 docs/examples/basic.tsx delete mode 100644 docs/examples/body-overflow.tsx delete mode 100644 docs/examples/case.less delete mode 100644 docs/examples/case.tsx delete mode 100644 docs/examples/click-nested.tsx delete mode 100644 docs/examples/clip.tsx delete mode 100644 docs/examples/container.tsx create mode 100644 docs/examples/customStyle.tsx create mode 100644 docs/examples/download.tsx delete mode 100644 docs/examples/inside.tsx delete mode 100644 docs/examples/large-popup.tsx create mode 100644 docs/examples/level.tsx delete mode 100644 docs/examples/nested.tsx delete mode 100644 docs/examples/point.less delete mode 100644 docs/examples/point.tsx delete mode 100644 docs/examples/shadow.tsx delete mode 100644 docs/examples/simple.tsx delete mode 100644 docs/examples/static-scroll.tsx delete mode 100644 docs/examples/visible-fallback.tsx create mode 100644 docs/examples/withLogo.tsx delete mode 100644 index.js create mode 100644 index.ts delete mode 100644 src/Popup/Arrow.tsx delete mode 100644 src/Popup/Mask.tsx delete mode 100644 src/Popup/PopupContent.tsx delete mode 100644 src/Popup/index.tsx create mode 100644 src/QRCodeCanvas.tsx create mode 100644 src/QRCodeSVG.tsx delete mode 100644 src/TriggerWrapper.tsx delete mode 100644 src/context.ts delete mode 100644 src/hooks/useAction.ts delete mode 100644 src/hooks/useAlign.ts create mode 100644 src/hooks/useQRCode.tsx delete mode 100644 src/hooks/useWatch.ts delete mode 100644 src/hooks/useWinClick.ts create mode 100644 src/libs/qrcodegen.ts delete mode 100644 src/mock.tsx delete mode 100644 src/util.ts create mode 100644 src/utils.tsx delete mode 100644 tests/__snapshots__/mobile.test.tsx.snap create mode 100644 tests/_utils.ts delete mode 100644 tests/align.test.tsx delete mode 100644 tests/arrow.test.jsx delete mode 100644 tests/basic.test.jsx create mode 100644 tests/basic.test.tsx delete mode 100644 tests/flip-visibleFirst.test.tsx delete mode 100644 tests/flip.test.tsx delete mode 100644 tests/flipShift.test.tsx delete mode 100644 tests/mask.test.jsx delete mode 100644 tests/mobile.test.tsx delete mode 100644 tests/motion.test.jsx delete mode 100644 tests/point.test.jsx delete mode 100644 tests/portal.test.jsx delete mode 100644 tests/ref.test.tsx delete mode 100644 tests/setup.js create mode 100644 tests/setup.ts create mode 100644 tests/setupAfterEnv.ts delete mode 100644 tests/shadow.test.tsx delete mode 100644 tests/util.test.jsx delete mode 100644 tests/util.tsx diff --git a/.dumirc.ts b/.dumirc.ts index bd80941..141e73d 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -3,21 +3,12 @@ import path from 'path'; export default defineConfig({ alias: { - 'rc-trigger$': path.resolve('src'), - 'rc-trigger/es': path.resolve('src'), + 'rc-qrcode$': path.resolve('src'), + 'rc-qrcode/es': path.resolve('src'), }, - mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], themeConfig: { - name: 'Trigger', + name: 'Qrcode', 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..7414da0 100644 --- a/.fatherrc.js +++ b/.fatherrc.js @@ -1,5 +1,10 @@ import { defineConfig } from 'father'; export default defineConfig({ - plugins: ['@rc-component/father-plugin'], -}); \ No newline at end of file + platform: 'browser', + cjs: { output: 'lib' }, + esm: { + output: 'es', + alias: { 'rc-util/lib': 'rc-util/es' }, + }, +}); diff --git a/HISTORY.md b/HISTORY.md index 7ee63c8..fe11a72 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,58 +1,6 @@ # History ---- -## 4.1.0 / 2020-05-08 +## 1.0.0 -- 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 +- feat: initial project diff --git a/README.md b/README.md index e479e56..e912959 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# @rc-component/trigger +# @rc-component/QRCode -React Trigger Component +React QRCode Component [![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] @@ -9,59 +9,15 @@ React Trigger Component [![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 - ## Install -[![@rc-component/trigger](https://nodei.co/npm/@rc-component/trigger.png)](https://npmjs.org/package/@rc-component/trigger) +[![@rc-component/qrcode](https://nodei.co/npm/@rc-component/qrcode.png)](https://npmjs.org/package/@rc-component/qrcode) ## 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); -``` - -## 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 | - ## Example -http://localhost:9001 +http://localhost:8001 ## Development @@ -74,175 +30,11 @@ npm start ### 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')
+## API + +| Name | Type | Default | Description | +| --- | --- | --- | --- | ## Test Case @@ -255,4 +47,4 @@ open coverage/ dir ## License -rc-trigger is released under the MIT license. +rc-qrcode is released under the MIT license. diff --git a/docs/demos/basic.md b/docs/demos/basic.md new file mode 100644 index 0000000..824c331 --- /dev/null +++ b/docs/demos/basic.md @@ -0,0 +1,8 @@ +--- +title: Basic +nav: + title: Demo + path: /demo +--- + + \ No newline at end of file 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/customStyle.md b/docs/demos/customStyle.md new file mode 100644 index 0000000..c10fca2 --- /dev/null +++ b/docs/demos/customStyle.md @@ -0,0 +1,8 @@ +--- +title: Custom Style +nav: + title: Demo + path: /demo +--- + + \ No newline at end of file diff --git a/docs/demos/download.md b/docs/demos/download.md new file mode 100644 index 0000000..83ba153 --- /dev/null +++ b/docs/demos/download.md @@ -0,0 +1,8 @@ +--- +title: Download +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/level.md b/docs/demos/level.md new file mode 100644 index 0000000..b669e67 --- /dev/null +++ b/docs/demos/level.md @@ -0,0 +1,8 @@ +--- +title: Level +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/demos/withLogo.md b/docs/demos/withLogo.md new file mode 100644 index 0000000..3d0acd3 --- /dev/null +++ b/docs/demos/withLogo.md @@ -0,0 +1,8 @@ +--- +title: WithLogo +nav: + title: Demo + path: /demo +--- + + \ No newline at end of file diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx new file mode 100644 index 0000000..0783fdf --- /dev/null +++ b/docs/examples/basic.tsx @@ -0,0 +1,21 @@ +import { QRCodeCanvas } from 'rc-qrcode'; +import React from 'react'; + +export default () => { + const [value, setValue] = React.useState('https://ant-design.antgroup.com/'); + return ( +
+ ) => + setValue(e.target.value) + } + type="text" + placeholder="The value of qrcode" + style={{ width: '100%' }} + /> +
+ +
+ ); +}; 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 ( - -