Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1c90c46
chore: standardize repository setup
afc163 Jun 26, 2026
452068e
chore: address review feedback
afc163 Jun 26, 2026
bbb3e00
chore: remove cloudflare preview and now-build
afc163 Jun 26, 2026
d16b8eb
docs: standardize README release details
afc163 Jun 26, 2026
54fe98b
ci: make surge preview non-blocking
afc163 Jun 26, 2026
21186bb
ci: keep surge preview as fallback
afc163 Jun 26, 2026
53adbf1
docs: refine README usage and ecosystem note
afc163 Jun 27, 2026
fc0d148
ci: isolate surge preview token
afc163 Jun 27, 2026
0065a00
docs: add Chinese README
afc163 Jun 27, 2026
cac19fa
docs: add Ant Design logo to README
afc163 Jun 27, 2026
75efcea
docs: refine bilingual README branding
afc163 Jun 27, 2026
918507b
chore: standardize rc tooling and docs
afc163 Jun 27, 2026
ca1d70c
chore: address standardization review comments
afc163 Jun 27, 2026
def709c
chore: include father config in type checks
afc163 Jun 27, 2026
2027ffa
ci: update GitHub Actions versions
afc163 Jun 28, 2026
73add1c
ci: use resolvable CodeQL action ref
afc163 Jun 28, 2026
703ca12
fix: align dropdown docs and open class handling
afc163 Jun 28, 2026
2baf8c9
fix: preserve dropdown fallback wrapper class
afc163 Jun 28, 2026
efdbd3c
fix: simplify dropdown fallback child handling
afc163 Jun 28, 2026
73ec933
ci: use actions checkout v7
afc163 Jun 28, 2026
b384a3c
chore: standardize package metadata
afc163 Jun 28, 2026
e1f71d2
ci: standardize dependabot updates
afc163 Jun 28, 2026
060ebe8
chore: refine preview workflow ignores
afc163 Jun 28, 2026
c1d6f2f
docs: document dumi dev server port
afc163 Jun 28, 2026
4b90abe
chore: standardize husky configuration
afc163 Jun 28, 2026
903d8eb
docs: align readme badge layout
afc163 Jun 28, 2026
5146bcf
chore: standardize package type entry
afc163 Jun 28, 2026
af3de5a
docs: normalize readme badges
afc163 Jun 28, 2026
5b3778d
ci: limit reusable workflow secrets
afc163 Jun 28, 2026
1ee8ad8
ci: restore reusable workflow compatibility
afc163 Jun 28, 2026
38493da
ci: narrow surge preview permissions
afc163 Jun 28, 2026
8ee3fec
chore: limit reusable workflow secrets
afc163 Jun 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .dumirc.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// more config: https://d.umijs.org/config
import { defineConfig } from 'dumi';

const basePath = process.env.GH_PAGES ? '/dropdown/' : '/';
const publicPath = basePath;

