-
Notifications
You must be signed in to change notification settings - Fork 269
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: v15 popup #2844
feat: v15 popup #2844
Changes from 13 commits
71e34d2
808e9cc
f19d4a7
39762e1
dce1bc6
563271c
97b0243
3654237
89ecff4
534c260
e70cef6
b9f3aed
307fc95
f565985
ff54e0a
f2f8712
33b8f84
196d4a3
f13ddcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Address: exist defaultIcon & selectIcon 1`] = `"<div class="nut-overlay" style="--nutui-overlay-zIndex: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-title">请选择地址</div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="m512 557.23 279.25 279.25c4.27 4.27 10.88 4.27 14.94 0l30.29-30.29c4.27-4.27 4.27-10.88 0-14.94L557.23 512l279.25-279.25c4.27-4.27 4.27-10.88 0-14.94l-30.29-30.29c-4.27-4.27-10.88-4.27-14.94 0L512 466.77 232.75 187.52c-4.27-4.27-10.88-4.27-14.94 0l-30.29 30.29c-4.27 4.27-4.27 10.88 0 14.94L466.77 512 187.52 791.25c-4.27 4.27-4.27 10.88 0 14.94l30.29 30.29c4.27 4.27 10.88 4.27 14.94 0z" fill="currentColor" fill-opacity="0.9"></path></svg></div></div><div class="nut-address "><ul class="nut-address-exist"><li class="nut-address-exist-item "><div class="default">123</div><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市次渠镇通州区</div></div></li><li class="nut-address-exist-item "><div class="default">123</div><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>钓鱼岛钓鱼岛全区</div></div></li><li class="nut-address-exist-item active"><div class="select">456</div><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市大兴区科创十一街18号院京东大厦</div></div></li></ul></div></div>"`; | ||
exports[`Address: exist defaultIcon & selectIcon 1`] = `"<div class="nut-overlay" style="--nutui-overlay-zIndex: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-wrapper"><div class="nut-popup-title-title">请选择地址</div></div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="m512 557.23 279.25 279.25c4.27 4.27 10.88 4.27 14.94 0l30.29-30.29c4.27-4.27 4.27-10.88 0-14.94L557.23 512l279.25-279.25c4.27-4.27 4.27-10.88 0-14.94l-30.29-30.29c-4.27-4.27-10.88-4.27-14.94 0L512 466.77 232.75 187.52c-4.27-4.27-10.88-4.27-14.94 0l-30.29 30.29c-4.27 4.27-4.27 10.88 0 14.94L466.77 512 187.52 791.25c-4.27 4.27-4.27 10.88 0 14.94l30.29 30.29c4.27 4.27 10.88 4.27 14.94 0z" fill="currentColor" fill-opacity="0.9"></path></svg></div></div><div class="nut-address "><ul class="nut-address-exist"><li class="nut-address-exist-item "><div class="default">123</div><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市次渠镇通州区</div></div></li><li class="nut-address-exist-item "><div class="default">123</div><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>钓鱼岛钓鱼岛全区</div></div></li><li class="nut-address-exist-item active"><div class="select">456</div><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市大兴区科创十一街18号院京东大厦</div></div></li></ul></div></div>"`; | ||
|
||
exports[`Address: show custom 1`] = `"<div class="nut-overlay" style="--nutui-overlay-zIndex: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-left"></div><div class="nut-popup-title-title">选择地址</div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="m512 557.23 279.25 279.25c4.27 4.27 10.88 4.27 14.94 0l30.29-30.29c4.27-4.27 4.27-10.88 0-14.94L557.23 512l279.25-279.25c4.27-4.27 4.27-10.88 0-14.94l-30.29-30.29c-4.27-4.27-10.88-4.27-14.94 0L512 466.77 232.75 187.52c-4.27-4.27-10.88-4.27-14.94 0l-30.29 30.29c-4.27 4.27-4.27 10.88 0 14.94L466.77 512 187.52 791.25c-4.27 4.27-4.27 10.88 0 14.94l30.29 30.29c4.27 4.27 10.88 4.27 14.94 0z" fill="currentColor" fill-opacity="0.9"></path></svg></div></div><div class="nut-cascader "><div class="nut-tabs nut-tabs-horizontal"><div class="nut-tabs-titles nut-tabs-titles-line nut-tabs-titles-scrollable"><div class="nut-tabs-titles-item nut-tabs-titles-item-active"><span class="nut-tabs-titles-item-text">请选择</span><span class="nut-tabs-titles-item-line"></span></div></div><div class="nut-tabs-content-wrap"><div class="nut-tabs-content" style="transform: translate3d(-0%, 0, 0); transition-duration: 300ms;"><div class="nut-tabpane active"><div class="nut-cascader-pane"><div class="nut-cascader-item"><div class="nut-cascader-item-title">浙江</div></div><div class="disabled nut-cascader-item"><div class="nut-cascader-item-title">湖南</div></div><div class="nut-cascader-item"><div class="nut-cascader-item-title">福建</div></div></div></div></div></div></div></div></div>"`; | ||
exports[`Address: show custom 1`] = `"<div class="nut-overlay" style="--nutui-overlay-zIndex: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-wrapper"><div class="nut-popup-title-title">选择地址</div></div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="m512 557.23 279.25 279.25c4.27 4.27 10.88 4.27 14.94 0l30.29-30.29c4.27-4.27 4.27-10.88 0-14.94L557.23 512l279.25-279.25c4.27-4.27 4.27-10.88 0-14.94l-30.29-30.29c-4.27-4.27-10.88-4.27-14.94 0L512 466.77 232.75 187.52c-4.27-4.27-10.88-4.27-14.94 0l-30.29 30.29c-4.27 4.27-4.27 10.88 0 14.94L466.77 512 187.52 791.25c-4.27 4.27-4.27 10.88 0 14.94l30.29 30.29c4.27 4.27 10.88 4.27 14.94 0z" fill="currentColor" fill-opacity="0.9"></path></svg></div></div><div class="nut-cascader "><div class="nut-tabs nut-tabs-horizontal"><div class="nut-tabs-titles nut-tabs-titles-line nut-tabs-titles-scrollable"><div class="nut-tabs-titles-item nut-tabs-titles-item-active"><span class="nut-tabs-titles-item-text">请选择</span><span class="nut-tabs-titles-item-line"></span></div></div><div class="nut-tabs-content-wrap"><div class="nut-tabs-content" style="transform: translate3d(-0%, 0, 0); transition-duration: 300ms;"><div class="nut-tabpane active"><div class="nut-cascader-pane"><div class="nut-cascader-item"><div class="nut-cascader-item-title">浙江</div></div><div class="disabled nut-cascader-item"><div class="nut-cascader-item-title">湖南</div></div><div class="nut-cascader-item"><div class="nut-cascader-item-title">福建</div></div></div></div></div></div></div></div></div>"`; | ||
|
||
exports[`Address: show exist 1`] = `"<div class="nut-overlay" style="--nutui-overlay-zIndex: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-title">选择地址</div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="m512 557.23 279.25 279.25c4.27 4.27 10.88 4.27 14.94 0l30.29-30.29c4.27-4.27 4.27-10.88 0-14.94L557.23 512l279.25-279.25c4.27-4.27 4.27-10.88 0-14.94l-30.29-30.29c-4.27-4.27-10.88-4.27-14.94 0L512 466.77 232.75 187.52c-4.27-4.27-10.88-4.27-14.94 0l-30.29 30.29c-4.27 4.27-4.27 10.88 0 14.94L466.77 512 187.52 791.25c-4.27 4.27-4.27 10.88 0 14.94l30.29 30.29c4.27 4.27 10.88 4.27 14.94 0z" fill="currentColor" fill-opacity="0.9"></path></svg></div></div><div class="nut-address "><ul class="nut-address-exist"><li class="nut-address-exist-item active"><svg class="nut-icon nut-icon-Check " style="color: var(--nutui-color-primary);" xmlns="http://www.w3.org/2000/svg" color="var(--nutui-color-primary)" viewBox="0 0 49 48" aria-labelledby="Check" role="presentation"><path d="M45.121 16.121 47.243 14 43 9.757l-2.121 2.122L19 33.757 7.121 21.88 5 19.757.757 24l2.122 2.121L14.757 38l2.122 2.121L19 42.243l2.121-2.122L23.243 38z" fill="currentColor" fill-opacity="0.9"></path></svg><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市次渠镇通州区</div></div></li><li class="nut-address-exist-item "><svg class="nut-icon nut-icon-Location " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Location" role="presentation"><path d="M533.33 1024s448-232.53 448-576c0-247.47-200.53-448-448-448s-448 200.53-448 448c0 343.47 448 576 448 576m181.12-206.72c-52.91 47.57-105.81 85.33-145.92 111.36a893 893 0 0 1-35.2 21.76 1148.8 1148.8 0 0 1-181.12-133.12C244.05 719.79 149.33 591.79 149.33 448c0-212.05 171.95-384 384-384s384 171.95 384 384c0 143.79-94.72 271.79-202.88 369.28M533.33 640a192 192 0 1 0-.02-384.02 192 192 0 0 0 .02 384.02m0-64c-70.61 0-128-57.39-128-128s57.39-128 128-128 128 57.39 128 128-57.39 128-128 128" fill="currentColor" fill-opacity="0.9"></path></svg><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>钓鱼岛钓鱼岛全区</div></div></li><li class="nut-address-exist-item "><svg class="nut-icon nut-icon-Location " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Location" role="presentation"><path d="M533.33 1024s448-232.53 448-576c0-247.47-200.53-448-448-448s-448 200.53-448 448c0 343.47 448 576 448 576m181.12-206.72c-52.91 47.57-105.81 85.33-145.92 111.36a893 893 0 0 1-35.2 21.76 1148.8 1148.8 0 0 1-181.12-133.12C244.05 719.79 149.33 591.79 149.33 448c0-212.05 171.95-384 384-384s384 171.95 384 384c0 143.79-94.72 271.79-202.88 369.28M533.33 640a192 192 0 1 0-.02-384.02 192 192 0 0 0 .02 384.02m0-64c-70.61 0-128-57.39-128-128s57.39-128 128-128 128 57.39 128 128-57.39 128-128 128" fill="currentColor" fill-opacity="0.9"></path></svg><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市大兴区科创十一街18号院京东大厦</div></div></li></ul></div></div>"`; | ||
exports[`Address: show exist 1`] = `"<div class="nut-overlay" style="--nutui-overlay-zIndex: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-wrapper"><div class="nut-popup-title-title">选择地址</div></div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="m512 557.23 279.25 279.25c4.27 4.27 10.88 4.27 14.94 0l30.29-30.29c4.27-4.27 4.27-10.88 0-14.94L557.23 512l279.25-279.25c4.27-4.27 4.27-10.88 0-14.94l-30.29-30.29c-4.27-4.27-10.88-4.27-14.94 0L512 466.77 232.75 187.52c-4.27-4.27-10.88-4.27-14.94 0l-30.29 30.29c-4.27 4.27-4.27 10.88 0 14.94L466.77 512 187.52 791.25c-4.27 4.27-4.27 10.88 0 14.94l30.29 30.29c4.27 4.27 10.88 4.27 14.94 0z" fill="currentColor" fill-opacity="0.9"></path></svg></div></div><div class="nut-address "><ul class="nut-address-exist"><li class="nut-address-exist-item active"><svg class="nut-icon nut-icon-Check " style="color: var(--nutui-color-primary);" xmlns="http://www.w3.org/2000/svg" color="var(--nutui-color-primary)" viewBox="0 0 49 48" aria-labelledby="Check" role="presentation"><path d="M45.121 16.121 47.243 14 43 9.757l-2.121 2.122L19 33.757 7.121 21.88 5 19.757.757 24l2.122 2.121L14.757 38l2.122 2.121L19 42.243l2.121-2.122L23.243 38z" fill="currentColor" fill-opacity="0.9"></path></svg><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市次渠镇通州区</div></div></li><li class="nut-address-exist-item "><svg class="nut-icon nut-icon-Location " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Location" role="presentation"><path d="M533.33 1024s448-232.53 448-576c0-247.47-200.53-448-448-448s-448 200.53-448 448c0 343.47 448 576 448 576m181.12-206.72c-52.91 47.57-105.81 85.33-145.92 111.36a893 893 0 0 1-35.2 21.76 1148.8 1148.8 0 0 1-181.12-133.12C244.05 719.79 149.33 591.79 149.33 448c0-212.05 171.95-384 384-384s384 171.95 384 384c0 143.79-94.72 271.79-202.88 369.28M533.33 640a192 192 0 1 0-.02-384.02 192 192 0 0 0 .02 384.02m0-64c-70.61 0-128-57.39-128-128s57.39-128 128-128 128 57.39 128 128-57.39 128-128 128" fill="currentColor" fill-opacity="0.9"></path></svg><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>钓鱼岛钓鱼岛全区</div></div></li><li class="nut-address-exist-item "><svg class="nut-icon nut-icon-Location " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Location" role="presentation"><path d="M533.33 1024s448-232.53 448-576c0-247.47-200.53-448-448-448s-448 200.53-448 448c0 343.47 448 576 448 576m181.12-206.72c-52.91 47.57-105.81 85.33-145.92 111.36a893 893 0 0 1-35.2 21.76 1148.8 1148.8 0 0 1-181.12-133.12C244.05 719.79 149.33 591.79 149.33 448c0-212.05 171.95-384 384-384s384 171.95 384 384c0 143.79-94.72 271.79-202.88 369.28M533.33 640a192 192 0 1 0-.02-384.02 192 192 0 0 0 .02 384.02m0-64c-70.61 0-128-57.39-128-128s57.39-128 128-128 128 57.39 128 128-57.39 128-128 128" fill="currentColor" fill-opacity="0.9"></path></svg><div class="nut-address-exist-item-info"><div>探探鱼</div><div>182****1718</div><div>北京市大兴区科创十一街18号院京东大厦</div></div></li></ul></div></div>"`; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -121,19 +121,18 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
const renderLeftOnCustomSwitch = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||||||||||||||||||||||||||
{custom && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<div className={`${classPrefix}-left-icon`} onClick={onSwitchModule}> | ||||||||||||||||||||||||||||||||||||||||||||||||||
{React.isValidElement(backIcon) ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
backIcon | ||||||||||||||||||||||||||||||||||||||||||||||||||
) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<ArrowLeft color="#cccccc" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (custom) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<div className={`${classPrefix}-left-icon`} onClick={onSwitchModule}> | ||||||||||||||||||||||||||||||||||||||||||||||||||
{React.isValidElement(backIcon) ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
backIcon | ||||||||||||||||||||||||||||||||||||||||||||||||||
) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<ArrowLeft color="#cccccc" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
return null | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+124
to
+135
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. 建议:在回调中使用最新状态以避免逻辑错误 当前的 onSwitchModule 函数在更新 currentType 之后,才调用了 onSwitch 回调,但回调参数仍然是之前旧的 currentType 值,这可能导致不符合预期的行为。建议先用一个局部变量存储新的类型,再统一更新并调用回调,以确保回调函数拿到最新的类型值。 可以参考以下修正示例: -const onSwitchModule = () => {
- if (currentType === 'exist') {
- setCurrentType('custom')
- } else {
- setCurrentType('exist')
- }
- onSwitch && onSwitch({ type: currentType })
+const onSwitchModule = () => {
+ const newType = currentType === 'exist' ? 'custom' : 'exist'
+ setCurrentType(newType)
+ onSwitch && onSwitch({ type: newType })
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
const selectedExistItem = (data: AddressList) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
import React, { useState } from 'react' | ||
import { Popup, Cell } from '@nutui/nutui-react' | ||
|
||
const Demo1 = () => { | ||
const [showBasic, setShowBasic] = useState(false) | ||
const Demo = () => { | ||
const [showIcon, setShowIcon] = useState(false) | ||
|
||
return ( | ||
<> | ||
<Cell | ||
title="展示弹出层" | ||
title="基础弹框" | ||
onClick={() => { | ||
setShowBasic(true) | ||
setShowIcon(true) | ||
}} | ||
/> | ||
<Popup | ||
zIndex={2000} | ||
visible={showBasic} | ||
style={{ padding: '30px 50px' }} | ||
closeable | ||
visible={showIcon} | ||
title="标题" | ||
description="这里是副标题这是副标题" | ||
position="bottom" | ||
onClose={() => { | ||
setShowBasic(false) | ||
setShowIcon(false) | ||
}} | ||
/> | ||
</> | ||
) | ||
} | ||
export default Demo1 | ||
export default Demo |
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.
这个文件不提交