-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Cascader.Panel support default expand cells #515
Changes from 29 commits
bf253d7
f18f6f3
99e1125
fdcadbb
fc2bc36
5966e56
cecd044
b854548
6765c25
a438e92
a75df6f
7ed02d2
7dc164c
ce2e86e
273f613
2ad949e
e1a0426
0d4290e
67cef8a
07f5596
6c5c1c5
3f03912
f0c9f4c
0b2c795
e83b662
be8679f
bee7389
fa3d22e
7c7f117
5e15a6c
19823ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# 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'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,6 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
|
||
name: ✅ test | ||
on: [push, pull_request] | ||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@master | ||
|
||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '16' | ||
|
||
- name: cache package-lock.json | ||
uses: actions/cache@v2 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: create package-lock.json | ||
run: npm i --package-lock-only | ||
|
||
- name: hack for singe file | ||
run: | | ||
if [ ! -d "package-temp-dir" ]; then | ||
mkdir package-temp-dir | ||
fi | ||
cp package-lock.json package-temp-dir | ||
- name: cache node_modules | ||
id: node_modules_cache_id | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: install | ||
if: steps.node_modules_cache_id.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@master | ||
|
||
- name: restore cache from package-lock.json | ||
uses: actions/cache@v2 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: restore cache from node_modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: lint | ||
run: npm run lint | ||
|
||
needs: setup | ||
|
||
compile: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@master | ||
|
||
- name: restore cache from package-lock.json | ||
uses: actions/cache@v2 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: restore cache from node_modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: compile | ||
run: npm run compile | ||
|
||
needs: setup | ||
|
||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@master | ||
|
||
- name: restore cache from package-lock.json | ||
uses: actions/cache@v2 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: restore cache from node_modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
- name: tsc | ||
run: npm run lint:tsc | ||
- name: coverage | ||
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash) | ||
|
||
needs: setup | ||
test: | ||
uses: react-component/rc-test/.github/workflows/test.yml@main | ||
secrets: inherit |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,6 @@ coverage | |
.dumi/tmp | ||
.dumi/tmp-production | ||
dist | ||
.vscode | ||
.vscode | ||
|
||
bun.lockb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[install] | ||
peer = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: multiple-search | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../../examples/multiple-search.tsx"></code> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import '../assets/index.less'; | ||
import Cascader from '../src'; | ||
|
||
const options = [ | ||
{ | ||
value: 'zhejiang', | ||
label: 'Zhejiang', | ||
children: [ | ||
{ | ||
value: 'hangzhou', | ||
label: 'Hangzhou', | ||
children: [ | ||
{ | ||
value: 'xihu', | ||
label: 'West Lake', | ||
}, | ||
{ | ||
value: 'xiasha', | ||
label: 'Xia Sha', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
value: 'jiangsu', | ||
label: 'Jiangsu', | ||
children: [ | ||
{ | ||
value: 'nanjing', | ||
label: 'Nanjing', | ||
children: [ | ||
{ | ||
value: 'zhonghuamen', | ||
label: 'Zhong Hua men', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
Comment on lines
+5
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议添加类型定义并分离数据
interface CascaderOption {
value: string;
label: string;
children?: CascaderOption[];
}
|
||
|
||
const Demo = () => { | ||
return <Cascader checkable showSearch options={options} />; | ||
}; | ||
|
||
export default Demo; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,8 @@ export default () => { | |
|
||
const [value2, setValue2] = React.useState<string[][]>([]); | ||
|
||
const [disabled, setDisabled] = React.useState(false); | ||
|
||
return ( | ||
<> | ||
<h1>Panel</h1> | ||
|
@@ -71,26 +73,38 @@ export default () => { | |
> | ||
Set Value | ||
</button> | ||
<button | ||
onClick={() => { | ||
setDisabled(prev => !prev); | ||
}} | ||
> | ||
{disabled ? 'enable panel' : 'disable panel'} | ||
</button> | ||
<Cascader.Panel | ||
value={value} | ||
options={addressOptions} | ||
onChange={nextValue => { | ||
console.log('Change:', nextValue); | ||
setValue(nextValue); | ||
}} | ||
disabled={disabled} | ||
/> | ||
|
||
<div>defaultActiveKey=[bj, haidian]</div> | ||
<Cascader.Panel | ||
checkable | ||
value={value2} | ||
options={addressOptions} | ||
onChange={nextValue => { | ||
console.log('Change:', nextValue); | ||
setValue2(nextValue); | ||
console.log('Change:', nextValue); | ||
setValue2(nextValue); | ||
}} | ||
defaultActiveKey={['bj', 'haidian']} | ||
disabled={disabled} | ||
defaultActiveKey={['bj', 'haidian']} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 发现重复的属性设置
建议移除重复的属性: <Cascader.Panel
checkable
value={value2}
options={addressOptions}
onChange={nextValue => {
console.log('Change:', nextValue);
setValue2(nextValue);
}}
defaultActiveKey={['bj', 'haidian']}
disabled={disabled}
- defaultActiveKey={['bj', 'haidian']}
/>
🧰 Tools🪛 Biome[error] 103-104: This JSX property is assigned multiple times. This attribute is assigned again here. (lint/suspicious/noDuplicateJsxProps) 🪛 eslint[error] 104-104: No duplicate props allowed (react/jsx-no-duplicate-props) |
||
/> | ||
|
||
<Cascader.Panel options={addressOptions} direction="rtl" /> | ||
<Cascader.Panel options={addressOptions} disabled={disabled} direction="rtl" /> | ||
|
||
<Cascader.Panel notFoundContent="Empty!!!" /> | ||
</> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
建议使用路径别名优化导入语句
当前的相对路径导入方式可能会在项目结构变化时造成维护困难。建议配置 TypeScript 的 path aliases,使用
@
或类似的别名来简化导入路径。例如: