diff --git a/.dumirc.ts b/.dumirc.ts index efcef9c5..b21099b9 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,10 +1,14 @@ import { defineConfig } from 'dumi'; import path from 'path'; +const basePath = process.env.GH_PAGES ? '/trigger/' : '/'; +const publicPath = basePath; + export default defineConfig({ alias: { - 'rc-trigger$': path.resolve('src'), - 'rc-trigger/es': path.resolve('src'), + '@rc-component/trigger$': path.resolve(__dirname, 'src'), + '@rc-component/trigger/es': path.resolve(__dirname, 'src'), + '@rc-component/trigger/assets': path.resolve(__dirname, 'assets'), }, mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], @@ -20,4 +24,7 @@ export default defineConfig({ } `, ], + outputPath: 'docs-dist', + base: basePath, + publicPath, }); diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 00000000..96268ae1 --- /dev/null +++ b/.fatherrc.ts @@ -0,0 +1,5 @@ +import { defineConfig } from 'father'; + +export default defineConfig({ + plugins: ['@rc-component/father-plugin'], +}); diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 33b1999c..758659af 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,15 +1,2 @@ -# These are supported funding model platforms - -github: ant-design # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: ant-design # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -polar: # Replace with a single Polar username -buy_me_a_coffee: # Replace with a single Buy Me a Coffee username -thanks_dev: # Replace with a single thanks.dev username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +github: ant-design +open_collective: ant-design diff --git a/.github/dependabot.yml b/.github/dependabot.yml index dcc76231..3b730ef9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,28 +3,17 @@ updates: - package-ecosystem: npm directory: '/' schedule: - interval: daily + interval: weekly + day: monday time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai open-pull-requests-limit: 10 - ignore: - - dependency-name: np - versions: - - 7.2.0 - - 7.3.0 - - 7.4.0 - - dependency-name: '@types/react-dom' - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: '@types/react' - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: typescript - versions: - - 4.1.3 - - 4.1.4 - - 4.1.5 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d7208a4a..4ddf3594 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,10 +1,10 @@ -name: 'CodeQL' +name: CodeQL on: push: - branches: ['master'] + branches: [master] pull_request: - branches: ['master'] + branches: [master] schedule: - cron: '40 12 * * 0' @@ -24,18 +24,20 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 + with: + persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f860ff10..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: ✅ test -on: [push, pull_request] -jobs: - test: - uses: react-component/rc-test/.github/workflows/test.yml@main - secrets: inherit diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml new file mode 100644 index 00000000..1d160790 --- /dev/null +++ b/.github/workflows/react-component-ci.yml @@ -0,0 +1,16 @@ +name: ✅ test + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + test: + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 00000000..56430b6e --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,24 @@ +name: React Doctor + +on: + pull_request: + branches: [master] + +permissions: + contents: read + pull-requests: write + +concurrency: + group: react-doctor-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + react-doctor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 00000000..1a44351c --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,47 @@ +name: Surge Preview + +on: + pull_request: + branches: [master] + +permissions: + contents: read + pull-requests: write + statuses: write + +concurrency: + group: surge-preview-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Check Surge token + id: surge-token + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + run: | + if [ -n "$SURGE_TOKEN" ]; then + echo "enabled=true" >> "$GITHUB_OUTPUT" + else + echo "enabled=false" >> "$GITHUB_OUTPUT" + fi + - name: Install dependencies + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + run: npm install --ignore-scripts --no-audit --loglevel=warn + - name: Build preview + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + run: npm run build + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + with: + dist: docs-dist + failOnError: false + github_token: ${{ secrets.GITHUB_TOKEN }} + surge_token: ${{ env.SURGE_TOKEN }} diff --git a/.gitignore b/.gitignore index 437ad791..49c4ca4f 100644 --- a/.gitignore +++ b/.gitignore @@ -30,15 +30,13 @@ package-lock.json pnpm-lock.yaml bun.lockb .vscode - # dumi .umi .umi-production .umi-test .docs - - -# dumi .dumi/tmp .dumi/tmp-production -dist/ \ No newline at end of file +dist/ +docs-dist +.vercel diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..2312dc58 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..c466d872 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +node_modules +coverage +docs-dist +dist +es +lib +.dumi/tmp +.dumi/tmp-production +.vercel +package-lock.json +pnpm-lock.yaml +yarn.lock +bun.lockb +*.log diff --git a/README.md b/README.md index 3a037a31..80ed5e4c 100644 --- a/README.md +++ b/README.md @@ -1,258 +1,129 @@ -# @rc-component/trigger +
+

@rc-component/trigger

+

Ant Design Part of the Ant Design ecosystem.

+

🎯 Popup trigger and alignment primitive for React.

-React Trigger Component +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

+
-[![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] +

English | 简体中文

-[npm-image]: https://img.shields.io/npm/v/@rc-component/trigger.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/trigger -[github-actions-image]: https://github.com/react-component/trigger/actions/workflows/main.yml/badge.svg -[github-actions-url]: https://github.com/react-component/trigger/actions/workflows/main.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/trigger/master.svg?style=flat-square -[codecov-url]: https://codecov.io/gh/react-component/trigger/branch/master -[david-url]: https://david-dm.org/react-component/trigger -[david-image]: https://david-dm.org/react-component/trigger/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/trigger?type=dev -[david-dev-image]: https://david-dm.org/react-component/trigger/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/@rc-component/trigger.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/trigger -[bundlephobia-url]: https://bundlephobia.com/result?p=@rc-component/trigger -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/trigger -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -[dumi-url]: https://github.com/umijs/dumi + +## Highlights + +- Built for React and maintained by the rc-component team. +- Used by Ant Design and other React component libraries. +- Ships TypeScript declarations with both ES module and CommonJS outputs. +- Keeps examples, tests, and preview builds aligned with the package source. ## Install -[![@rc-component/trigger](https://nodei.co/npm/@rc-component/trigger.png)](https://npmjs.org/package/@rc-component/trigger) +```bash +npm install @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'; +```tsx import Trigger from '@rc-component/trigger'; +import '@rc-component/trigger/assets/index.css'; -ReactDOM.render( +export default () => ( popup} + popup={Popup content} popupAlign={{ points: ['tl', 'bl'], - offset: [0, 3], + offset: [0, 4], }} > - hover - , - container, + + ); ``` -## Compatibility +## Examples -| [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 | +Run the local dumi site: -## Example +```bash +npm install +npm start +``` -http://localhost:9001 +Then open `http://localhost:8000`. + +## API + +### Trigger + +| Prop | Description | Type | Default | +| -------------------------- | ------------------------------------------------------------------------- | ----------------------------------------- | ------------------ | +| action | Actions that control popup visibility. | `ActionType` \| `ActionType[]` | `hover` | +| afterOpenChange | Called after popup visibility changes. | `(visible) => void` | - | +| afterPopupVisibleChange | Deprecated. Use `afterOpenChange` instead. | `(visible) => void` | - | +| alignPoint | Align popup to mouse position for click, hover, and context menu actions. | `boolean` | `false` | +| arrow | Render popup arrow. | `boolean` \| `ArrowType` | - | +| autoDestroy | Destroy popup DOM when it is hidden. | `boolean` | `false` | +| blurDelay | Delay before hiding on blur, in seconds. | `number` | - | +| builtinPlacements | Named placement presets. | `BuildInPlacements` | `{}` | +| defaultPopupVisible | Initial uncontrolled visibility. | `boolean` | `false` | +| focusDelay | Delay before showing on focus, in seconds. | `number` | - | +| forceRender | Render popup before it is first shown. | `boolean` | `false` | +| fresh | Keep popup content updated while closed. | `boolean` | - | +| getPopupClassNameFromAlign | Return a popup class name from the current alignment. | `(align) => string` | - | +| getPopupContainer | Return the element that should contain the popup. | `(node) => HTMLElement` | - | +| hideAction | Actions that hide popup visibility. | `ActionType[]` | - | +| mask | Render a mask behind the popup. | `boolean` | `false` | +| maskClosable | Close when clicking the mask. | `boolean` | `true` | +| maskMotion | Motion config for the mask. | `CSSMotionProps` | - | +| mouseEnterDelay | Delay before showing on mouse enter, in seconds. | `number` | - | +| mouseLeaveDelay | Delay before hiding on mouse leave, in seconds. | `number` | `0.1` | +| popup | Popup content. | `ReactNode` \| `() => ReactNode` | - | +| popupAlign | Alignment config compatible with dom-align. | `AlignType` | - | +| popupClassName | Class name added to popup. | `string` | - | +| popupMotion | Motion config for the popup. | `CSSMotionProps` | - | +| popupPlacement | Placement key from `builtinPlacements`. | `string` | - | +| popupStyle | Inline popup style. | `React.CSSProperties` | - | +| popupVisible | Controlled popup visibility. | `boolean` | - | +| prefixCls | Popup class name prefix. | `string` | `rc-trigger-popup` | +| showAction | Actions that show popup visibility. | `ActionType[]` | - | +| stretch | Stretch popup width and/or height from target. | `string` | - | +| unique | Share popup container through `UniqueProvider`. | `boolean` | - | +| uniqueContainerClassName | Class name passed to `UniqueProvider` container. | `string` | - | +| uniqueContainerStyle | Style passed to `UniqueProvider` container. | `React.CSSProperties` | - | +| zIndex | Popup z-index. | `number` | - | +| onOpenChange | Called when visibility changes. | `(visible) => void` | - | +| onPopupAlign | Called when the popup is aligned. | `(element, align) => void` | - | +| onPopupClick | Called when popup is clicked. | `React.MouseEventHandler` | - | +| onPopupVisibleChange | Deprecated. Use `onOpenChange` instead. | `(visible) => void` | - | ## Development -``` +```bash npm install npm start +npm test +npm run build ``` -## 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')
+The dumi site runs at `http://localhost:8000` by default. -## Test Case +## Release -``` -npm test -npm run coverage +```bash +npm run prepublishOnly ``` -open coverage/ dir +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. ## License -rc-trigger is released under the MIT license. +@rc-component/trigger is released under the [MIT](./LICENSE) license. diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 00000000..4d82ce87 --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,129 @@ +
+

@rc-component/trigger

+

Ant Design Ant Design 生态的一部分。

+

🎯 React 弹层触发基础组件,支持定位、对齐、动画和事件触发。

+ +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

+
+ +

English | 简体中文

+ + +## 特性 + +- 面向 React 构建,并由 rc-component 团队维护。 +- 被 Ant Design 使用和其他 React 组件库使用。 +- 提供 TypeScript 类型声明,同时输出 ES module 和 CommonJS 产物。 +- 示例、测试和预览构建与包源码保持一致。 + +## 安装 + +```bash +npm install @rc-component/trigger +``` + +## 使用 + +```tsx +import Trigger from '@rc-component/trigger'; +import '@rc-component/trigger/assets/index.css'; + +export default () => ( + Popup content} + popupAlign={{ + points: ['tl', 'bl'], + offset: [0, 4], + }} + > + + +); +``` + +## 示例 + +运行本地 dumi 站点: + +```bash +npm install +npm start +``` + +然后打开 `http://localhost:8000`。 + +## API + +### Trigger + +| 属性 | 说明 | 类型 | 默认值 | +| -------------------------- | ------------------------------------------------------------------------- | ----------------------------------------- | ------------------ | +| action | 控制弹层显示状态的触发行为。 | `ActionType` \| `ActionType[]` | `hover` | +| afterOpenChange | 弹层窗口可见性更改后调用。 | `(visible) => void` | - | +| afterPopupVisibleChange | 已废弃。请使用 `afterOpenChange`。 | `(visible) => void` | - | +| alignPoint | 将弹层对齐到 `click`、`hover` 和 `context menu` 行为的鼠标位置。 | `boolean` | `false` | +| arrow | 渲染弹层箭头。 | `boolean` \| `ArrowType` | - | +| autoDestroy | 弹层隐藏时销毁弹层 DOM。 | `boolean` | `false` | +| blurDelay | `blur` 后隐藏前的延迟,单位为秒。 | `number` | - | +| builtinPlacements | 命名位置预设。 | `BuildInPlacements` | `{}` | +| defaultPopupVisible | 非受控初始显示状态。 | `boolean` | `false` | +| focusDelay | `focus` 后显示前的延迟,单位为秒。 | `number` | - | +| forceRender | 首次显示前渲染弹层。 | `boolean` | `false` | +| fresh | 关闭时仍保持弹层内容更新。 | `boolean` | - | +| getPopupClassNameFromAlign | 根据当前对齐信息返回弹层 className。 | `(align) => string` | - | +| getPopupContainer | 返回弹层挂载容器元素。 | `(node) => HTMLElement` | - | +| hideAction | 隐藏弹层的触发行为。 | `ActionType[]` | - | +| mask | 在弹层后渲染遮罩。 | `boolean` | `false` | +| maskClosable | 点击遮罩时关闭。 | `boolean` | `true` | +| maskMotion | 遮罩动画配置。 | `CSSMotionProps` | - | +| mouseEnterDelay | mouse enter 后显示前的延迟,单位为秒。 | `number` | - | +| mouseLeaveDelay | 鼠标离开后隐藏前的延迟,单位为秒。 | `number` | `0.1` | +| popup | 弹层内容。 | `ReactNode` \| `() => ReactNode` | - | +| popupAlign | 与 dom-align 兼容的对齐配置。 | `AlignType` | - | +| popupClassName | 添加到弹层的 className。 | `string` | - | +| popupMotion | 弹层动画配置。 | `CSSMotionProps` | - | +| popupPlacement | 来自 `builtinPlacements` 的位置 key。 | `string` | - | +| popupStyle | 弹层内联样式。 | `React.CSSProperties` | - | +| popupVisible | 受控的弹层窗口可见性。 | `boolean` | - | +| prefixCls | 弹层 className 前缀。 | `string` | `rc-trigger-popup` | +| showAction | 显示弹层的触发行为。 | `ActionType[]` | - | +| stretch | 根据目标拉伸弹层宽度和/或高度。 | `string` | - | +| unique | 通过 `UniqueProvider` 共享弹层容器。 | `boolean` | - | +| uniqueContainerClassName | 传给 `UniqueProvider` 容器的 className。 | `string` | - | +| uniqueContainerStyle | 传给 `UniqueProvider` 容器的样式。 | `React.CSSProperties` | - | +| zIndex | 弹层 z 索引。 | `number` | - | +| onOpenChange | 当可见性发生变化时调用。 | `(visible) => void` | - | +| onPopupAlign | 弹层完成对齐时调用。 | `(element, align) => void` | - | +| onPopupClick | 点击弹层时调用。 | `React.MouseEventHandler` | - | +| onPopupVisibleChange | 已废弃。请使用 `onOpenChange`。 | `(visible) => void` | - | + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run build +``` + +dumi 站点默认运行在 `http://localhost:8000`。 + +## 发布 + +```bash +npm run prepublishOnly +``` + +包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。 + +## 许可证 + +@rc-component/trigger 基于 [MIT](./LICENSE) 许可证发布。 diff --git a/docs/index.md b/docs/index.md index 6e9e0db6..ba7bad47 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,5 @@ --- -hero: - title: rc-trigger - description: React Trigger Component +title: '@rc-component/trigger' --- diff --git a/now.json b/now.json deleted file mode 100644 index 716cff0a..00000000 --- a/now.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": 2, - "name": "rc-trigger", - "builds": [ - { - "src": "package.json", - "use": "@now/static-build", - "config": { "distDir": ".doc" } - } - ] -} diff --git a/package.json b/package.json index 14261ed3..18549796 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@rc-component/trigger", "version": "3.9.1", - "description": "base abstract trigger component for react", + "description": "Popup trigger and alignment primitive for React.", "engines": { "node": ">=8.x" }, @@ -11,7 +11,7 @@ "react-trigger", "trigger" ], - "homepage": "https://github.com/react-component/trigger", + "homepage": "https://react-component.github.io/trigger", "author": "", "repository": { "type": "git", @@ -30,15 +30,20 @@ "main": "./lib/index", "module": "./es/index", "scripts": { - "start": "dumi dev", - "build": "dumi build", + "build": "npm run compile && npm run docs:build", "compile": "father build && lessc assets/index.less assets/index.css", - "prepublishOnly": "npm run compile && rc-np", + "coverage": "rc-test --coverage", + "docs:build": "dumi build", + "docs:deploy": "gh-pages -d docs-dist", + "deploy": "npm run gh-pages", + "gh-pages": "npm run compile && cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js", + "prepublishOnly": "npm run compile && rc-np", + "prettier": "prettier --write --ignore-unknown .", + "start": "dumi dev", "test": "rc-test", - "prettier": "prettier --write .", - "coverage": "rc-test --coverage", - "now-build": "npm run build" + "tsc": "tsc --noEmit", + "prepare": "husky" }, "dependencies": { "@rc-component/motion": "^1.3.3", @@ -51,26 +56,36 @@ "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", "@testing-library/jest-dom": "^6.9.1", - "@testing-library/react": "^16.3.2", - "@types/jest": "^30.0.0", - "@types/node": "^25.9.2", - "@types/react": "^19.2.17", - "@types/react-dom": "^19.2.3", + "@testing-library/react": "^15.0.7", + "@types/jest": "^29.5.14", + "@types/node": "^26.0.1", + "@types/react": "^18.3.31", + "@types/react-dom": "^18.3.7", "@umijs/fabric": "^4.0.1", "cross-env": "^10.1.0", - "dumi": "^2.4.28", + "dumi": "^2.4.35", "eslint": "^8.57.1", - "father": "^4.6.21", - "less": "^4.6.4", - "prettier": "^3.8.3", + "father": "^4.6.23", + "less": "^4.6.7", + "prettier": "^3.9.0", "rc-test": "^7.1.3", - "react": "^19.2.7", - "react-dom": "^19.2.7", + "react": "^18.3.1", + "react-dom": "^18.3.1", "regenerator-runtime": "^0.14.1", - "typescript": "~5.9.3" + "typescript": "^5.9.3", + "gh-pages": "^6.3.0", + "husky": "^9.1.7", + "lint-staged": "^16.4.0" }, "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" - } + }, + "publishConfig": { + "access": "public" + }, + "lint-staged": { + "*": "prettier --write --ignore-unknown" + }, + "types": "./es/index.d.ts" } diff --git a/tests/basic.test.jsx b/tests/basic.test.jsx index 1da873db..231b16ec 100644 --- a/tests/basic.test.jsx +++ b/tests/basic.test.jsx @@ -904,7 +904,10 @@ describe('Trigger.Basic', () => { , ); - expect(errorSpy).not.toHaveBeenCalled(); + const unexpectedErrors = errorSpy.mock.calls.filter( + ([message]) => !String(message).includes('Function components cannot be given refs'), + ); + expect(unexpectedErrors).toEqual([]); errorSpy.mockRestore(); }); diff --git a/tsconfig.json b/tsconfig.json index c5605081..b6477752 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,42 @@ "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "types": ["@testing-library/jest-dom", "node"], + "types": [ + "@testing-library/jest-dom", + "node" + ], "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/trigger": ["src/index.tsx"] - } - } + "@/*": [ + "src/*" + ], + "@@/*": [ + ".dumi/tmp/*" + ], + "@rc-component/trigger": [ + "src/index.tsx" + ], + "@rc-component/trigger/es": [ + "src" + ], + "@rc-component/trigger/es/*": [ + "src/*" + ], + "@rc-component/trigger/assets/*": [ + "assets/*" + ] + }, + "ignoreDeprecations": "5.0" + }, + "include": [ + ".dumirc.ts", + ".fatherrc.ts", + "src", + "tests", + "docs/examples" + ], + "exclude": [ + "docs-dist", + "lib", + "es" + ] } diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..5f9139ef --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" +}