Skip to content

Commit eaf379b

Browse files
feat: popover 组件增加新功能 (#1932)
* fix: 修复 ImagePreview 在Taro编译成H5后报错的问题 * fix: 地址关闭时, Close 事件触发两次问题解决 * feat: 组件DatePicker 添加双向绑定 * docs: 组件Picker文档修改 * feat: 组件Picker与DatePicker新增属性safe-area-inset-bottom * feat: imagepreview * fix: 组件imagepreview点击视频遮罩关闭(#1729) * fix: 解决 Picker 在微信小程序中无法使用问题 (#1774) * fix: 修改 Picker 组件 v-model 失效问题 * fix: 组件NoticeBar修改height之后,垂直轮播会卡顿 * fix: 删除Datepicker Demo演示多余内容 * fix: 组件Picker在JD小程序上适配 * fix: 组件Address京东小程序适配 * feat: 京东小程序适配 * fix: 删除空格 * feat: 删除console * fix: 京东小程序imagepreview适配 * fix: 修复 imagepreview 动态设置 initNo 显示不正确问题 * fix: 组件 InfiniteLoading 某些情况下会错误触发下拉刷新#1819 * fix: 删除pullrefresh * feat: 组件 imagepreview瘦身 * feat: 组件Picker 瘦身 * fix: address线上问题修改 * fix: 完善imagepreview * feat: 公共函数提取 * feat: 函数式改用 createComponent * fix: 文件回撤 * feat: 单元测试修改 * fix: 组件popover样式问题修改 * feat: 新增 clamp 函数 * fix: 组件Infiniteloading Review 内容修改 * fix: 组件Infiniteloading问题更新 * feat: getScrollTopRoot函数修改 * feat: 组件popover新增功能
1 parent 1c1d30d commit eaf379b

File tree

11 files changed

+581
-156
lines changed

11 files changed

+581
-156
lines changed

src/packages/__VUE/popover/demo.vue

+55-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</nut-popover>
1212
</nut-col>
1313
<nut-col :span="8">
14-
<nut-popover v-model:visible="darkTheme" theme="dark" :list="iconItemList">
14+
<nut-popover v-model:visible="darkTheme" theme="dark" location="bottom-start" :list="iconItemList">
1515
<template #reference>
1616
<nut-button type="primary" shape="square">{{ translate('dark') }}</nut-button>
1717
</template>
@@ -30,7 +30,7 @@
3030
</nut-popover>
3131
</nut-col>
3232
<nut-col :span="8">
33-
<nut-popover v-model:visible="disableAction" :list="itemListDisabled" location="bottom-end">
33+
<nut-popover v-model:visible="disableAction" :list="itemListDisabled" location="right">
3434
<template #reference>
3535
<nut-button type="primary" shape="square">{{ translate('disableAction') }}</nut-button>
3636
</template>
@@ -60,14 +60,38 @@
6060
<nut-picker v-model:visible="showPicker" :columns="columns" title="" @change="change" :swipe-duration="500">
6161
<template #top>
6262
<div class="brickBox">
63-
<nut-popover v-model:visible="customPositon" :location="curPostion" theme="dark" :list="positionList">
64-
<template #reference>
65-
<div class="brick"></div>
66-
</template>
67-
</nut-popover>
63+
<div class="brick" id="pickerTarget"></div>
6864
</div>
6965
</template>
7066
</nut-picker>
67+
68+
<nut-popover
69+
v-model:visible="customPositon"
70+
targetId="pickerTarget"
71+
:location="curPostion"
72+
theme="dark"
73+
:list="positionList"
74+
>
75+
</nut-popover>
76+
77+
<h2>{{ translate('contentTarget') }}</h2>
78+
<nut-button type="primary" shape="square" id="popid" @click="clickCustomHandle">
79+
{{ translate('contentTarget') }}
80+
</nut-button>
81+
<nut-popover
82+
v-model:visible="customTarget"
83+
targetId="popid"
84+
:list="iconItemList"
85+
location="top-start"
86+
></nut-popover>
87+
88+
<h2>{{ translate('contentColor') }}</h2>
89+
90+
<nut-popover v-model:visible="customColor" :list="iconItemList" location="right-start" bgColor="#f00" theme="dark">
91+
<template #reference>
92+
<nut-button type="primary" shape="square">{{ translate('contentColor') }}</nut-button>
93+
</template>
94+
</nut-popover>
7195
</div>
7296
</template>
7397
<script lang="ts">
@@ -87,7 +111,9 @@ const initTranslate = () =>
87111
dark: '暗黑风格',
88112
showIcon: '展示图标',
89113
disableAction: '禁用选项',
90-
content: '自定义内容'
114+
content: '自定义内容',
115+
contentColor: '自定义颜色',
116+
contentTarget: '自定义对象'
91117
},
92118
'en-US': {
93119
title: 'Basic Usage',
@@ -98,7 +124,9 @@ const initTranslate = () =>
98124
dark: 'dark',
99125
showIcon: 'show icon',
100126
disableAction: 'disabled',
101-
content: 'custom content'
127+
content: 'custom content',
128+
contentColor: 'custom color',
129+
contentTarget: 'custom target'
102130
}
103131
});
104132
export default createDemo({
@@ -116,7 +144,10 @@ export default createDemo({
116144
leftLocation: false, //向左弹出
117145
customPositon: false,
118146
119-
showPicker: false
147+
showPicker: false,
148+
149+
customTarget: false,
150+
customColor: false
120151
});
121152
const curPostion = ref('top');
122153
@@ -220,13 +251,19 @@ export default createDemo({
220251
state.showPicker = true;
221252
setTimeout(() => {
222253
state.customPositon = true;
223-
});
254+
}, 0);
224255
};
225256
226257
const change = ({ selectedValue }) => {
258+
console.log('change');
227259
curPostion.value = selectedValue[0];
228-
state.customPositon = true;
260+
if (state.showPicker) state.customPositon = true;
261+
};
262+
263+
const clickCustomHandle = () => {
264+
state.customTarget = !state.customTarget;
229265
};
266+
230267
return {
231268
iconItemList,
232269
itemList,
@@ -239,7 +276,8 @@ export default createDemo({
239276
translate,
240277
columns,
241278
change,
242-
handlePicker
279+
handlePicker,
280+
clickCustomHandle
243281
};
244282
}
245283
});
@@ -276,8 +314,10 @@ export default createDemo({
276314
}
277315
}
278316
279-
.nut-popover-content {
280-
width: 120px;
317+
.demo {
318+
.nut-popover-content {
319+
width: 120px;
320+
}
281321
}
282322
283323
.customClass {

src/packages/__VUE/popover/doc.en-US.md

+82
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,85 @@ export default {
284284
:::
285285

286286

287+
### custom target
288+
289+
Popover 提供了 `targetId` 属性,用于匹配目标元素,在目标元素上添加对应的 id 值即可
290+
291+
:::demo
292+
```html
293+
<template>
294+
<nut-button type="primary" shape="square" id="popid" @click="clickCustomHandle">custom target</nut-button>
295+
<nut-popover v-model:visible="customTarget" targetId="popid" :list="itemList" location="top-start"></nut-popover>
296+
</template>
297+
298+
<script>
299+
import { reactive, ref } from 'vue';
300+
export default {
301+
setup() {
302+
const visible = ref({
303+
customTarget:false
304+
});
305+
306+
const itemList = reactive([
307+
{name: 'option1'},
308+
{name: 'option2'},
309+
{name: 'option3'}
310+
]);
311+
312+
const clickCustomHandle = () => {
313+
visible.customTarget = !visible.customTarget;
314+
};
315+
316+
return {
317+
itemList,
318+
visible,
319+
clickCustomHandle,
320+
};
321+
}
322+
}
323+
</script>
324+
325+
326+
```
327+
:::
328+
329+
### Custom Color
330+
331+
:::demo
332+
```html
333+
<template>
334+
<nut-popover v-model:visible="customColor" :list="itemList" location="right-start" bgColor="#f00" theme="dark">
335+
<template #reference>
336+
<nut-button type="primary" shape="square" >Custom Color</nut-button>
337+
</template>
338+
</nut-popover>
339+
</template>
340+
341+
<script>
342+
import { reactive, ref } from 'vue';
343+
export default {
344+
setup() {
345+
const visible = ref({
346+
customColor:false
347+
});
348+
349+
const itemList = reactive([
350+
{name: 'option1'},
351+
{name: 'option2'},
352+
{name: 'option3'}
353+
]);
354+
355+
return {
356+
itemList,
357+
visible
358+
};
359+
}
360+
}
361+
</script>
362+
363+
```
364+
:::
365+
287366
## API
288367
### Props
289368

@@ -304,6 +383,9 @@ export default {
304383
| close-on-click-overlay `v3.2.8` | Whether to close when clicking overlay | boolean | true |
305384
| close-on-click-action `v3.2.8` | Whether to close when clicking action | boolean | true |
306385
| close-on-click-outside `v3.2.8` | Whether to close when clicking outside | boolean | true |
386+
| bg-color `v3.3.1` | Custom color | String | - |
387+
| target-id `v3.3.1` | Custom target id | String | - |
388+
| arrow-offset `v3.3.1` | the offset of the arrow | Number | 0 |
307389

308390
### List data structure
309391

src/packages/__VUE/popover/doc.md

+83
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,86 @@ export default {
282282
```
283283
:::
284284

285+
### 自定义目标元素
286+
287+
Popover 提供了 `targetId` 属性,用于匹配目标元素,在目标元素上添加对应的 id 值即可
288+
289+
:::demo
290+
```html
291+
<template>
292+
<nut-button type="primary" shape="square" id="popid" @click="clickCustomHandle">自定义目标元素</nut-button>
293+
<nut-popover v-model:visible="customTarget" targetId="popid" :list="itemList" location="top-start"></nut-popover>
294+
</template>
295+
296+
<script>
297+
import { reactive, ref } from 'vue';
298+
export default {
299+
setup() {
300+
const visible = ref({
301+
customTarget:false
302+
});
303+
304+
const itemList = reactive([
305+
{name: 'option1'},
306+
{name: 'option2'},
307+
{name: 'option3'}
308+
]);
309+
310+
const clickCustomHandle = () => {
311+
visible.customTarget = !visible.customTarget;
312+
};
313+
314+
return {
315+
itemList,
316+
visible,
317+
clickCustomHandle,
318+
};
319+
}
320+
}
321+
</script>
322+
323+
324+
```
325+
:::
326+
327+
### 自定义颜色
328+
329+
Popopver 提供了 2 种主题色,同样可以通过 `bgColor` 属性改变背景色
330+
331+
:::demo
332+
```html
333+
<template>
334+
<nut-popover v-model:visible="customColor" :list="itemList" location="right-start" bgColor="#f00" theme="dark">
335+
<template #reference>
336+
<nut-button type="primary" shape="square" >自定义颜色</nut-button>
337+
</template>
338+
</nut-popover>
339+
</template>
340+
341+
<script>
342+
import { reactive, ref } from 'vue';
343+
export default {
344+
setup() {
345+
const visible = ref({
346+
customColor:false
347+
});
348+
349+
const itemList = reactive([
350+
{name: 'option1'},
351+
{name: 'option2'},
352+
{name: 'option3'}
353+
]);
354+
355+
return {
356+
itemList,
357+
visible
358+
};
359+
}
360+
}
361+
</script>
362+
363+
```
364+
:::
285365

286366
## API
287367
### Props
@@ -303,6 +383,9 @@ export default {
303383
| close-on-click-overlay `v3.2.8` | 是否在点击遮罩层后关闭菜单 | boolean | true |
304384
| close-on-click-action `v3.2.8` | 是否在点击选项后关闭 | boolean | true |
305385
| close-on-click-outside `v3.2.8` | 是否在点击外部元素后关闭菜单 | boolean | true |
386+
| bg-color `v3.3.1` | 自定义背景色 | String | - |
387+
| target-id `v3.3.1` | 自定义目标元素 id | String | - |
388+
| arrow-offset `v3.3.1` | 小箭头的偏移量 | Number | 0 |
306389

307390
### List 数据结构
308391

0 commit comments

Comments
 (0)