diff --git a/.dumirc.ts b/.dumirc.ts index 1e597f02..4f40c1df 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,16 +1,14 @@ import { defineConfig } from 'dumi'; import path from 'path'; -// const isProdSite = -// // 不是预览模式 同时是生产环境 -// process.env.PREVIEW !== 'true' && process.env.NODE_ENV === 'production'; - -// const name = 'tooltip'; +const basePath = process.env.GH_PAGES ? '/tooltip/' : '/'; +const publicPath = basePath; export default defineConfig({ alias: { - 'rc-tooltip$': path.resolve('src'), - 'rc-tooltip/es': path.resolve('src'), + '@rc-component/tooltip$': path.resolve('src'), + '@rc-component/tooltip/assets': path.resolve('assets'), + '@rc-component/tooltip/es': path.resolve('src'), }, mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], @@ -18,6 +16,7 @@ export default defineConfig({ name: 'Tooltip', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, - // base: isProdSite ? `/${name}/` : '/', - // publicPath: isProdSite ? `/${name}/` : '/', + 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 cb16808a..3b730ef9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,23 +1,19 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: less - versions: - - 4.1.0 + - package-ecosystem: npm + directory: '/' + schedule: + 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 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..82242dfd --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,43 @@ +name: 'CodeQL' + +on: + push: + branches: ['master'] + pull_request: + branches: ['master'] + schedule: + - cron: '17 10 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [javascript] + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Initialize CodeQL + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 5735e2d2..1ed64209 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -1,6 +1,12 @@ name: ✅ test -on: [push, pull_request] +on: + push: + branches: [master] + pull_request: + branches: [master] +permissions: + contents: read jobs: test: - uses: react-component/rc-test/.github/workflows/test.yml@main - secrets: inherit \ No newline at end of file + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: inherit diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 00000000..097eb883 --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,27 @@ +name: React Doctor + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [master] + +permissions: + contents: read + pull-requests: write + issues: write + statuses: 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: + fetch-depth: 0 + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml deleted file mode 100644 index 8f125072..00000000 --- a/.github/workflows/site-deploy.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Deploy website -on: - push: - tags: - - '*' - workflow_dispatch: - -permissions: - contents: write - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: setup node - uses: actions/setup-node@v1 - with: - node-version: 14 - - - name: create package-lock.json - run: npm i --package-lock-only --ignore-scripts - - - name: Install dependencies - run: npm ci - - - name: build Docs - run: npm run build - - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist - force_orphan: true - user_name: 'github-actions[bot]' - user_email: 'github-actions[bot]@users.noreply.github.com' diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 00000000..4c2f17ed --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,54 @@ +name: Surge Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + checks: write + +jobs: + preview: + runs-on: ubuntu-latest + concurrency: + group: surge-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true + env: + PREVIEW: true + 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: Build preview + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + run: | + npm install + npm run build + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + with: + surge_token: ${{ env.SURGE_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dist: docs-dist + failOnError: false + setCommitStatus: false + - name: Skip Surge preview + if: ${{ steps.surge-token.outputs.enabled != 'true' }} + run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/.gitignore b/.gitignore index d34b9854..f0882bba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.storybook *.iml *.log *.log.* @@ -27,19 +26,26 @@ assets/**/*.css build lib es -coverage +/coverage yarn.lock package-lock.json pnpm-lock.yaml +.doc +docs-dist +.vercel +.storybook +tmp/ +.history # umi .umi .umi-production .umi-test .env.local +.dumi/ -# dumi +bun.lockb +bun.lock +coverage .dumi/tmp .dumi/tmp-production - -bun.lockb 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 362bc0d8..727846c6 100644 --- a/README.md +++ b/README.md @@ -1,160 +1,113 @@ -# @rc-component/tooltip +
+

@rc-component/tooltip

+

Ant Design Part of the Ant Design ecosystem.

+

💡 Positioned React tooltip for hover, focus, click, and controlled popup flows.

-React Tooltip +

+ 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] -[![Codecov][codecov-image]][codecov-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] +

English | 简体中文

