Skip to content

Commit

Permalink
feat(checkbox): 防止checkbox事件冒泡,collapse 增加 default-expand-all
Browse files Browse the repository at this point in the history
  • Loading branch information
novlan1 committed Jul 17, 2024
1 parent bab6c48 commit e22330e
Show file tree
Hide file tree
Showing 33 changed files with 578 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit
npx --no -- commitlint@18 --edit
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const path = require('path');
const JEST_STYLE_MOCK_FILE = path.resolve(__dirname, 'jest.style-mock.ts');
const JEST_FILE_MOCK_FILE = path.resolve(__dirname, 'jest.file-mock.ts');


module.exports = {
preset: 'ts-jest',
rootDir: path.resolve(__dirname, './'),
Expand All @@ -13,6 +12,7 @@ module.exports = {
'^src/packages/(.*)$': '<rootDir>/packages/press-ui/src/packages/$1',
'^src/pages/(.*)$': '<rootDir>/packages/press-ui/src/pages/$1',
'^src/utils/(.*)$': '<rootDir>/packages/press-ui/src/utils/$1',
'^press-ui/(.*)$': '<rootDir>packages/press-ui/src/packages/$1',
},
transform: {
'\\.(vue)$': 'vue-jest',
Expand Down Expand Up @@ -46,4 +46,5 @@ module.exports = {
collectCoverage: true,
coverageReporters: ['lcov', 'text-summary'],
coverageDirectory: '<rootDir>/tests/coverage',
transformIgnorePatterns: ['<rootDir>/packages/press-ui/node_modules/.pnpm/(?!(@popperjs\\+core)@)'],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "press-ui",
"version": "2.0.7",
"version": "2.0.8",
"description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目",
"private": true,
"repository": {
Expand Down
28 changes: 28 additions & 0 deletions packages/press-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [2.0.8](https://github.com/novlan1/press-ui/compare/v2.0.7...v2.0.8) (2024-07-15)


### ✏️ Documentation | 文档

* **form:** add form docs ([0f03845](https://github.com/novlan1/press-ui/commit/0f03845399ef293c7768a712fb29170c3cb2c27e))
* **pull-refresh:** update docs ([20ebb3a](https://github.com/novlan1/press-ui/commit/20ebb3a97a92e1d33cbca14b3439fc5aa70a3855))


### ✨ Features | 新功能

* **form:** 优化form ([9434ed8](https://github.com/novlan1/press-ui/commit/9434ed8f54be3ddd7d6eb3dcea295fe8bfaf44c9))
* **form:** update form line ([6fe785d](https://github.com/novlan1/press-ui/commit/6fe785dbad00dc8f95c14e9c03e0ac5b4fc4a2a9))


### 🚀 Chore | 构建/工程依赖/工具

* **form:** chore: lint ([347837a](https://github.com/novlan1/press-ui/commit/347837ac0ee2644345696fba8c0c33dc13e25604))
* **form:** update demo ([d96358d](https://github.com/novlan1/press-ui/commit/d96358dcf7006f2308b1a8ffe0026b56b29bdd78))
* **form:** update demo ([b339629](https://github.com/novlan1/press-ui/commit/b339629e349b78d9dfc5276b0240b3ff723ffb6f))
* **pull-refresh:** update demo ([611c804](https://github.com/novlan1/press-ui/commit/611c804a4956dfdb8752d9ddd25833a1fed73d4d))
* update manifestAppIdList ([98f85e3](https://github.com/novlan1/press-ui/commit/98f85e306e0c3188f9f75c85b1d09431d8fea8ed))


### 🐛 Bug Fixes | Bug 修复

* **scripts:** 修复 windows 环境兼容性问题 ([c9f79ad](https://github.com/novlan1/press-ui/commit/c9f79ad332f2a60fa5c2283e6690d6d32781eb3e))

### [2.0.7](https://github.com/novlan1/press-ui/compare/v2.0.6...v2.0.7) (2024-07-12)


Expand Down
28 changes: 28 additions & 0 deletions packages/press-ui/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# 更新日志

### [2.0.8](https://github.com/novlan1/press-ui/compare/v2.0.7...v2.0.8) (2024-07-15)


### Documentation 📖

* **form:** add form docs ([0f03845](https://github.com/novlan1/press-ui/commit/0f03845399ef293c7768a712fb29170c3cb2c27e))
* **pull-refresh:** update docs ([20ebb3a](https://github.com/novlan1/press-ui/commit/20ebb3a97a92e1d33cbca14b3439fc5aa70a3855))


### Features 🎉

* **form:** 优化form ([9434ed8](https://github.com/novlan1/press-ui/commit/9434ed8f54be3ddd7d6eb3dcea295fe8bfaf44c9))
* **form:** update form line ([6fe785d](https://github.com/novlan1/press-ui/commit/6fe785dbad00dc8f95c14e9c03e0ac5b4fc4a2a9))


### Chore 🚀

* **form:** chore: lint ([347837a](https://github.com/novlan1/press-ui/commit/347837ac0ee2644345696fba8c0c33dc13e25604))
* **form:** update demo ([d96358d](https://github.com/novlan1/press-ui/commit/d96358dcf7006f2308b1a8ffe0026b56b29bdd78))
* **form:** update demo ([b339629](https://github.com/novlan1/press-ui/commit/b339629e349b78d9dfc5276b0240b3ff723ffb6f))
* **pull-refresh:** update demo ([611c804](https://github.com/novlan1/press-ui/commit/611c804a4956dfdb8752d9ddd25833a1fed73d4d))
* update manifestAppIdList ([98f85e3](https://github.com/novlan1/press-ui/commit/98f85e306e0c3188f9f75c85b1d09431d8fea8ed))


### Bug Fixes 🐞

* **scripts:** 修复 windows 环境兼容性问题 ([c9f79ad](https://github.com/novlan1/press-ui/commit/c9f79ad332f2a60fa5c2283e6690d6d32781eb3e))

### [2.0.7](https://github.com/novlan1/press-ui/compare/v2.0.6...v2.0.7) (2024-07-12)


Expand Down
2 changes: 1 addition & 1 deletion packages/press-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "press-ui",
"version": "2.0.7",
"version": "2.0.8",
"description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目",
"private": true,
"repository": {
Expand Down
6 changes: 5 additions & 1 deletion packages/press-ui/script/component-config/generate-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ function generateIndexScss() {
const list = glob.sync(globMatch);

result.push(...list.map((item) => {
const relativePath = path.relative(targetDir, item);
let relativePath = path.relative(targetDir, item);
if (process.platform === 'win32') {
relativePath = relativePath.replace(/\\/g, '/');
}

const str = `@import "./${relativePath}";`;
return str;
}));
Expand Down
3 changes: 2 additions & 1 deletion packages/press-ui/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"1112328124",
"1112217302",
"1112240178",
"1112328122"
"1112328122",
"1112377970"
]
},
"mp-alipay": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

function _extends() {
_extends = Object.assign || function (target) {
for (let i = 1; i < arguments.length; i++) {
Expand Down
6 changes: 3 additions & 3 deletions packages/press-ui/src/packages/mixins/relation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export declare function ChildrenMixin(parent: string, options?: Record<string, a
watch: {
disableBindRelation(val: any): void;
};
created(): void;
mounted(): void;
beforeDestroy(): void;
methods: {
bindRelation(this: any): void;
};
created(): void;
mounted(): void;
beforeDestroy(): void;
};
export declare function ParentMixin(parent: string): {
provide(): {
Expand Down
2 changes: 1 addition & 1 deletion packages/press-ui/src/packages/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "press-ui",
"version": "2.0.7",
"version": "2.0.8",
"description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目",
"main": "index.js",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ exports[`renders demo correctly 1`] = `
<div class="press-avatar press-avatar--circle" style="width: 40px; height: 40px; background: rgb(192, 196, 204); margin-right: 20px;">
<!----> <span style="color: rgb(255, 255, 255); text-align: center;">Y</span>
</div>
<div class="press-avatar press-avatar--circle" style="width: 40px; height: 40px; background: rgb(137, 193, 82); margin-right: 20px;">
<div class="press-avatar press-avatar--circle" style="width: 40px; height: 40px; background: rgb(134, 206, 250); margin-right: 20px;">
<!----> <span style="color: rgb(255, 255, 255); text-align: center;">G</span>
</div>
<div class="press-avatar press-avatar--circle" style="width: 40px; height: 40px; background: rgb(152, 209, 238);">
<div class="press-avatar press-avatar--circle" style="width: 40px; height: 40px; background: rgb(119, 177, 204);">
<!----> <span style="color: rgb(255, 255, 255); text-align: center;">杨</span>
</div>
</div>
Expand Down
36 changes: 21 additions & 15 deletions packages/press-ui/src/packages/press-back-top/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@
@scroll="onScroll"
>
<div class="demo-inner">
<PressCheckbox
<press-cell
v-for="(item) of Object.keys(valueMap)"
:key="item"
:value="valueMap[item]"
shape="square"
@change="e => onChange(e, item)"
:title="t(item)"
clickable
@click="valueMap[item] = !valueMap[item]"
>
{{ t(item) }}
</PressCheckbox>
<template #right-icon>
<PressCheckbox
:value="valueMap[item]"
shape="square"
@change="e => onChange(e, item)"
/>
</template>
</press-cell>
</div>
</scroll-view>

Expand Down Expand Up @@ -117,15 +123,15 @@ export default {
}
.demo-inner {
height: calc(100% + 300px);
padding: 10px 20px;
padding: 10px 0px;
::v-deep {
/* #ifdef MP-QQ */
press-checkbox,
/* #endif */
.press-checkbox {
margin-bottom: 12px;
}
}
// ::v-deep {
// /* #ifdef MP-QQ */
// press-checkbox,
// /* #endif */
// .press-checkbox {
// margin-bottom: 12px;
// }
// }
}
</style>
6 changes: 6 additions & 0 deletions packages/press-ui/src/packages/press-cell/css/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
line-height: var(--cell-line-height, $cell-line-height);
}

&--clickable {
/* #ifdef H5 */
cursor: pointer;
/* #endif */
}

// 【修改点】 &--clickable&--hover不能用
&--clickable.press-cell--hover,
&--clickable:active {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<div
v-if="labelPosition === 'left'"
:class="innerLabelClass"
@click="onClickLabel"
@click.stop="onClickLabel"
>
<slot />
</div>
<div
class="press-checkbox__icon-wrap"
@click="toggle"
@click.stop="toggle"
>
<slot
v-if="useIconSlot"
Expand All @@ -31,7 +31,7 @@
<div
v-if="labelPosition === 'right'"
:class="innerLabelClass"
@click="onClickLabel"
@click.stop="onClickLabel"
>
<slot />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div :class="customClass + ' press-collapse-item ' + (index !== 0 ? 'press-hairline--top' : '')">
<!-- 【修改点】cell增加center,垂直居中 -->
<!-- 【修改点】cell 增加 center,垂直居中 -->
<press-cell
:size="size"
:title="title"
Expand All @@ -11,7 +11,6 @@
:is-link="isLink"
:clickable="clickable"
:border="border && expanded"
:class="collapseItemClass"
:custom-class="collapseItemCustomClass"
hover-class="press-cell--hover"
center
Expand Down Expand Up @@ -92,12 +91,13 @@ export default {
},
emits: [],
data() {
const { defaultExpandAll } = this[PARENT];
return {
expanded: false,
expanded: !!defaultExpandAll,
animation: {},
mounted: false,
animationStyle: 'height: 0;',
animationStyle: defaultExpandAll ? 'height: auto;' : 'height: 0;',
};
},
computed: {
Expand All @@ -107,9 +107,7 @@ export default {
},
collapseItemCustomClass() {
let result = '';
// #ifdef MP-ALIPAY
result = this.collapseItemClass;
// #endif
return result;
},
wrapperClass() {
Expand Down
35 changes: 18 additions & 17 deletions packages/press-ui/src/packages/press-collapse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export default {
}
},
methods: {
onChange(event) {
onChange(value) {
this.setData({
activeNames: event.detail,
activeNames: value,
});
},
}
Expand Down Expand Up @@ -84,9 +84,9 @@ export default {
}
},
methods: {
onChange(event) {
onChange(value) {
this.setData({
activeName: event.detail,
activeName: value,
});
},
}
Expand Down Expand Up @@ -124,16 +124,16 @@ export default {
}
},
methods: {
onChange(event) {
onChange(value) {
this.setData({
activeNames: event.detail,
activeNames: value,
});
},
onOpen(event) {
Toast(`展开: ${event.detail}`);
onOpen(value) {
Toast(`展开: ${value}`);
},
onClose(event) {
Toast(`关闭: ${event.detail}`);
onClose(value) {
Toast(`关闭: ${value}`);
},
}
};
Expand Down Expand Up @@ -161,9 +161,9 @@ export default {
}
},
methods: {
onChange(event) {
onChange(value) {
this.setData({
activeNames: event.detail,
activeNames: value,
});
},
}
Expand All @@ -174,11 +174,12 @@ export default {

### Collapse Props

| 参数 | 说明 | 类型 | 默认值 |
| --------- | ------------------- | ---------------------------------------------------------------------- | ------- |
| value | 当前展开面板的 name | 非手风琴模式:_(string \| number)[]_<br>手风琴模式:_string \| number_ | - |
| accordion | 是否开启手风琴模式 | _boolean_ | `false` |
| border | 是否显示外边框 | _boolean_ | `true` |
| 参数 | 说明 | 类型 | 默认值 |
| ------------------ | ------------------- | ---------------------------------------------------------------------- | ------- |
| value | 当前展开面板的 name | 非手风琴模式:_(string \| number)[]_<br>手风琴模式:_string \| number_ | - |
| accordion | 是否开启手风琴模式 | _boolean_ | `false` |
| border | 是否显示外边框 | _boolean_ | `true` |
| default-expand-all | 是否默认展开全部 | _boolean_ | `false` |

### Collapse Event

Expand Down
Loading

0 comments on commit e22330e

Please sign in to comment.