handleSelect(item, index)}
>
{item.icon && (
-
- {item.action && item.action.icon && (
+
item.action?.onClick?.(e)}
>
{item.action.icon}
diff --git a/src/packages/popup/popup.scss b/src/packages/popup/popup.scss
index 51a352ad8a..1dd8ed0577 100644
--- a/src/packages/popup/popup.scss
+++ b/src/packages/popup/popup.scss
@@ -160,13 +160,13 @@
}
}
- &-default-enter-active {
+ &-none-enter-active {
animation-fill-mode: both;
animation-name: popup-scale-fade-in;
animation-duration: $popup-animation-duration;
}
- &-default-exit-active {
+ &-none-exit-active {
animation-fill-mode: both;
animation-name: popup-scale-fade-out;
animation-duration: $popup-animation-duration;
@@ -323,7 +323,7 @@
animation-duration: $popup-animation-duration;
}
- &-default-exit-done,
+ &-none-exit-done,
&-center-exit-done,
&-left-exit-done,
&-right-exit-done,
diff --git a/src/packages/tour/__test__/tour.spec.tsx b/src/packages/tour/__test__/tour.spec.tsx
index bdcfba249f..d1f767f4c6 100644
--- a/src/packages/tour/__test__/tour.spec.tsx
+++ b/src/packages/tour/__test__/tour.spec.tsx
@@ -31,20 +31,22 @@ const steps4 = [
{
content: '70+ 高质量组件,覆盖移动端主流场景',
target: 'target4',
+ location: 'top-left',
},
{
content: '支持一套代码同时开发多端小程序+H5',
target: 'target5',
+ location: 'top-left',
},
{
content: '基于京东APP 10.0 视觉规范',
target: 'target6',
- location: 'top-end',
+ location: 'top-right',
},
{
content: '支持定制主题,内置 700+ 个主题变量',
target: 'target7',
- location: 'top-end',
+ location: 'top-right',
},
]
@@ -52,10 +54,12 @@ test('base render', () => {
const root = document.createElement('div')
root.id = 'target'
const { container } = render(
-
+
)
expect(document.querySelector('.nut-popover')).toBeTruthy()
- expect(document.querySelector('.nut-popover-content-bottom-end')).toBeTruthy()
+ expect(
+ document.querySelector('.nut-popover-content-bottom-right')
+ ).toBeTruthy()
})
test('custom style', () => {
@@ -66,11 +70,10 @@ test('custom style', () => {
visible
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
style={{
'--nutui-popover-content-background-color': 'rgb(255, 0, 0)',
'--nutui-popover-text-color': 'rgb(255, 255, 255)',
- '--nutui-popover-border-color': 'rgb(255, 0, 0)',
}}
offset={[0, 0]}
maskWidth={50}
@@ -91,11 +94,10 @@ test('custom offset', () => {
visible
list={steps2}
type="tile"
- location="bottom-end"
+ location="bottom-right"
style={{
'--nutui-popover-content-background-color': 'rgb(255, 0, 0)',
'--nutui-popover-text-color': 'rgb(255, 255, 255)',
- '--nutui-popover-border-color': 'rgb(255, 0, 0)',
}}
offset={[8, 8]}
/>
@@ -112,12 +114,11 @@ test('slot render', () => {
visible
list={steps3}
type="tile"
- location="bottom-end"
+ location="bottom-right"
offset={[8, 8]}
style={{
'--nutui-popover-content-background-color': 'rgb(75, 76, 77)',
'--nutui-popover-text-color': 'rgb(255, 255, 255)',
- '--nutui-popover-border-color': 'rgb(75, 76, 77)',
}}
>
@@ -135,7 +136,7 @@ test('steps render', async () => {
const root1 = document.createElement('div')
root1.id = 'target5'
const { container } = render(
-
+
)
const btn = document.querySelectorAll(
'.nut-tour-content-bottom-operate-btn'
diff --git a/src/packages/tour/demo.taro.tsx b/src/packages/tour/demo.taro.tsx
index 5d508c9d0d..15bb8ba9e2 100644
--- a/src/packages/tour/demo.taro.tsx
+++ b/src/packages/tour/demo.taro.tsx
@@ -1,6 +1,6 @@
import React from 'react'
import Taro from '@tarojs/taro'
-import { ScrollView, View } from '@tarojs/components'
+import { View } from '@tarojs/components'
import { useTranslate } from '@/sites/assets/locale/taro'
import Header from '@/sites/components/header'
import './demo.scss'
@@ -31,7 +31,7 @@ const TourDemo = () => {
return (
<>
-
{translated.title1}
@@ -44,7 +44,7 @@ const TourDemo = () => {
{translated.title5}
-
+
>
)
}
diff --git a/src/packages/tour/demos/h5/demo1.tsx b/src/packages/tour/demos/h5/demo1.tsx
index ae1938cdc3..9125751890 100644
--- a/src/packages/tour/demos/h5/demo1.tsx
+++ b/src/packages/tour/demos/h5/demo1.tsx
@@ -34,7 +34,7 @@ const Demo1 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
/>
>
)
diff --git a/src/packages/tour/demos/h5/demo2.tsx b/src/packages/tour/demos/h5/demo2.tsx
index 2c65c3db8c..12a414d142 100644
--- a/src/packages/tour/demos/h5/demo2.tsx
+++ b/src/packages/tour/demos/h5/demo2.tsx
@@ -34,11 +34,10 @@ const Demo2 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
style={{
'--nutui-popover-content-background-color': 'rgb(255, 0, 0)',
'--nutui-popover-text-color': 'rgb(255, 255, 255)',
- '--nutui-popover-border-color': 'rgb(255, 0, 0)',
}}
offset={[0, 0]}
maskWidth={50}
diff --git a/src/packages/tour/demos/h5/demo3.tsx b/src/packages/tour/demos/h5/demo3.tsx
index 4b03a63af1..3c992fad8d 100644
--- a/src/packages/tour/demos/h5/demo3.tsx
+++ b/src/packages/tour/demos/h5/demo3.tsx
@@ -48,11 +48,10 @@ const Demo3 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
style={{
'--nutui-popover-content-background-color': 'rgb(255, 0, 0)',
'--nutui-popover-text-color': 'rgb(255, 255, 255)',
- '--nutui-popover-border-color': 'rgb(255, 0, 0)',
}}
offset={[8, 8]}
/>
diff --git a/src/packages/tour/demos/h5/demo4.tsx b/src/packages/tour/demos/h5/demo4.tsx
index 7dd065c214..8ec481ae14 100644
--- a/src/packages/tour/demos/h5/demo4.tsx
+++ b/src/packages/tour/demos/h5/demo4.tsx
@@ -33,7 +33,7 @@ const Demo4 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
offset={[8, 8]}
closeOnOverlayClick={false}
>
diff --git a/src/packages/tour/demos/h5/demo5.tsx b/src/packages/tour/demos/h5/demo5.tsx
index 21ca36d2cd..ab78c0742f 100644
--- a/src/packages/tour/demos/h5/demo5.tsx
+++ b/src/packages/tour/demos/h5/demo5.tsx
@@ -2,7 +2,7 @@ import React, { useState } from 'react'
import { Cell, Tour, Tabbar } from '@nutui/nutui-react'
const Demo5 = () => {
- const [showTour, setShowTour] = useState(true)
+ const [showTour, setShowTour] = useState(false)
const closeTour = () => {
setShowTour(false)
@@ -20,12 +20,12 @@ const Demo5 = () => {
{
content: '基于京东APP 10.0 视觉规范',
target: 'target7',
- location: 'top-end',
+ location: 'top-right',
},
{
content: '支持定制主题,内置 700+ 个主题变量',
target: 'target8',
- location: 'top-end',
+ location: 'top-right',
},
]
@@ -48,7 +48,7 @@ const Demo5 = () => {
visible={showTour}
onClose={closeTour}
list={steps}
- location="top-start"
+ location="top-left"
offset={[0, 0]}
maskWidth={60}
maskHeight={50}
diff --git a/src/packages/tour/demos/taro/demo1.tsx b/src/packages/tour/demos/taro/demo1.tsx
index 86b9c10874..3333e7fc85 100644
--- a/src/packages/tour/demos/taro/demo1.tsx
+++ b/src/packages/tour/demos/taro/demo1.tsx
@@ -34,7 +34,7 @@ const Demo1 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
/>
>
)
diff --git a/src/packages/tour/demos/taro/demo2.tsx b/src/packages/tour/demos/taro/demo2.tsx
index 367f1abcc8..a792a1810d 100644
--- a/src/packages/tour/demos/taro/demo2.tsx
+++ b/src/packages/tour/demos/taro/demo2.tsx
@@ -34,11 +34,10 @@ const Demo2 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
style={{
'--nutui-popover-content-background-color': 'rgb(255, 0, 0)',
'--nutui-popover-text-color': 'rgb(255, 255, 255)',
- '--nutui-popover-border-color': 'rgb(255, 0, 0)',
}}
offset={[0, 0]}
maskWidth={50}
diff --git a/src/packages/tour/demos/taro/demo3.tsx b/src/packages/tour/demos/taro/demo3.tsx
index 67b09d9298..6422eef8bb 100644
--- a/src/packages/tour/demos/taro/demo3.tsx
+++ b/src/packages/tour/demos/taro/demo3.tsx
@@ -49,11 +49,10 @@ const Demo3 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
style={{
'--nutui-popover-content-background-color': 'rgb(255, 0, 0)',
'--nutui-popover-text-color': 'rgb(255, 255, 255)',
- '--nutui-popover-border-color': 'rgb(255, 0, 0)',
}}
offset={[8, 8]}
/>
diff --git a/src/packages/tour/demos/taro/demo4.tsx b/src/packages/tour/demos/taro/demo4.tsx
index ad229d517a..923861b814 100644
--- a/src/packages/tour/demos/taro/demo4.tsx
+++ b/src/packages/tour/demos/taro/demo4.tsx
@@ -34,7 +34,7 @@ const Demo4 = () => {
onClose={closeTour}
list={steps}
type="tile"
- location="bottom-end"
+ location="bottom-right"
offset={[8, 8]}
closeOnOverlayClick={false}
>
diff --git a/src/packages/tour/demos/taro/demo5.tsx b/src/packages/tour/demos/taro/demo5.tsx
index f753040fd1..4d665891c0 100644
--- a/src/packages/tour/demos/taro/demo5.tsx
+++ b/src/packages/tour/demos/taro/demo5.tsx
@@ -2,7 +2,7 @@ import React, { useState } from 'react'
import { Cell, Tour, Tabbar } from '@nutui/nutui-react-taro'
const Demo5 = () => {
- const [showTour, setShowTour] = useState(true)
+ const [showTour, setShowTour] = useState(false)
const closeTour = () => {
setShowTour(false)
@@ -12,20 +12,22 @@ const Demo5 = () => {
{
content: '70+ 高质量组件,覆盖移动端主流场景',
target: 'target5',
+ location: 'top-left',
},
{
content: '支持一套代码同时开发多端小程序+H5',
target: 'target6',
+ location: 'top-left',
},
{
content: '基于京东APP 10.0 视觉规范',
target: 'target7',
- location: 'top-end',
+ location: 'top-right',
},
{
content: '支持定制主题,内置 700+ 个主题变量',
target: 'target8',
- location: 'top-end',
+ location: 'top-right',
},
]
@@ -48,7 +50,7 @@ const Demo5 = () => {
visible={showTour}
onClose={closeTour}
list={steps}
- location="top-start"
+ location="top-left"
offset={[0, 0]}
maskWidth={60}
maskHeight={50}
diff --git a/src/packages/tour/tour.taro.tsx b/src/packages/tour/tour.taro.tsx
index 6648540179..85f4b8c0ff 100644
--- a/src/packages/tour/tour.taro.tsx
+++ b/src/packages/tour/tour.taro.tsx
@@ -91,7 +91,6 @@ export const Tour: FunctionComponent<
const getRootPosition = () => {
getTaroRectById(list[active].target as string).then((rect: any) => {
- console.log('rect', rect)
setMaskRect({
top: rect.top,
left: rect.left,
@@ -122,7 +121,6 @@ export const Tour: FunctionComponent<
) => {
setShowTour(false)
setShowPopup(false)
-
onClose && onClose(e)
}
@@ -162,16 +160,16 @@ export const Tour: FunctionComponent<
? 'nut-tour-mask'
: 'nut-tour-mask nut-tour-mask-none'
}`}
- id="nut-tour-popid"
+ id={`nut-tour-popid${index}`}
style={maskStyle()}
/>
)}
{/* placeholder don't delete <>> */}
diff --git a/src/sites/sites-react/doc/docs/react/migrate-from-v2.en-US.md b/src/sites/sites-react/doc/docs/react/migrate-from-v2.en-US.md
index 5b524d3cb6..171f967fa9 100644
--- a/src/sites/sites-react/doc/docs/react/migrate-from-v2.en-US.md
+++ b/src/sites/sites-react/doc/docs/react/migrate-from-v2.en-US.md
@@ -260,7 +260,12 @@ If your project uses these components, please read the documentation carefully a
[//]: # '#### ImagePreview'
[//]: # '#### NoticeBar'
-[//]: # '#### Popover'
+
+#### Popover
+
+- Deprecated style variables that existed in the documentation have been removed, `--nutui-popover-hover-background-color`、`--nutui-popover-hover-text-color`、`--nutui-popover-border-color`
+- Changed style variable, `--nutui-popover-menu-item-padding` -> `--nutui-popover-padding`,`--nutui-popover-menu-item-width` -> `--nutui-popover-item-width`
+- Revised the data type for `location` to use a unified position type `FullPosition`
#### Price
diff --git a/src/sites/sites-react/doc/docs/react/migrate-from-v2.md b/src/sites/sites-react/doc/docs/react/migrate-from-v2.md
index 61559a9017..88cf0c8259 100644
--- a/src/sites/sites-react/doc/docs/react/migrate-from-v2.md
+++ b/src/sites/sites-react/doc/docs/react/migrate-from-v2.md
@@ -277,7 +277,12 @@ plugins: [
[//]: # '#### ImagePreview'
[//]: # '#### NoticeBar'
-[//]: # '#### Popover'
+
+#### Popover
+
+- 废弃的样式变量,这些变量存在于文档,已删除:`--nutui-popover-hover-background-color`、`--nutui-popover-hover-text-color`、`--nutui-popover-border-color`
+- 变更样式变量 `--nutui-popover-menu-item-padding` 变更为 `--nutui-popover-padding`,`--nutui-popover-menu-item-width` 变更为 `--nutui-popover-item-width`
+- 修订 `location` 的数据类型,使用统一位置类型 `FullPosition`
#### Price
diff --git a/src/sites/sites-react/doc/docs/taro/migrate-from-v2.en-US.md b/src/sites/sites-react/doc/docs/taro/migrate-from-v2.en-US.md
index 5b524d3cb6..171f967fa9 100644
--- a/src/sites/sites-react/doc/docs/taro/migrate-from-v2.en-US.md
+++ b/src/sites/sites-react/doc/docs/taro/migrate-from-v2.en-US.md
@@ -260,7 +260,12 @@ If your project uses these components, please read the documentation carefully a
[//]: # '#### ImagePreview'
[//]: # '#### NoticeBar'
-[//]: # '#### Popover'
+
+#### Popover
+
+- Deprecated style variables that existed in the documentation have been removed, `--nutui-popover-hover-background-color`、`--nutui-popover-hover-text-color`、`--nutui-popover-border-color`
+- Changed style variable, `--nutui-popover-menu-item-padding` -> `--nutui-popover-padding`,`--nutui-popover-menu-item-width` -> `--nutui-popover-item-width`
+- Revised the data type for `location` to use a unified position type `FullPosition`
#### Price
diff --git a/src/sites/sites-react/doc/docs/taro/migrate-from-v2.md b/src/sites/sites-react/doc/docs/taro/migrate-from-v2.md
index fa1bde064e..2b317e987d 100644
--- a/src/sites/sites-react/doc/docs/taro/migrate-from-v2.md
+++ b/src/sites/sites-react/doc/docs/taro/migrate-from-v2.md
@@ -276,7 +276,12 @@ plugins: [
[//]: # '#### ImagePreview'
[//]: # '#### NoticeBar'
-[//]: # '#### Popover'
+
+#### Popover
+
+- 废弃的样式变量,这些变量存在于文档,已删除:`--nutui-popover-hover-background-color`、`--nutui-popover-hover-text-color`、`--nutui-popover-border-color`
+- 变更样式变量 `--nutui-popover-menu-item-padding` 变更为 `--nutui-popover-padding`,`--nutui-popover-menu-item-width` 变更为 `--nutui-popover-item-width`
+- 修订 `location` 的数据类型,使用统一位置类型 `FullPosition`
#### Price
diff --git a/src/styles/variables-jmapp.scss b/src/styles/variables-jmapp.scss
index d0f70b7fab..f4d228c14c 100644
--- a/src/styles/variables-jmapp.scss
+++ b/src/styles/variables-jmapp.scss
@@ -1744,30 +1744,18 @@ $badge-outline-border: var(
//popover(✅)
$popover-border-radius: var(--nutui-popover-border-radius, $radius-s) !default;
$popover-font-size: var(--nutui-popover-font-size, $font-size-base) !default;
-$popover-border-color: var(--nutui-popover-border-color, #ffffff) !default;
$popover-content-background-color: var(
--nutui-popover-content-background-color,
#ffffff
) !default;
$popover-text-color: var(--nutui-popover-text-color, $color-text) !default;
-$popover-hover-background-color: var(
- --nutui-popover-hover-background-color,
- #fff
-) !default;
-$popover-hover-text-color: var(
- --nutui-popover-hover-text-color,
- $color-text
-) !default;
$popover-disable-color: var(
--nutui-popover-disable-color,
$color-text-disabled
) !default;
$popover-divider-color: var(--nutui-popover-divider-color, none) !default;
-$popover-menu-item-padding: var(
- --nutui-popover-menu-item-padding,
- $spacing-xl
-) !default;
-$popover-menu-item-width: var(--nutui-popover-menu-item-width, 160px) !default;
+$popover-padding: var(--nutui-popover-padding, $spacing-xl) !default;
+$popover-item-width: var(--nutui-popover-item-width, 160px) !default;
//progress(✅)
$progress-height: var(--nutui-progress-height, 10px) !default;
diff --git a/src/styles/variables-jrkf.scss b/src/styles/variables-jrkf.scss
index 794cc13d6f..64608ffa0b 100644
--- a/src/styles/variables-jrkf.scss
+++ b/src/styles/variables-jrkf.scss
@@ -1661,29 +1661,18 @@ $badge-dot-border: var(--nutui-badge-dot-border, none) !default;
//popover(✅)
$popover-border-radius: var(--nutui-popover-border-radius, $radius-s) !default;
$popover-font-size: var(--nutui-popover-font-size, $font-size-base) !default;
-$popover-border-color: var(--nutui-popover-border-color, #ffffff) !default;
$popover-content-background-color: var(
--nutui-popover-content-background-color,
#ffffff
) !default;
$popover-text-color: var(--nutui-popover-text-color, $color-text) !default;
-$popover-hover-background-color: var(
- --nutui-popover-hover-background-color,
- #fff
-) !default;
-$popover-hover-text-color: var(
- --nutui-popover-hover-text-color,
- $color-text
-) !default;
$popover-disable-color: var(
--nutui-popover-disable-color,
$color-text-disabled
) !default;
$popover-divider-color: var(--nutui-popover-divider-color, none) !default;
-$popover-menu-item-padding: var(
- --nutui-popover-menu-item-padding,
- $spacing-xl
-) !default;
+$popover-padding: var(--nutui-popover-padding, $spacing-xl) !default;
+$popover-item-width: var(--nutui-popover-item-width, 160px) !default;
//progress(✅)
$progress-height: var(--nutui-progress-height, 10px) !default;
diff --git a/src/styles/variables.scss b/src/styles/variables.scss
index c752653fbe..5813c0a676 100644
--- a/src/styles/variables.scss
+++ b/src/styles/variables.scss
@@ -1631,21 +1631,12 @@ $badge-outline-border: var(
//popover(✅)
$popover-border-radius: var(--nutui-popover-border-radius, $radius-xs) !default;
-$popover-border-color: var(--nutui-popover-border-color, #ffffff) !default;
$popover-font-size: var(--nutui-popover-font-size, $font-size-s) !default;
$popover-content-background-color: var(
--nutui-popover-content-background-color,
#ffffff
) !default;
$popover-text-color: var(--nutui-popover-text-color, $color-mask) !default;
-$popover-hover-background-color: var(
- --nutui-popover-hover-background-color,
- #fff
-) !default;
-$popover-hover-text-color: var(
- --nutui-popover-hover-text-color,
- #1a1a1a
-) !default;
$popover-disable-color: var(
--nutui-popover-disable-color,
$color-text-disabled
@@ -1654,11 +1645,8 @@ $popover-divider-color: var(
--nutui-popover-divider-color,
$color-border
) !default;
-$popover-menu-item-padding: var(
- --nutui-popover-menu-item-padding,
- 8px
-) !default;
-$popover-menu-item-width: var(--nutui-popover-menu-item-width, 160px) !default;
+$popover-padding: var(--nutui-popover-padding, 8px) !default;
+$popover-item-width: var(--nutui-popover-item-width, 160px) !default;
//progress(✅)
$progress-height: var(--nutui-progress-height, 10px) !default;
diff --git a/src/types/spec/popover/base.ts b/src/types/spec/popover/base.ts
index adb5f5e981..816ceab984 100644
--- a/src/types/spec/popover/base.ts
+++ b/src/types/spec/popover/base.ts
@@ -11,6 +11,14 @@ export interface PopoverList {
action?: { icon?: ReactNode; onClick?: (e: any) => void }
}
+export interface WrapperPosition {
+ width: number
+ height: number
+ left: number
+ top: number
+ right: number
+}
+
export type BasePopover = POPUP_PROPS &
BaseProps & {
theme: UITheme
diff --git a/src/utils/get-rect-by-taro.ts b/src/utils/get-rect-by-taro.ts
index 075b737b35..f1c9232459 100644
--- a/src/utils/get-rect-by-taro.ts
+++ b/src/utils/get-rect-by-taro.ts
@@ -1,6 +1,9 @@
import { createSelectorQuery } from '@tarojs/taro'
+import MiniLru from '@/utils/lru'
import { getRect, inBrowser } from '@/hooks/use-client-rect'
+const lru = new MiniLru(10)
+
export interface Rect {
dataset: Record
id: string
@@ -33,10 +36,17 @@ export const getRectByTaro = async (
}
// 小程序下的逻辑
return new Promise((resolve, reject) => {
+ if (lru.has(element)) {
+ resolve(lru.get(element) as Rect)
+ return
+ }
createSelectorQuery()
.select(`#${harmonyId || element.uid}`)
.boundingClientRect()
.exec(([rects]) => {
+ if (rects) {
+ lru.set(element, rects)
+ }
resolve(rects)
})
})
diff --git a/src/utils/lru.ts b/src/utils/lru.ts
new file mode 100644
index 0000000000..1d9cca3381
--- /dev/null
+++ b/src/utils/lru.ts
@@ -0,0 +1,36 @@
+export default class MiniLru {
+ private cache: Map
+
+ private capacity: number
+
+ constructor(capacity: number) {
+ if (capacity <= 0) {
+ throw new Error('Cache capacity must be a positive number')
+ }
+ this.cache = new Map()
+ this.capacity = capacity
+ }
+
+ get(key: any): any | null {
+ if (this.cache.has(key)) {
+ const value = this.cache.get(key)
+ this.cache.delete(key)
+ this.cache.set(key, value)
+ return value
+ }
+ return null
+ }
+
+ set(key: any, value: any): void {
+ if (this.cache.has(key)) {
+ this.cache.delete(key)
+ } else if (this.cache.size >= this.capacity) {
+ this.cache.delete(this.cache.keys().next().value)
+ }
+ this.cache.set(key, value)
+ }
+
+ has(key: any): boolean {
+ return this.cache.has(key)
+ }
+}