mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-25 19:06:36 +08:00
Merge branch 'dev' into next
This commit is contained in:
commit
437dcc6c41
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vant/area-data",
|
"name": "@vant/area-data",
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"description": "Vant 省市区数据",
|
"description": "Vant 省市区数据",
|
||||||
"main": "dist/index.cjs.js",
|
"main": "dist/index.cjs.js",
|
||||||
"module": "dist/index.esm.js",
|
"module": "dist/index.esm.js",
|
||||||
|
@ -509,15 +509,14 @@ export const areaList = {
|
|||||||
130471: '邯郸经济技术开发区',
|
130471: '邯郸经济技术开发区',
|
||||||
130473: '邯郸冀南新区',
|
130473: '邯郸冀南新区',
|
||||||
130481: '武安市',
|
130481: '武安市',
|
||||||
130502: '桥东区',
|
130502: '襄都区',
|
||||||
130503: '桥西区',
|
130503: '信都区',
|
||||||
130521: '邢台县',
|
130505: '任泽区',
|
||||||
|
130506: '南和区',
|
||||||
130522: '临城县',
|
130522: '临城县',
|
||||||
130523: '内丘县',
|
130523: '内丘县',
|
||||||
130524: '柏乡县',
|
130524: '柏乡县',
|
||||||
130525: '隆尧县',
|
130525: '隆尧县',
|
||||||
130526: '任县',
|
|
||||||
130527: '南和县',
|
|
||||||
130528: '宁晋县',
|
130528: '宁晋县',
|
||||||
130529: '巨鹿县',
|
130529: '巨鹿县',
|
||||||
130530: '新河县',
|
130530: '新河县',
|
||||||
|
@ -16,7 +16,8 @@ const DEFAULT_CONFIG = {
|
|||||||
setupFilesAfterEnv: [JEST_SETUP_FILE],
|
setupFilesAfterEnv: [JEST_SETUP_FILE],
|
||||||
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
|
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
|
||||||
transform: {
|
transform: {
|
||||||
'\\.(js|jsx|ts|tsx|vue)$': '<rootDir>/node_modules/@vant/cli/cjs/jest.transformer.cjs',
|
'\\.(js|jsx|ts|tsx|vue)$':
|
||||||
|
'<rootDir>/node_modules/@vant/cli/cjs/jest.transformer.cjs',
|
||||||
},
|
},
|
||||||
transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'],
|
transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'],
|
||||||
snapshotSerializers: ['jest-serializer-html'],
|
snapshotSerializers: ['jest-serializer-html'],
|
||||||
|
@ -27,12 +27,12 @@ button
|
|||||||
| transform | boolean | 防止预览区内 fixed 定位的元素飞出预览区 |
|
| transform | boolean | 防止预览区内 fixed 定位的元素飞出预览区 |
|
||||||
| inline | boolean | 只显示组件本身,不显示预览区边框和代码 |
|
| inline | boolean | 只显示组件本身,不显示预览区边框和代码 |
|
||||||
|
|
||||||
|
|
||||||
### `compact`
|
### `compact`
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<demo-code compact>./demo/MyDemo.vue</demo-code>
|
<demo-code compact>./demo/MyDemo.vue</demo-code>
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### `transform`
|
### `transform`
|
||||||
@ -40,6 +40,7 @@ button
|
|||||||
```html
|
```html
|
||||||
<demo-code transform>./demo/MyDemo.vue</demo-code>
|
<demo-code transform>./demo/MyDemo.vue</demo-code>
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### `inline`
|
### `inline`
|
||||||
@ -47,6 +48,7 @@ button
|
|||||||
```html
|
```html
|
||||||
<demo-code inline>./demo/MyDemo.vue</demo-code>
|
<demo-code inline>./demo/MyDemo.vue</demo-code>
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 去除手机模拟器
|
### 去除手机模拟器
|
||||||
@ -79,5 +81,4 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
```
|
```
|
@ -18,10 +18,9 @@
|
|||||||
<% if (baiduAnalytics) { %>
|
<% if (baiduAnalytics) { %>
|
||||||
<script>
|
<script>
|
||||||
var _hmt = _hmt || [];
|
var _hmt = _hmt || [];
|
||||||
(function() {
|
(function () {
|
||||||
var hm = document.createElement('script');
|
var hm = document.createElement('script');
|
||||||
hm.src =
|
hm.src = 'https://hm.baidu.com/hm.js?<%= baiduAnalytics.seed %>';
|
||||||
'https://hm.baidu.com/hm.js?<%= baiduAnalytics.seed %>';
|
|
||||||
var s = document.getElementsByTagName('script')[0];
|
var s = document.getElementsByTagName('script')[0];
|
||||||
s.parentNode.insertBefore(hm, s);
|
s.parentNode.insertBefore(hm, s);
|
||||||
})();
|
})();
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
path:
|
path: 'M296.114 508.035c-3.22-13.597.473-28.499 11.079-39.105l333.912-333.912c16.271-16.272 42.653-16.272 58.925 0s16.272 42.654 0 58.926L395.504 498.47l304.574 304.574c16.272 16.272 16.272 42.654 0 58.926s-42.654 16.272-58.926 0L307.241 528.058a41.472 41.472 0 0 1-11.127-20.023z',
|
||||||
'M296.114 508.035c-3.22-13.597.473-28.499 11.079-39.105l333.912-333.912c16.271-16.272 42.653-16.272 58.925 0s16.272 42.654 0 58.926L395.504 498.47l304.574 304.574c16.272 16.272 16.272 42.654 0 58.926s-42.654 16.272-58.926 0L307.241 528.058a41.472 41.472 0 0 1-11.127-20.023z',
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'App',
|
name: 'App',
|
||||||
@ -7,6 +7,6 @@ export default defineComponent({
|
|||||||
<>
|
<>
|
||||||
<h1>App</h1>
|
<h1>App</h1>
|
||||||
</>
|
</>
|
||||||
)
|
);
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const a = 1
|
const a = 1;
|
||||||
a = 1
|
a = 1;
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
arr: [1, 2, 3]
|
arr: [1, 2, 3],
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
const a = b + 1
|
const a = b + 1;
|
||||||
export default a
|
export default a;
|
||||||
|
8
packages/vant-icons/src/config.d.ts
vendored
8
packages/vant-icons/src/config.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
declare const config: {
|
declare const config: {
|
||||||
name: string;
|
name: string;
|
||||||
basic: string[];
|
basic: string[];
|
||||||
outline: string[];
|
outline: string[];
|
||||||
filled: string[];
|
filled: string[];
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
|
@ -1281,9 +1281,9 @@ new-github-release-url@1.0.0:
|
|||||||
type-fest "^0.4.1"
|
type-fest "^0.4.1"
|
||||||
|
|
||||||
node-fetch@^2.6.1:
|
node-fetch@^2.6.1:
|
||||||
version "2.6.6"
|
version "2.6.7"
|
||||||
resolved "https://registry.npmmirror.com/node-fetch/download/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
|
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
|
||||||
integrity sha1-F1GnwBg06OFpd1hzLp77burfr4k=
|
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
whatwg-url "^5.0.0"
|
whatwg-url "^5.0.0"
|
||||||
|
|
||||||
@ -1794,7 +1794,7 @@ to-regex-range@^5.0.1:
|
|||||||
|
|
||||||
tr46@~0.0.3:
|
tr46@~0.0.3:
|
||||||
version "0.0.3"
|
version "0.0.3"
|
||||||
resolved "https://registry.npmmirror.com/tr46/download/tr46-0.0.3.tgz?cache=0&sync_timestamp=1633303287861&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Ftr46%2Fdownload%2Ftr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
|
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
|
||||||
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
|
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
|
||||||
|
|
||||||
tslib@~2.1.0:
|
tslib@~2.1.0:
|
||||||
@ -1887,12 +1887,12 @@ wcwidth@^1.0.1:
|
|||||||
|
|
||||||
webidl-conversions@^3.0.0:
|
webidl-conversions@^3.0.0:
|
||||||
version "3.0.1"
|
version "3.0.1"
|
||||||
resolved "https://registry.npmmirror.com/webidl-conversions/download/webidl-conversions-3.0.1.tgz?cache=0&sync_timestamp=1632753508689&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fwebidl-conversions%2Fdownload%2Fwebidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
|
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
|
||||||
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=
|
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=
|
||||||
|
|
||||||
whatwg-url@^5.0.0:
|
whatwg-url@^5.0.0:
|
||||||
version "5.0.0"
|
version "5.0.0"
|
||||||
resolved "https://registry.npmmirror.com/whatwg-url/download/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
|
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
|
||||||
integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0=
|
integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0=
|
||||||
dependencies:
|
dependencies:
|
||||||
tr46 "~0.0.3"
|
tr46 "~0.0.3"
|
||||||
|
@ -20,7 +20,7 @@ export type VueAttribute = {
|
|||||||
name: string;
|
name: string;
|
||||||
default: string;
|
default: string;
|
||||||
description: string;
|
description: string;
|
||||||
options: string[]
|
options: string[];
|
||||||
value: {
|
value: {
|
||||||
kind: 'expression';
|
kind: 'expression';
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -21,8 +21,8 @@ export function normalizePath(path: string): string {
|
|||||||
return path.replace(/\\/g, '/');
|
return path.replace(/\\/g, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// `default` `primary` -> ['default', 'primary']
|
// `default` `primary` -> ['default', 'primary']
|
||||||
export function formatOptions(options?: string) {
|
export function formatOptions(options?: string) {
|
||||||
if (!options) return []
|
if (!options) return [];
|
||||||
return options.replace(/`/g, '').split(' ')
|
return options.replace(/`/g, '').split(' ');
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v1.3.5
|
||||||
|
|
||||||
|
- Fix useChildren missing subTree when flattening vnodes
|
||||||
|
|
||||||
## v1.3.4
|
## v1.3.4
|
||||||
|
|
||||||
- Fix useClickAway failed in SSR
|
- Fix useClickAway failed in SSR
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vant/use",
|
"name": "@vant/use",
|
||||||
"version": "1.3.4",
|
"version": "1.3.5",
|
||||||
"description": "Vant Composition API",
|
"description": "Vant Composition API",
|
||||||
"main": "dist/index.cjs.js",
|
"main": "dist/index.cjs.js",
|
||||||
"module": "dist/index.esm.js",
|
"module": "dist/index.esm.js",
|
||||||
|
@ -6,9 +6,8 @@ export type CustomFieldInjectionValue = {
|
|||||||
validateWithTrigger: (trigger: 'onBlur' | 'onChange' | 'onSubmit') => void;
|
validateWithTrigger: (trigger: 'onBlur' | 'onChange' | 'onSubmit') => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CUSTOM_FIELD_INJECTION_KEY: InjectionKey<CustomFieldInjectionValue> = Symbol(
|
export const CUSTOM_FIELD_INJECTION_KEY: InjectionKey<CustomFieldInjectionValue> =
|
||||||
'van-field'
|
Symbol('van-field');
|
||||||
);
|
|
||||||
|
|
||||||
export function useCustomFieldValue(customValue: () => unknown) {
|
export function useCustomFieldValue(customValue: () => unknown) {
|
||||||
const field = inject(CUSTOM_FIELD_INJECTION_KEY, null);
|
const field = inject(CUSTOM_FIELD_INJECTION_KEY, null);
|
||||||
|
@ -20,6 +20,7 @@ export function flattenVNodes(children: VNodeNormalizedChildren) {
|
|||||||
result.push(child);
|
result.push(child);
|
||||||
|
|
||||||
if (child.component?.subTree) {
|
if (child.component?.subTree) {
|
||||||
|
result.push(child.component.subTree);
|
||||||
traverse(child.component.subTree.children);
|
traverse(child.component.subTree.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ export default {
|
|||||||
setup() {
|
setup() {
|
||||||
const root = ref();
|
const root = ref();
|
||||||
|
|
||||||
onMounted(()=>{
|
onMounted(() => {
|
||||||
const rect = useRect(root);
|
const rect = useRect(root);
|
||||||
console.log(rect); // -> 元素的大小及其相对于视口的位置
|
console.log(rect); // -> 元素的大小及其相对于视口的位置
|
||||||
})
|
});
|
||||||
|
|
||||||
return { root };
|
return { root };
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-width: 0; // hack for flex ellipsis
|
min-width: 0; // hack for flex ellipsis
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&--disabled {
|
&--disabled {
|
||||||
.van-dropdown-menu__title {
|
.van-dropdown-menu__title {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
.van-icon {
|
.van-icon {
|
||||||
&__image {
|
&__image {
|
||||||
|
display: block;
|
||||||
width: 1em;
|
width: 1em;
|
||||||
height: 1em;
|
height: 1em;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
|
@ -86,7 +86,6 @@
|
|||||||
z-index: var(--van-image-preview-close-icon-z-index);
|
z-index: var(--van-image-preview-close-icon-z-index);
|
||||||
color: var(--van-image-preview-close-icon-color);
|
color: var(--van-image-preview-close-icon-color);
|
||||||
font-size: var(--van-image-preview-close-icon-size);
|
font-size: var(--van-image-preview-close-icon-size);
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&--top-left {
|
&--top-left {
|
||||||
top: var(--van-image-preview-close-icon-margin);
|
top: var(--van-image-preview-close-icon-margin);
|
||||||
|
@ -62,7 +62,6 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0 var(--van-padding-md);
|
padding: 0 var(--van-padding-md);
|
||||||
font-size: var(--van-font-size-md);
|
font-size: var(--van-font-size-md);
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__left {
|
&__left {
|
||||||
|
@ -72,7 +72,6 @@
|
|||||||
font-size: var(--van-number-keyboard-close-font-size);
|
font-size: var(--van-number-keyboard-close-font-size);
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__sidebar {
|
&__sidebar {
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
font-size: var(--van-picker-action-font-size);
|
font-size: var(--van-picker-action-font-size);
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__confirm {
|
&__confirm {
|
||||||
|
@ -114,7 +114,6 @@
|
|||||||
z-index: var(--van-popup-close-icon-z-index);
|
z-index: var(--van-popup-close-icon-z-index);
|
||||||
color: var(--van-popup-close-icon-color);
|
color: var(--van-popup-close-icon-color);
|
||||||
font-size: var(--van-popup-close-icon-size);
|
font-size: var(--van-popup-close-icon-size);
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&--top-left {
|
&--top-left {
|
||||||
top: var(--van-popup-close-icon-margin);
|
top: var(--van-popup-close-icon-margin);
|
||||||
|
@ -61,7 +61,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
background: var(--van-stepper-background);
|
background: var(--van-stepper-background);
|
||||||
border: 0;
|
border: 0;
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
|
@ -30,8 +30,12 @@
|
|||||||
padding-bottom: env(safe-area-inset-bottom);
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-haptics-feedback:active {
|
.van-haptics-feedback {
|
||||||
opacity: var(--van-active-opacity);
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: var(--van-active-opacity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[class*='van-hairline'] {
|
[class*='van-hairline'] {
|
||||||
|
@ -15,7 +15,7 @@ exports[`should render Tab inside a component correctly 1`] = `
|
|||||||
aria-controls="van-tab"
|
aria-controls="van-tab"
|
||||||
>
|
>
|
||||||
<span class="van-tab__text van-tab__text--ellipsis">
|
<span class="van-tab__text van-tab__text--ellipsis">
|
||||||
2
|
1
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="van-tabs-1"
|
<div id="van-tabs-1"
|
||||||
@ -26,7 +26,7 @@ exports[`should render Tab inside a component correctly 1`] = `
|
|||||||
aria-controls="van-tab"
|
aria-controls="van-tab"
|
||||||
>
|
>
|
||||||
<span class="van-tab__text van-tab__text--ellipsis">
|
<span class="van-tab__text van-tab__text--ellipsis">
|
||||||
1
|
2
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="van-tabs-2"
|
<div id="van-tabs-2"
|
||||||
@ -47,15 +47,6 @@ exports[`should render Tab inside a component correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-tabs__content">
|
<div class="van-tabs__content">
|
||||||
<div id="van-tab"
|
|
||||||
role="tabpanel"
|
|
||||||
class="van-tab__panel"
|
|
||||||
tabindex="0"
|
|
||||||
aria-labelledby="van-tabs-1"
|
|
||||||
style
|
|
||||||
>
|
|
||||||
1
|
|
||||||
</div>
|
|
||||||
<div id="van-tab"
|
<div id="van-tab"
|
||||||
role="tabpanel"
|
role="tabpanel"
|
||||||
class="van-tab__panel"
|
class="van-tab__panel"
|
||||||
@ -64,6 +55,15 @@ exports[`should render Tab inside a component correctly 1`] = `
|
|||||||
style="display: none;"
|
style="display: none;"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="van-tab"
|
||||||
|
role="tabpanel"
|
||||||
|
class="van-tab__panel"
|
||||||
|
tabindex="0"
|
||||||
|
aria-labelledby="van-tabs-1"
|
||||||
|
style
|
||||||
|
>
|
||||||
|
2
|
||||||
|
</div>
|
||||||
<div id="van-tab"
|
<div id="van-tab"
|
||||||
role="tabpanel"
|
role="tabpanel"
|
||||||
class="van-tab__panel"
|
class="van-tab__panel"
|
||||||
|
@ -5,7 +5,12 @@ import {
|
|||||||
type CSSProperties,
|
type CSSProperties,
|
||||||
type ExtractPropTypes,
|
type ExtractPropTypes,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import { truthProp, makeStringProp, createNamespace } from '../utils';
|
import {
|
||||||
|
truthProp,
|
||||||
|
makeStringProp,
|
||||||
|
createNamespace,
|
||||||
|
HAPTICS_FEEDBACK,
|
||||||
|
} from '../utils';
|
||||||
import { Icon } from '../icon';
|
import { Icon } from '../icon';
|
||||||
|
|
||||||
const [name, bem] = createNamespace('tag');
|
const [name, bem] = createNamespace('tag');
|
||||||
@ -66,7 +71,11 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CloseIcon = closeable && (
|
const CloseIcon = closeable && (
|
||||||
<Icon name="cross" class={bem('close')} onClick={onClose} />
|
<Icon
|
||||||
|
name="cross"
|
||||||
|
class={[bem('close'), HAPTICS_FEEDBACK]}
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -111,6 +111,5 @@
|
|||||||
|
|
||||||
&__close {
|
&__close {
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
<transition-stub>
|
<transition-stub>
|
||||||
<span class="van-tag van-tag--medium van-tag--primary">
|
<span class="van-tag van-tag--medium van-tag--primary">
|
||||||
Tag
|
Tag
|
||||||
<i class="van-badge__wrapper van-icon van-icon-cross van-tag__close">
|
<i class="van-badge__wrapper van-icon van-icon-cross van-tag__close van-haptics-feedback">
|
||||||
</i>
|
</i>
|
||||||
</span>
|
</span>
|
||||||
</transition-stub>
|
</transition-stub>
|
||||||
|
@ -112,9 +112,10 @@ export default defineComponent({
|
|||||||
|
|
||||||
const onSidebarChange = (index: number) => {
|
const onSidebarChange = (index: number) => {
|
||||||
emit('update:mainActiveIndex', index);
|
emit('update:mainActiveIndex', index);
|
||||||
emit('click-nav', index);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onClickSidebarItem = (index: number) => emit('click-nav', index);
|
||||||
|
|
||||||
const renderSidebar = () => {
|
const renderSidebar = () => {
|
||||||
const Items = props.items.map((item) => (
|
const Items = props.items.map((item) => (
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
@ -123,6 +124,7 @@ export default defineComponent({
|
|||||||
badge={item.badge}
|
badge={item.badge}
|
||||||
class={[bem('nav-item'), item.className]}
|
class={[bem('nav-item'), item.className]}
|
||||||
disabled={item.disabled}
|
disabled={item.disabled}
|
||||||
|
onClick={onClickSidebarItem}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -26,7 +26,23 @@ test('should render empty TreeSelect correctly', () => {
|
|||||||
expect(mount(TreeSelect).html()).toMatchSnapshot();
|
expect(mount(TreeSelect).html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should emit click-nav event when nav item is clicked', () => {
|
test('should emit update:mainActiveIndex event when mainActiveIndex is changed', async () => {
|
||||||
|
const wrapper = mount(TreeSelect, {
|
||||||
|
props: {
|
||||||
|
items: mockItems,
|
||||||
|
mainActiveIndex: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const navItems = wrapper.findAll('.van-tree-select__nav-item');
|
||||||
|
await navItems[0].trigger('click');
|
||||||
|
expect(wrapper.emitted('update:mainActiveIndex')).toBeFalsy();
|
||||||
|
|
||||||
|
await navItems[1].trigger('click');
|
||||||
|
expect(wrapper.emitted('update:mainActiveIndex')?.[0]).toEqual([1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should emit click-nav event when nav item is clicked', async () => {
|
||||||
const wrapper = mount(TreeSelect, {
|
const wrapper = mount(TreeSelect, {
|
||||||
props: {
|
props: {
|
||||||
items: mockItems,
|
items: mockItems,
|
||||||
@ -34,9 +50,10 @@ test('should emit click-nav event when nav item is clicked', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const navItems = wrapper.findAll('.van-tree-select__nav-item');
|
const navItems = wrapper.findAll('.van-tree-select__nav-item');
|
||||||
navItems[1].trigger('click');
|
await navItems[0].trigger('click');
|
||||||
expect(wrapper.emitted('update:mainActiveIndex')?.[0]).toEqual([1]);
|
expect(wrapper.emitted('click-nav')?.[0]).toEqual([0]);
|
||||||
expect(wrapper.emitted('click-nav')?.[0]).toEqual([1]);
|
await navItems[0].trigger('click');
|
||||||
|
expect(wrapper.emitted('click-nav')?.[1]).toEqual([0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should emit click-item event when item is clicked', () => {
|
test('should emit click-item event when item is clicked', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user