export default defineConfig({
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
themeConfig: {
name: 'rc-dropdown',
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
},
outputPath: '.docs',
outputPath: 'docs-dist',
base: basePath,
publicPath,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
exportStatic: {},
styles: [
`
Expand Down
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: ant-design
open_collective: ant-design
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

jobs:
CI:
uses: react-component/rc-test/.github/workflows/test.yml@main
uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
secrets: inherit

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
22 changes: 12 additions & 10 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ "master" ]
branches: ['master']
pull_request:
branches: [ "master" ]
branches: ['master']
schedule:
- cron: "38 3 * * 6"
- cron: '38 3 * * 6'

jobs:
analyze:
Expand All @@ -20,22 +20,24 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ javascript ]
language: [javascript]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
persist-credentials: false

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444
with:
category: "/language:${{ matrix.language }}"
category: '/language:${{ matrix.language }}'
27 changes: 27 additions & 0 deletions .github/workflows/react-doctor.yml
Original file line number Diff line number Diff line change
@@ -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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
fetch-depth: 0
persist-credentials: false
- uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3
52 changes: 52 additions & 0 deletions .github/workflows/surge-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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
statuses: write

jobs:
preview:
runs-on: ubuntu-latest
env:
PREVIEW: true
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
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."
192 changes: 71 additions & 121 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,143 +1,92 @@
# @rc-component/dropdown
<div align="center">
<h1>@rc-component/dropdown</h1>
<p><sub><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /> Part of the Ant Design ecosystem.</sub></p>
<p>🔽 A trigger-driven dropdown component for React.</p>
</div>

react dropdown component.
<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>


<div align="center">

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

</div>

[npm-image]: https://img.shields.io/npm/v/@rc-component/dropdown.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@rc-component/dropdown
[travis-image]: https://img.shields.io/travis/react-component/dropdown/master?style=flat-square
[travis-url]: https://travis-ci.com/react-component/dropdown
[github-actions-image]: https://github.com/react-component/dropdown/actions/workflows/ci.yml/badge.svg
[github-actions-url]: https://github.com/react-component/dropdown/actions/workflows/ci.yml
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/dropdown/master.svg?style=flat-square
[codecov-url]: https://app.codecov.io/gh/react-component/dropdown
[david-url]: https://david-dm.org/react-component/dropdown
[david-image]: https://david-dm.org/react-component/dropdown/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/dropdown?type=dev
[david-dev-image]: https://david-dm.org/react-component/dropdown/dev-status.svg?style=flat-square
[download-image]: https://img.shields.io/npm/dm/@rc-component/dropdown.svg?style=flat-square
[download-url]: https://npmjs.org/package/@rc-component/dropdown
[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fdropdown?style=flat-square
[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/dropdown
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/dropdown
[dumi-url]: https://github.com/umijs/dumi
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
[dumi-url]: https://github.com/umijs/dumi

## Highlights

## Screenshot
- Built on `@rc-component/trigger`.
- Supports hover, click, context menu, and custom trigger actions.
- Accepts a React element or render function as dropdown overlay.
- Supports align point behavior and trigger-width matching.

![](https://t.alipayobjects.com/images/rmsweb/T1bWpgXgBaXXXXXXXX.png)
## Install

## Example
```bash
npm install @rc-component/dropdown
```

online example: http://react-component.github.io/dropdown/examples/
## Usage

## install
```tsx | pure
import Dropdown from '@rc-component/dropdown';
import '@rc-component/dropdown/assets/index.css';

export default function App() {
return (
<Dropdown overlay={<div>Dropdown content</div>} trigger={['click']}>
<button type="button">Open</button>
</Dropdown>
);
}
```

[![@rc-component/dropdown](https://nodei.co/npm/@rc-component/dropdown.png)](https://npmjs.org/package/@rc-component/dropdown)
## Examples

## Usage
Run the local dumi site:

```js
var Dropdown = require('@rc-component/dropdown');
// use dropdown
```bash
npm install
npm start
```

Then open `http://localhost:8000`.

## API

### props

<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>overlayClassName</td>
<td>String</td>
<td></td>
<td>additional css class of root dom node</td>
</tr>
<tr>
<td>openClassName</td>
<td>String</td>
         <td>`${prefixCls}-open`</td>
         <td>className of trigger when dropdown is opened</td>
</tr>
<tr>
<td>prefixCls</td>
<td>String</td>
<td>rc-dropdown</td>
<td>prefix class name</td>
</tr>
<tr>
<td>transitionName</td>
<td>String</td>
<td></td>
<td>dropdown menu's animation css class name</td>
</tr>
<tr>
<td>animation</td>
<td>String</td>
<td></td>
<td>part of dropdown menu's animation css class name</td>
</tr>
<tr>
<td>placement</td>
<td>String</td>
<td>bottomLeft</td>
<td>Position of menu item. There are: top, topCenter, topRight, bottomLeft, bottom, bottomRight </td>
</tr>
<tr>
<td>onVisibleChange</td>
<td>Function</td>
<td></td>
<td>call when visible is changed</td>
</tr>
<tr>
<td>visible</td>
<td>boolean</td>
<td></td>
<td>whether tooltip is visible</td>
</tr>
<tr>
<td>defaultVisible</td>
<td>boolean</td>
<td></td>
<td>whether tooltip is visible initially</td>
</tr>
<tr>
<td>overlay</td>
<td>rc-menu</td>
<td></td>
<td><a href="https://github.com/react-component/menu">rc-menu</a> element</td>
</tr>
<tr>
<td>onOverlayClick</td>
<td>function(e)</td>
<td></td>
<td>call when overlay is clicked</td>
</tr>
<tr>
<td>minOverlayWidthMatchTrigger</td>
<td>boolean</td>
         <td>true (false when set alignPoint)</td>
         <td>whether overlay's width must not be less than trigger's </td>
</tr>
<tr>
<td>getPopupContainer</td>
<td>Function(menuDOMNode): HTMLElement</td>
<th>() => document.body</th>
<td>Where to render the DOM node of dropdown</td>
</tr>
</tbody>
</table>

Note: Additional props are passed into the underlying [rc-trigger](https://github.com/react-component/trigger) component. This can be useful for example, to display the dropdown in a separate [portal](https://reactjs.org/docs/portals.html)-driven window via the `getDocument()` rc-trigger prop.
Additional props are passed to the underlying [`@rc-component/trigger`](https://github.com/react-component/trigger) component.

| Property | Description | Type | Default |
| --- | --- | --- | --- |
| alignPoint | Align popup to the click point | boolean | false |
| animation | Popup animation name | string | - |
| defaultVisible | Initial visible state | boolean | - |
| getPopupContainer | Container where dropdown is rendered | `(node: HTMLElement) => HTMLElement` | `() => document.body` |
| minOverlayWidthMatchTrigger | Whether overlay width should be at least trigger width | boolean | `true` unless `alignPoint` is set |
| openClassName | Class name added to trigger when dropdown is open | string | `${prefixCls}-open` |
| overlay | Dropdown overlay | `React.ReactElement \| (() => React.ReactElement)` | - |
| overlayClassName | Additional overlay class name | string | - |
| overlayStyle | Overlay style | `React.CSSProperties` | - |
| placement | Dropdown placement | string | `bottomLeft` |
| prefixCls | Component class name prefix | string | `rc-dropdown` |
| transitionName | Popup transition class name | string | - |
| trigger | Trigger action | `ActionType \| ActionType[]` | `['hover']` |
| visible | Controlled visible state | boolean | - |
| onOverlayClick | Callback when overlay is clicked | `(event: React.MouseEvent) => void` | - |
| onVisibleChange | Callback when visibility changes | `(visible: boolean) => void` | - |
Comment thread
coderabbitai[bot] marked this conversation as resolved.

## Development

Expand All @@ -146,21 +95,22 @@ npm install
npm start
```

## Test Case

```bash
npm test
npm run chrome-test
npm run tsc
npm run lint
npm run compile
npm run build
```

## Coverage
## Release

```bash
npm run coverage
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-component/dropdown is released under the MIT license.
@rc-component/dropdown is released under the [MIT](./LICENSE) license.
Loading
Loading