-[npm-image]: http://img.shields.io/npm/v/@rc-component/tooltip.svg?style=flat-square -[npm-url]: http://npmjs.org/package/@rc-component/tooltip -[github-actions-image]: https://github.com/react-component/tooltip/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/tooltip/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/tooltip/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/tooltip -[download-image]: https://img.shields.io/npm/dm/@rc-component/tooltip.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/tooltip -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/tooltip -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/tooltip -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -## Screenshot +## Highlights - - -## Browsers support - -| [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 | [Opera](http://godban.github.io/browsers-support-badges/)
Opera | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| IE 8 + ✔ | Firefox 31.0+ ✔ | Chrome 31.0+ ✔ | Safari 7.0+ ✔ | Opera 30.0+ ✔ | +- Supports hover, focus, click, and controlled visibility through one trigger layer. +- Provides built-in placements, custom alignment, delays, arrows, and popup motion. +- Exposes semantic `classNames` and `styles` slots for root, arrow, and container nodes. +- Keeps accessibility wiring through generated tooltip ids and `aria-describedby`. ## Install -[![@rc-component/tooltip](https://nodei.co/npm/@rc-component/tooltip.png)](https://npmjs.org/package/@rc-component/tooltip) +```bash +npm install @rc-component/tooltip +``` ## Usage -```js -var Tooltip = require('@rc-component/tooltip'); -var React = require('react'); -var ReactDOM = require('react-dom'); +```tsx pure +import Tooltip from '@rc-component/tooltip'; +import '@rc-component/tooltip/assets/bootstrap_white.css'; -// By default, the tooltip has no style. -// Consider importing the stylesheet it comes with: -// '@rc-component/tooltip/assets/bootstrap_white.css' - -ReactDOM.render( - tooltip}> - hover - , - container, +export default () => ( + Tooltip content}> + + ); ``` -## Examples - -`npm start` and then go to - +Online preview: https://tooltip.react-component.vercel.app/ -Online demo: https://tooltip-react-component.vercel.app/ +## Examples -## API +Run the local dumi site: -### Props - -| name | type | default | description | -| ------------------- | ------------------------------------------------------------------ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| trigger | string \| string\[] | 'hover' | which actions cause tooltip shown. enum of 'hover','click','focus' | -| visible | boolean | false | whether tooltip is visible | -| defaultVisible | boolean | false | whether tooltip is visible by default | -| placement | string | 'right' | tooltip placement. enum of 'top','left','right','bottom', 'topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'leftTop', 'leftBottom', 'rightTop', 'rightBottom' | -| motion | object | | Config popup motion. Please ref demo for example | -| onVisibleChange | (visible: boolean) => void; | | Callback when visible change | -| afterVisibleChange | (visible: boolean) => void; | | Callback after visible change | -| overlay | ReactNode \| () => ReactNode | | tooltip overlay content | -| overlayStyle | object | | deprecated, Please use `styles={{ root: {} }}` | -| overlayClassName | string | | deprecated, Please use `classNames={{ root: {} }}` | -| prefixCls | string | 'rc-tooltip' | prefix class name of tooltip | -| mouseEnterDelay | number | 0 | delay time (in second) before tooltip shows when mouse enter | -| mouseLeaveDelay | number | 0.1 | delay time (in second) before tooltip hides when mouse leave | -| getTooltipContainer | (triggerNode: HTMLElement) => HTMLElement | () => document.body | get container of tooltip, default to body | -| destroyOnHidden | boolean | false | destroy tooltip when it is hidden | -| align | object | | align config of tooltip, ref [dom-align](https://github.com/yiminghe/dom-align). See [Align Overflow](#align-overflow) below | -| showArrow | boolean \| object | false | whether to show arrow of tooltip | -| zIndex | number | | config popup tooltip zIndex | -| classNames | classNames?: { root?: string; container?: string;}; | | Semantic DOM class | -| styles | styles?: {root?: React.CSSProperties;container?: React.CSSProperties;}; | | Semantic DOM styles | - -### Align Overflow - -The `align` prop accepts an object that may include an `overflow` field to control how the tooltip adjusts when it overflows the visible area. This is powered by [dom-align](https://github.com/yiminghe/dom-align). - -| name | type | default | description | -| ---------------- | ---------------- | ------- | -------------------------------------------------------------------------------------------------------- | -| adjustX | boolean \| number | false | adjust tooltip position in the X direction when it overflows | -| adjustY | boolean \| number | false | adjust tooltip position in the Y direction when it overflows | -| alwaysByViewport | boolean | false | when `true`, always adjusts position based on the viewport rather than the scrollable parent container | - -```jsx -tooltip content} -> - - +```bash +npm install +npm start ``` -When `alwaysByViewport` is `true`, the tooltip will reposition itself to stay within the browser viewport. This is particularly useful when the trigger element is inside a scrollable container and you want the tooltip to always be visible on screen. - -## Important Note +Then open `http://localhost:8000`. -`Tooltip` requires a child node that accepts an `onMouseEnter`, `onMouseLeave`, `onFocus`, `onClick` event. This means the child node must be a built-in component like `div` or `span`, or a custom component that passes its props to its built-in component child. - -## Accessibility - -For accessibility purpose you can use the `id` prop to link your tooltip with another element. For example attaching it to an input element: - -```js - - - -``` - -If you do it like this, a screenreader would read the content of your tooltip if you focus the input element. +## API -**NOTE:** `role="tooltip"` is also added to expose the purpose of the tooltip element to a screenreader. +### Tooltip + +| Name | Type | Default | Description | +| --------------------- | ---------------------------------------------------- | ------------------- | ---------------------------------------------------------- | +| `afterVisibleChange` | `(visible: boolean) => void` | - | Called after popup visibility changes. | +| `align` | AlignType | `{}` | Extra popup alignment config. | +| `arrowContent` | React.ReactNode | - | Custom arrow content. | +| `builtinPlacements` | TriggerProps['builtinPlacements'] | built-in placements | Placement map passed to trigger. | +| `children` | React.ReactElement | - | Required trigger element. | +| `classNames` | `Partial>` | - | Semantic class names for root, arrow, and container nodes. | +| `defaultVisible` | boolean | - | Initial uncontrolled visible state. | +| `destroyOnHidden` | boolean | false | Destroy popup DOM when hidden. | +| `fresh` | boolean | - | Keep popup content fresh when closed. | +| `getTooltipContainer` | `(node: HTMLElement) => HTMLElement` | - | Resolve popup container. | +| `id` | string | generated id | Tooltip id used for accessibility. | +| `motion` | TriggerProps['popupMotion'] | - | Popup motion config. | +| `mouseEnterDelay` | number | 0 | Delay in seconds before showing on mouse enter. | +| `mouseLeaveDelay` | number | 0.1 | Delay in seconds before hiding on mouse leave. | +| `onPopupAlign` | TriggerProps['onPopupAlign'] | - | Called after popup alignment. | +| `onVisibleChange` | `(visible: boolean) => void` | - | Called when visibility changes. | +| `overlay` | React.ReactNode \| `() => React.ReactNode` | - | Tooltip content. | +| `placement` | string | `'right'` | Popup placement. | +| `prefixCls` | string | `'rc-tooltip'` | Prefix class name. | +| `showArrow` | boolean \| ArrowType | true | Whether to show arrow or provide arrow config. | +| `styles` | `Partial>` | - | Semantic styles for root, arrow, and container nodes. | +| `trigger` | ActionType \| ActionType[] | `['hover']` | Actions that show the tooltip. | +| `unique` | TriggerProps['unique'] | - | Experimental unique container reuse config. | +| `visible` | boolean | - | Controlled visible state. | +| `zIndex` | number | - | Popup z-index. | ## Development ```bash npm install npm start -``` - -## Test Case - -```bash npm test -npm run chrome-test +npm run tsc +npm run compile +npm run build ``` -## Coverage +The dumi site runs at `http://localhost:8000` by default. + +## Release ```bash -npm run coverage +npm run prepublishOnly ``` +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. + ## License -`@rc-component/tooltip` is released under the MIT license. +@rc-component/tooltip 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..da084ae0 --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,113 @@ +
+

@rc-component/tooltip

+

Ant Design Ant Design 生态的一部分。

+

💡 React 文字提示组件,基于 trigger 定位和弹层能力构建。

+ +

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

+
+ +

English | 简体中文

+ + +## 特性 + +- 支持悬停、聚焦、单击以及通过一个触发层控制可见性。 +- 提供内置放置、自定义对齐、延迟、箭头和弹层动作。 +- 为根节点、箭头节点和容器节点引入语义 `classNames` 和 `styles` 槽。 +- 通过生成的工具提示 id 和 `aria-describedby` 保留可访问性连接。 + +## 安装 + +```bash +npm install @rc-component/tooltip +``` + +## 使用 + +```tsx pure +import Tooltip from '@rc-component/tooltip'; +import '@rc-component/tooltip/assets/bootstrap_white.css'; + +export default () => ( + Tooltip content}> + + +); +``` + +在线预览:https://tooltip.react-component.vercel.app/ + +## 示例 + +运行本地 dumi 站点: + +```bash +npm install +npm start +``` + +然后打开 `http://localhost:8000`。 + +## API + +### Tooltip + +| 名称 | 类型 | 默认值 | 说明 | +| --------------------- | ---------------------------------------------------- | ------------------- | ---------------------------------------------------------- | +| `afterVisibleChange` | `(visible: boolean) => void` | - | 弹层窗口可见性更改后调用。 | +| `align` | AlignType | `{}` | 额外弹层对齐配置。 | +| `arrowContent` | React.ReactNode | - | 自定义箭头内容。 | +| `builtinPlacements` | TriggerProps['builtinPlacements'] | built-in placements | 传递给触发器的放置映射。 | +| `children` | React.ReactElement | - | 所需的触发元素。 | +| `classNames` | `Partial>` | - | 根节点、箭头节点和容器节点的语义化类名。 | +| `defaultVisible` | boolean | - | 初始不受控制的可见状态。 | +| `destroyOnHidden` | boolean | false | 隐藏时销毁弹层 DOM。 | +| `fresh` | boolean | - | 关闭时保持弹层内容新鲜。 | +| `getTooltipContainer` | `(node: HTMLElement) => HTMLElement` | - | 指定弹层容器。 | +| `id` | string | generated id | 用于辅助功能的工具提示 ID。 | +| `motion` | TriggerProps['popupMotion'] | - | 弹层运动配置。 | +| `mouseEnterDelay` | number | 0 | 鼠标移入后显示的延迟(秒)。 | +| `mouseLeaveDelay` | number | 0.1 | 鼠标移出后隐藏的延迟(秒)。 | +| `onPopupAlign` | TriggerProps['onPopupAlign'] | - | 弹层对齐后调用。 | +| `onVisibleChange` | `(visible: boolean) => void` | - | 当可见性发生变化时调用。 | +| `overlay` | React.ReactNode \| `() => React.ReactNode` | - | 提示内容。 | +| `placement` | string | `'right'` | 弹层放置。 | +| `prefixCls` | string | `'rc-tooltip'` | 前缀 className。 | +| `showArrow` | boolean \| ArrowType | true | 是否显示箭头,或提供箭头配置。 | +| `styles` | `Partial>` | - | 根节点、箭头节点和容器节点的语义样式。 | +| `trigger` | ActionType \| ActionType[] | `['hover']` | 显示提示的触发行为。 | +| `unique` | TriggerProps['unique'] | - | 实验性独特的容器重用配置。 | +| `visible` | boolean | - | 受控可见状态。 | +| `zIndex` | number | - | 弹层 z 索引。 | + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run tsc +npm run compile +npm run build +``` + +dumi 站点默认运行在 `http://localhost:8000`。 + +## 发布 + +```bash +npm run prepublishOnly +``` + +包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。 + +## 许可证 + +@rc-component/tooltip 基于 [MIT](./LICENSE) 许可证发布。 diff --git a/docs/examples/arrowContent.tsx b/docs/examples/arrowContent.tsx index 61d68d9a..34581416 100644 --- a/docs/examples/arrowContent.tsx +++ b/docs/examples/arrowContent.tsx @@ -1,5 +1,5 @@ import React, { CSSProperties } from 'react'; -import Tooltip from 'rc-tooltip'; +import Tooltip from '@rc-component/tooltip'; import '../../assets/bootstrap_white.less'; const text = Tooltip Text; diff --git a/docs/examples/formError.tsx b/docs/examples/formError.tsx index 4c31f968..25c0b154 100644 --- a/docs/examples/formError.tsx +++ b/docs/examples/formError.tsx @@ -1,4 +1,4 @@ -import Tooltip from 'rc-tooltip'; +import Tooltip from '@rc-component/tooltip'; import React, { Component } from 'react'; import '../../assets/bootstrap.less'; diff --git a/docs/examples/onVisibleChange.tsx b/docs/examples/onVisibleChange.tsx index fb8049b9..dbb73331 100644 --- a/docs/examples/onVisibleChange.tsx +++ b/docs/examples/onVisibleChange.tsx @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import Tooltip from 'rc-tooltip'; +import Tooltip from '@rc-component/tooltip'; import '../../assets/bootstrap.less'; function preventDefault(e: React.MouseEvent) { diff --git a/docs/examples/placement.tsx b/docs/examples/placement.tsx index e62ab59d..1409f130 100644 --- a/docs/examples/placement.tsx +++ b/docs/examples/placement.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import Tooltip from 'rc-tooltip'; +import Tooltip from '@rc-component/tooltip'; import '../../assets/bootstrap.less'; -import Popup from '../../src/Popup'; +import Popup from '@rc-component/tooltip/es/Popup'; const text = Tooltip Text; diff --git a/docs/examples/point.tsx b/docs/examples/point.tsx index f7faf1dc..cda1c172 100644 --- a/docs/examples/point.tsx +++ b/docs/examples/point.tsx @@ -1,4 +1,4 @@ -import Tooltip from 'rc-tooltip'; +import Tooltip from '@rc-component/tooltip'; import React from 'react'; import '../../assets/bootstrap_white.less'; diff --git a/docs/examples/showArrow.tsx b/docs/examples/showArrow.tsx index bf2a97dc..c1f9d1b4 100644 --- a/docs/examples/showArrow.tsx +++ b/docs/examples/showArrow.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import Tooltip from 'rc-tooltip'; +import Tooltip from '@rc-component/tooltip'; import '../../assets/bootstrap_white.less'; const text = Tooltip Text; diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx index cef651c8..6367adf1 100644 --- a/docs/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -1,9 +1,9 @@ import type { ActionType } from '@rc-component/trigger'; -import Tooltip from 'rc-tooltip'; +import Tooltip from '@rc-component/tooltip'; import type { CSSProperties } from 'react'; import React, { Component } from 'react'; import '../../assets/bootstrap.less'; -import { placements } from '../../src/placements'; +import { placements } from '@rc-component/tooltip/es/placements'; type OffsetType = string | number; diff --git a/docs/examples/twoButtons.tsx b/docs/examples/twoButtons.tsx index 25b39bc3..25ecb2a9 100644 --- a/docs/examples/twoButtons.tsx +++ b/docs/examples/twoButtons.tsx @@ -1,7 +1,7 @@ import { UniqueProvider } from '@rc-component/trigger'; import React from 'react'; import '../../assets/bootstrap.less'; -import Tooltip from '../../src'; +import Tooltip from '@rc-component/tooltip'; const TwoButtonsDemo = () => ( diff --git a/docs/index.md b/docs/index.md index 4c79a7b9..43776f02 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,8 +1,5 @@ --- -hero: - title: rc-tooltip - description: React Tooltip +title: '@rc-component/tooltip' --- - diff --git a/package.json b/package.json index 7789adfc..89633334 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,27 @@ { "name": "@rc-component/tooltip", "version": "1.4.0", - "description": "React Tooltip", + "description": "Tooltip UI component for React", "keywords": [ "react", "react-component", "react-tooltip", "tooltip" ], - "homepage": "http://github.com/react-component/tooltip", + "homepage": "https://react-component.github.io/tooltip", "bugs": { - "url": "http://github.com/react-component/tooltip/issues" + "url": "https://github.com/react-component/tooltip/issues" }, "repository": { "type": "git", - "url": "git@github.com:react-component/tooltip.git" + "url": "https://github.com/react-component/tooltip.git" }, "license": "MIT", "maintainers": [ "yiminghe@gmail.com" ], - "main": "lib/index", - "module": "es/index", + "main": "./lib/index", + "module": "./es/index", "files": [ "lib", "es", @@ -29,16 +29,20 @@ "assets/*.less" ], "scripts": { + "build": "npm run compile && npm run docs:build", "compile": "father build && lessc assets/bootstrap.less assets/bootstrap.css && lessc assets/bootstrap_white.less assets/bootstrap_white.css", + "coverage": "rc-test --coverage", "docs:build": "dumi build", - "docs:deploy": "npm run docs:build && gh-pages -d dist", + "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/ --ext .tsx,.ts,.jsx,.js", - "now-build": "npm run docs:build", - "prepare": "dumi setup", "prepublishOnly": "npm run compile && rc-np", - "postpublish": "npm run docs:build && npm run docs:deploy", + "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", - "test": "rc-test" + "test": "rc-test", + "tsc": "tsc --noEmit", + "prepare": "husky" }, "dependencies": { "@rc-component/trigger": "^3.7.1", @@ -47,27 +51,37 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.3", + "@rc-component/np": "^1.0.4", "@testing-library/jest-dom": "^6.9.1", - "@testing-library/react": "^16.3.0", - "@types/jest": "^29.4.0", - "@types/node": "^22.15.18", - "@types/react": "^19.1.4", - "@types/react-dom": "^19.1.5", - "@types/warning": "^3.0.0", - "dumi": "^2.2.13", - "eslint": "^8.56.0", - "father": "^4.0.0", - "gh-pages": "^6.1.1", - "less": "^4.1.1", - "prettier": "^3.6.2", - "rc-test": "^7.0.9", - "react": "^19.1.0", - "react-dom": "^19.1.0", - "typescript": "^4.0.5" + "@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", + "@types/warning": "^3.0.4", + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "father": "^4.6.23", + "gh-pages": "^6.3.0", + "less": "^4.6.7", + "prettier": "^3.9.0", + "rc-test": "^7.1.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "typescript": "^5.9.3", + "cross-env": "^10.1.0", + "husky": "^9.1.7", + "lint-staged": "^16.4.0" }, "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" + }, + "types": "./es/index.d.ts", + "publishConfig": { + "access": "public" + }, + "lint-staged": { + "*": "prettier --write --ignore-unknown" } } diff --git a/tsconfig.json b/tsconfig.json index f9501603..b22bfce4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,9 @@ "declaration": true, "skipLibCheck": true, "esModuleInterop": true, - "types": ["@testing-library/jest-dom"], + "types": [ + "@testing-library/jest-dom" + ], "paths": { "@/*": [ "src/*" @@ -15,16 +17,28 @@ "@@/*": [ ".dumi/tmp/*" ], - "rc-tooltip": [ + "@rc-component/tooltip": [ "src/index.tsx" + ], + "@rc-component/tooltip/es": [ + "src" + ], + "@rc-component/tooltip/es/*": [ + "src/*" ] - } + }, + "ignoreDeprecations": "5.0" }, "include": [ ".dumirc.ts", - "./src/**/*.ts", - "./src/**/*.tsx", - "./docs/**/*.tsx", - "./tests/**/*.tsx" + ".fatherrc.ts", + "src", + "tests", + "docs/examples" + ], + "exclude": [ + "docs-dist", + "lib", + "es" ] -} \ No newline at end of file +} diff --git a/vercel.json b/vercel.json index 120c2be6..5f9139ef 100644 --- a/vercel.json +++ b/vercel.json @@ -1,14 +1,6 @@ { - "$schema": "https://openapi.vercel.sh/vercel.json", - "version": 2, - "name": "@rc-component/tooltip", - "builds": [ - { - "src": "package.json", - "use": "@vercel/static-build", - "config": { - "distDir": "dist" - } - } - ] -} \ No newline at end of file + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" +}