From 02ade87963feeb40f3fda4b0fdd13048df3c3e50 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 5 Sep 2019 17:06:58 +0800 Subject: [PATCH] breaking change: remove SwitchCell component (#1968) --- dist/switch-cell/index.d.ts | 1 - dist/switch-cell/index.js | 42 ---------- dist/switch-cell/index.json | 7 -- dist/switch-cell/index.wxml | 25 ------ dist/switch-cell/index.wxss | 1 - docs/markdown/changelog.md | 9 +++ example/app.json | 2 - example/config.js | 4 - example/pages/switch-cell/index.js | 11 --- example/pages/switch-cell/index.json | 3 - example/pages/switch-cell/index.wxml | 31 -------- example/pages/switch-cell/index.wxss | 1 - lib/swipe-cell/index.js | 111 --------------------------- lib/swipe-cell/index.json | 3 - lib/swipe-cell/index.wxml | 20 ----- lib/swipe-cell/index.wxss | 1 - lib/switch-cell/index.js | 44 ----------- lib/switch-cell/index.json | 7 -- lib/switch-cell/index.wxml | 25 ------ lib/switch-cell/index.wxss | 1 - packages/common/style/var.less | 4 - packages/switch-cell/README.md | 91 ---------------------- packages/switch-cell/index.json | 7 -- packages/switch-cell/index.less | 10 --- packages/switch-cell/index.ts | 48 ------------ packages/switch-cell/index.wxml | 25 ------ 26 files changed, 9 insertions(+), 525 deletions(-) delete mode 100644 dist/switch-cell/index.d.ts delete mode 100644 dist/switch-cell/index.js delete mode 100644 dist/switch-cell/index.json delete mode 100644 dist/switch-cell/index.wxml delete mode 100644 dist/switch-cell/index.wxss delete mode 100644 example/pages/switch-cell/index.js delete mode 100644 example/pages/switch-cell/index.json delete mode 100644 example/pages/switch-cell/index.wxml delete mode 100644 example/pages/switch-cell/index.wxss delete mode 100644 lib/swipe-cell/index.js delete mode 100644 lib/swipe-cell/index.json delete mode 100644 lib/swipe-cell/index.wxml delete mode 100644 lib/swipe-cell/index.wxss delete mode 100644 lib/switch-cell/index.js delete mode 100644 lib/switch-cell/index.json delete mode 100644 lib/switch-cell/index.wxml delete mode 100644 lib/switch-cell/index.wxss delete mode 100644 packages/switch-cell/README.md delete mode 100644 packages/switch-cell/index.json delete mode 100644 packages/switch-cell/index.less delete mode 100644 packages/switch-cell/index.ts delete mode 100644 packages/switch-cell/index.wxml diff --git a/dist/switch-cell/index.d.ts b/dist/switch-cell/index.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/dist/switch-cell/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/dist/switch-cell/index.js b/dist/switch-cell/index.js deleted file mode 100644 index 608ce72c..00000000 --- a/dist/switch-cell/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { VantComponent } from '../common/component'; -VantComponent({ - field: true, - props: { - value: null, - icon: String, - title: String, - label: String, - border: Boolean, - checked: Boolean, - loading: Boolean, - disabled: Boolean, - activeColor: String, - inactiveColor: String, - useLabelSlot: Boolean, - size: { - type: String, - value: '24px' - }, - activeValue: { - type: null, - value: true - }, - inactiveValue: { - type: null, - value: false - } - }, - watch: { - checked(value) { - this.set({ value }); - } - }, - created() { - this.set({ value: this.data.checked }); - }, - methods: { - onChange(event) { - this.$emit('change', event.detail); - } - } -}); diff --git a/dist/switch-cell/index.json b/dist/switch-cell/index.json deleted file mode 100644 index 22e53428..00000000 --- a/dist/switch-cell/index.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "component": true, - "usingComponents": { - "van-cell": "../cell/index", - "van-switch": "../switch/index" - } -} diff --git a/dist/switch-cell/index.wxml b/dist/switch-cell/index.wxml deleted file mode 100644 index 49a653e7..00000000 --- a/dist/switch-cell/index.wxml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - diff --git a/dist/switch-cell/index.wxss b/dist/switch-cell/index.wxss deleted file mode 100644 index 2ad612ee..00000000 --- a/dist/switch-cell/index.wxss +++ /dev/null @@ -1 +0,0 @@ -@import '../common/index.wxss';.van-switch-cell{padding-top:9px;padding-bottom:9px}.van-switch-cell__switch{vertical-align:middle} \ No newline at end of file diff --git a/docs/markdown/changelog.md b/docs/markdown/changelog.md index f8364faf..390b3f42 100644 --- a/docs/markdown/changelog.md +++ b/docs/markdown/changelog.md @@ -18,6 +18,11 @@ - `transitionEnd`事件重命名为`transitionend` +##### SwitchCell + +- 移除了`SwitchCell`组件,请使用`Cell`和`Switch`组件代替 + + #### 新特性 ##### Area @@ -47,3 +52,7 @@ - 新增`round`属性 - 新增`closeable`属性 - 新增`close-icon`属性 + +##### Steps + +- 新增`active-icon`属性 diff --git a/example/app.json b/example/app.json index c57f5c29..592b2aba 100644 --- a/example/app.json +++ b/example/app.json @@ -33,7 +33,6 @@ "pages/stepper/index", "pages/steps/index", "pages/switch/index", - "pages/switch-cell/index", "pages/search/index", "pages/slider/index", "pages/sidebar/index", @@ -98,7 +97,6 @@ "van-submit-bar": "./dist/submit-bar/index", "van-swipe-cell": "./dist/swipe-cell/index", "van-switch": "./dist/switch/index", - "van-switch-cell": "./dist/switch-cell/index", "van-tab": "./dist/tab/index", "van-tabs": "./dist/tabs/index", "van-tabbar": "./dist/tabbar/index", diff --git a/example/config.js b/example/config.js index 587d44ec..b11d1da4 100644 --- a/example/config.js +++ b/example/config.js @@ -72,10 +72,6 @@ export default [ { path: '/switch', title: 'Switch 开关' - }, - { - path: '/switch-cell', - title: 'SwitchCell 开关单元格' } ] }, diff --git a/example/pages/switch-cell/index.js b/example/pages/switch-cell/index.js deleted file mode 100644 index d9be1346..00000000 --- a/example/pages/switch-cell/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import Page from '../../common/page'; - -Page({ - data: { - checked: true - }, - - onChange(event) { - this.setData({ checked: event.detail }); - } -}); diff --git a/example/pages/switch-cell/index.json b/example/pages/switch-cell/index.json deleted file mode 100644 index 1655ad94..00000000 --- a/example/pages/switch-cell/index.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "navigationBarTitleText": "SwitchCell 开关单元格" -} diff --git a/example/pages/switch-cell/index.wxml b/example/pages/switch-cell/index.wxml deleted file mode 100644 index 3b87ab3a..00000000 --- a/example/pages/switch-cell/index.wxml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/example/pages/switch-cell/index.wxss b/example/pages/switch-cell/index.wxss deleted file mode 100644 index 2ddba4a1..00000000 --- a/example/pages/switch-cell/index.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/switch-cell/index.wxss */ \ No newline at end of file diff --git a/lib/swipe-cell/index.js b/lib/swipe-cell/index.js deleted file mode 100644 index 8deedb13..00000000 --- a/lib/swipe-cell/index.js +++ /dev/null @@ -1,111 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var component_1 = require("../common/component"); -var touch_1 = require("../mixins/touch"); -var THRESHOLD = 0.3; -component_1.VantComponent({ - props: { - disabled: Boolean, - leftWidth: { - type: Number, - value: 0 - }, - rightWidth: { - type: Number, - value: 0 - }, - asyncClose: Boolean - }, - mixins: [touch_1.touch], - data: { - catchMove: false - }, - created: function () { - this.offset = 0; - }, - methods: { - open: function (position) { - var _a = this.data, leftWidth = _a.leftWidth, rightWidth = _a.rightWidth; - var offset = position === 'left' ? leftWidth : -rightWidth; - this.swipeMove(offset); - }, - close: function () { - this.swipeMove(0); - }, - swipeMove: function (offset) { - if (offset === void 0) { offset = 0; } - this.offset = offset; - var transform = "translate3d(" + offset + "px, 0, 0)"; - var transition = this.draging - ? 'none' - : '.6s cubic-bezier(0.18, 0.89, 0.32, 1)'; - this.set({ - wrapperStyle: "\n -webkit-transform: " + transform + ";\n -webkit-transition: " + transition + ";\n transform: " + transform + ";\n transition: " + transition + ";\n " - }); - }, - swipeLeaveTransition: function () { - var _a = this.data, leftWidth = _a.leftWidth, rightWidth = _a.rightWidth; - var offset = this.offset; - if (rightWidth > 0 && -offset > rightWidth * THRESHOLD) { - this.open('right'); - } - else if (leftWidth > 0 && offset > leftWidth * THRESHOLD) { - this.open('left'); - } - else { - this.swipeMove(0); - } - this.set({ catchMove: false }); - }, - startDrag: function (event) { - if (this.data.disabled) { - return; - } - this.draging = true; - this.startOffset = this.offset; - this.firstDirection = ''; - this.touchStart(event); - }, - noop: function () { }, - onDrag: function (event) { - if (this.data.disabled) { - return; - } - this.touchMove(event); - if (!this.firstDirection) { - this.firstDirection = this.direction; - this.set({ catchMove: this.firstDirection === 'horizontal' }); - } - if (this.firstDirection === 'vertical') { - return; - } - var _a = this.data, leftWidth = _a.leftWidth, rightWidth = _a.rightWidth; - var offset = this.startOffset + this.deltaX; - if ((rightWidth > 0 && -offset > rightWidth) || - (leftWidth > 0 && offset > leftWidth)) { - return; - } - this.swipeMove(offset); - }, - endDrag: function () { - if (this.data.disabled) { - return; - } - this.draging = false; - this.swipeLeaveTransition(); - }, - onClick: function (event) { - var _a = event.currentTarget.dataset.key, position = _a === void 0 ? 'outside' : _a; - this.$emit('click', position); - if (!this.offset) { - return; - } - if (this.data.asyncClose) { - this.$emit('close', { position: position, instance: this }); - } - else { - this.swipeMove(0); - } - } - } -}); diff --git a/lib/swipe-cell/index.json b/lib/swipe-cell/index.json deleted file mode 100644 index 467ce294..00000000 --- a/lib/swipe-cell/index.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "component": true -} diff --git a/lib/swipe-cell/index.wxml b/lib/swipe-cell/index.wxml deleted file mode 100644 index 0ce1e47c..00000000 --- a/lib/swipe-cell/index.wxml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - diff --git a/lib/swipe-cell/index.wxss b/lib/swipe-cell/index.wxss deleted file mode 100644 index d6152709..00000000 --- a/lib/swipe-cell/index.wxss +++ /dev/null @@ -1 +0,0 @@ -@import '../common/index.wxss';.van-swipe-cell{position:relative;overflow:hidden}.van-swipe-cell__left,.van-swipe-cell__right{position:absolute;top:0;height:100%}.van-swipe-cell__left{left:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.van-swipe-cell__right{right:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)} \ No newline at end of file diff --git a/lib/switch-cell/index.js b/lib/switch-cell/index.js deleted file mode 100644 index 48ba2b47..00000000 --- a/lib/switch-cell/index.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var component_1 = require("../common/component"); -component_1.VantComponent({ - field: true, - props: { - value: null, - icon: String, - title: String, - label: String, - border: Boolean, - checked: Boolean, - loading: Boolean, - disabled: Boolean, - activeColor: String, - inactiveColor: String, - useLabelSlot: Boolean, - size: { - type: String, - value: '24px' - }, - activeValue: { - type: null, - value: true - }, - inactiveValue: { - type: null, - value: false - } - }, - watch: { - checked: function (value) { - this.set({ value: value }); - } - }, - created: function () { - this.set({ value: this.data.checked }); - }, - methods: { - onChange: function (event) { - this.$emit('change', event.detail); - } - } -}); diff --git a/lib/switch-cell/index.json b/lib/switch-cell/index.json deleted file mode 100644 index 22e53428..00000000 --- a/lib/switch-cell/index.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "component": true, - "usingComponents": { - "van-cell": "../cell/index", - "van-switch": "../switch/index" - } -} diff --git a/lib/switch-cell/index.wxml b/lib/switch-cell/index.wxml deleted file mode 100644 index 49a653e7..00000000 --- a/lib/switch-cell/index.wxml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - diff --git a/lib/switch-cell/index.wxss b/lib/switch-cell/index.wxss deleted file mode 100644 index 2ad612ee..00000000 --- a/lib/switch-cell/index.wxss +++ /dev/null @@ -1 +0,0 @@ -@import '../common/index.wxss';.van-switch-cell{padding-top:9px;padding-bottom:9px}.van-switch-cell__switch{vertical-align:middle} \ No newline at end of file diff --git a/packages/common/style/var.less b/packages/common/style/var.less index 64969de4..c26e6a74 100644 --- a/packages/common/style/var.less +++ b/packages/common/style/var.less @@ -108,10 +108,6 @@ @switch-disabled-opacity: .4; @switch-border: 1px solid rgba(0, 0, 0, .1); -// SwitchCell -@switch-cell-padding-top: 9px; -@switch-cell-padding-bottom: 9px; - // Toast @toast-max-width: 70%; @toast-font-size: 14px; diff --git a/packages/switch-cell/README.md b/packages/switch-cell/README.md deleted file mode 100644 index 370880b9..00000000 --- a/packages/switch-cell/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# SwitchCell 开关单元格 - -### 引入 -在`app.json`或`index.json`中引入组件,默认为`ES6`版本,`ES5`引入方式参见[快速上手](#/quickstart) - -```json -"usingComponents": { - "van-switch-cell": "path/to/vant-weapp/dist/switch-cell/index" -} -``` - -## 代码演示 - -### 基础用法 - -```html - -``` - -```javascript -Page({ - data: { - checked: true - }, - - onChange(event) { - // 需要手动对 checked 状态进行更新 - this.setData({ checked: event.detail }); - } -}); -``` - -### 禁用状态 -通过`disabled`属性可以将组件设置为禁用状态 - -```html - -``` - -### 加载状态 -通过`loading`属性可以将组件设置为加载状态 - -```html - -``` - -### Props - -| 参数 | 说明 | 类型 | 默认值 | -|-----------|-----------|-----------|-------------| -| name | 在表单内提交时的标识符 | *string* | - | -| checked | 开关状态 | *any* | `false` | -| icon | 左侧图标名称或图片链接,可选值见 Icon 组件 | *string* | - | -| title | 左侧标题 | *string* | `''` | -| label | 标题下方的描述信息 | *string* | - | -| loading | 是否为加载状态 | *boolean* | `false` | -| disabled | 是否为禁用状态 | *boolean* | `false` | -| size | 开关尺寸 | *string* | `24px` | -| active-color | 开关打开时的背景色 | *string* | `#1989fa` | -| inactive-color | 开关关闭时的背景色 | *string* | `#fff` | -| active-value | 打开时的值 | *any* | `true` | -| inactive-value | 关闭时的值 | *any* | `false` | -| use-label-slot | 是否使用 label slot | *boolean* | `false` | - -### Events - -| 事件名 | 说明 | 参数 | -|-----------|-----------|-----------| -| bind:change | 开关状态切换回调 | event.detail: 是否选中开关 | - -### Slot - -| 名称 | 说明 | -|-----------|-----------| -| title | 自定义`title`显示内容,如果设置了`title`属性则不生效 | -| label | 自定义`label`显示内容,需要设置 `use-label-slot`属性 | -| icon | 自定义`icon`显示内容,如果设置了`icon`属性则不生效 | diff --git a/packages/switch-cell/index.json b/packages/switch-cell/index.json deleted file mode 100644 index 22e53428..00000000 --- a/packages/switch-cell/index.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "component": true, - "usingComponents": { - "van-cell": "../cell/index", - "van-switch": "../switch/index" - } -} diff --git a/packages/switch-cell/index.less b/packages/switch-cell/index.less deleted file mode 100644 index 098675f3..00000000 --- a/packages/switch-cell/index.less +++ /dev/null @@ -1,10 +0,0 @@ -@import '../common/style/var.less'; - -.van-switch-cell { - padding-top: @switch-cell-padding-top; - padding-bottom: @switch-cell-padding-bottom; - - &__switch { - vertical-align: middle; - } -} diff --git a/packages/switch-cell/index.ts b/packages/switch-cell/index.ts deleted file mode 100644 index af2c40d0..00000000 --- a/packages/switch-cell/index.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { VantComponent } from '../common/component'; -import { Weapp } from 'definitions/weapp'; - -VantComponent({ - field: true, - - props: { - value: null, - icon: String, - title: String, - label: String, - border: Boolean, - checked: Boolean, - loading: Boolean, - disabled: Boolean, - activeColor: String, - inactiveColor: String, - useLabelSlot: Boolean, - size: { - type: String, - value: '24px' - }, - activeValue: { - type: null, - value: true - }, - inactiveValue: { - type: null, - value: false - } - }, - - watch: { - checked(value) { - this.set({ value }); - } - }, - - created() { - this.set({ value: this.data.checked }); - }, - - methods: { - onChange(event: Weapp.Event) { - this.$emit('change', event.detail); - } - } -}); diff --git a/packages/switch-cell/index.wxml b/packages/switch-cell/index.wxml deleted file mode 100644 index 49a653e7..00000000 --- a/packages/switch-cell/index.wxml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - -