@tuya-miniapp/smart-ui 2.6.0-beta-21 → 2.6.0-beta-22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stepper/index.css +1 -1
- package/dist/stepper/index.js +23 -8
- package/dist/stepper/index.wxml +2 -2
- package/dist/stepper/index.wxs +10 -0
- package/dist/stepper/index.wxss +1 -1
- package/lib/stepper/index.css +1 -1
- package/lib/stepper/index.js +24 -8
- package/lib/stepper/index.wxml +2 -2
- package/lib/stepper/index.wxs +10 -0
- package/lib/stepper/index.wxss +1 -1
- package/package.json +1 -1
package/dist/stepper/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
@import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{
|
1
|
+
@import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{color:var(--stepper-button-disabled-icon-color,var(--app-B6-N7,rgba(0,0,0,.1)))}.smart-stepper__minus--disabled,.smart-stepper__minus--disabled.smart-stepper__minus--hover,.smart-stepper__minus--disabled.smart-stepper__plus--hover,.smart-stepper__plus--disabled,.smart-stepper__plus--disabled.smart-stepper__minus--hover,.smart-stepper__plus--disabled.smart-stepper__plus--hover{background-color:var(--stepper-button-disabled-color,var(--app-B6,#fff))}.smart-stepper--round .smart-stepper__input{background-color:initial!important}.smart-stepper--round .smart-stepper__minus,.smart-stepper--round .smart-stepper__plus{border-radius:100%}.smart-stepper--round .smart-stepper__minus:active,.smart-stepper--round .smart-stepper__plus:active{opacity:.7}.smart-stepper--round .smart-stepper__minus--disabled,.smart-stepper--round .smart-stepper__minus--disabled:active,.smart-stepper--round .smart-stepper__plus--disabled,.smart-stepper--round .smart-stepper__plus--disabled:active{opacity:.3}.smart-stepper--round .smart-stepper__plus{background-color:var(--stepper-button-round-theme-color,#ee0a24);color:#fff}.smart-stepper--round .smart-stepper__minus{background-color:#fff;border:1px solid var(--stepper-button-round-theme-color,#ee0a24);color:var(--stepper-button-round-theme-color,#ee0a24)}.smart-stepper__input{-webkit-appearance:none;border:0;border-radius:0;border-width:1px 0;box-sizing:border-box;color:var(--stepper-input-text-color,var(--app-B6-N1,#000));display:inline-block;font-size:var(--stepper-input-font-size,16px);height:var(--stepper-input-height,28px);min-height:0;padding:1px;text-align:center;vertical-align:middle;width:var(--stepper-input-width,50px)}.smart-stepper__input--disabled{color:var(--stepper-input-disabled-text-color,var(--app-B6-N7,rgba(0,0,0,.1)))}
|
package/dist/stepper/index.js
CHANGED
@@ -69,6 +69,7 @@ SmartComponent({
|
|
69
69
|
currentValue: '',
|
70
70
|
Minus,
|
71
71
|
Plus,
|
72
|
+
isInit: false,
|
72
73
|
},
|
73
74
|
watch: {
|
74
75
|
value() {
|
@@ -76,14 +77,25 @@ SmartComponent({
|
|
76
77
|
},
|
77
78
|
},
|
78
79
|
created() {
|
80
|
+
const currentValue = this.format(this.data.value, true);
|
81
|
+
if (currentValue !== this.data.value) {
|
82
|
+
this.$emit('change', currentValue);
|
83
|
+
}
|
79
84
|
this.setData({
|
80
|
-
currentValue
|
85
|
+
currentValue,
|
86
|
+
isInit: true,
|
81
87
|
});
|
82
88
|
},
|
83
89
|
methods: {
|
84
90
|
observeValue() {
|
85
|
-
const { value } = this.data;
|
86
|
-
|
91
|
+
const { value, isInit } = this.data;
|
92
|
+
if (!isInit)
|
93
|
+
return;
|
94
|
+
const currentValue = this.format(value, true);
|
95
|
+
if (currentValue !== value) {
|
96
|
+
this.$emit('change', currentValue);
|
97
|
+
}
|
98
|
+
this.setData({ currentValue });
|
87
99
|
},
|
88
100
|
check() {
|
89
101
|
const val = this.format(this.data.currentValue);
|
@@ -102,7 +114,7 @@ SmartComponent({
|
|
102
114
|
this.$emit('focus', event.detail);
|
103
115
|
},
|
104
116
|
onBlur(event) {
|
105
|
-
const value = this.format(event.detail.value);
|
117
|
+
const value = this.format(event.detail.value, true);
|
106
118
|
this.setData({ currentValue: value });
|
107
119
|
this.emitChange(value);
|
108
120
|
this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value }));
|
@@ -116,13 +128,16 @@ SmartComponent({
|
|
116
128
|
return value;
|
117
129
|
},
|
118
130
|
// limit value range
|
119
|
-
format(value) {
|
131
|
+
format(value, isFormatAll = false) {
|
120
132
|
value = this.filter(value);
|
121
133
|
// format range
|
122
134
|
value = value === '' ? 0 : +value;
|
123
|
-
value = Math.
|
135
|
+
value = Math.min(this.data.max, value);
|
136
|
+
if (isFormatAll) {
|
137
|
+
value = Math.max(value, this.data.min);
|
138
|
+
}
|
124
139
|
// format decimal
|
125
|
-
if (isDef(this.data.decimalLength)) {
|
140
|
+
if (isDef(this.data.decimalLength) && isFormatAll) {
|
126
141
|
value = value.toFixed(this.data.decimalLength);
|
127
142
|
}
|
128
143
|
return value;
|
@@ -149,7 +164,7 @@ SmartComponent({
|
|
149
164
|
return;
|
150
165
|
}
|
151
166
|
const diff = type === 'minus' ? -this.data.step : +this.data.step;
|
152
|
-
const value = this.format(add(+this.data.currentValue, diff));
|
167
|
+
const value = this.format(add(+this.data.currentValue, diff), true);
|
153
168
|
this.emitChange(value);
|
154
169
|
this.$emit(type);
|
155
170
|
ty.vibrateShort({ type: 'light' });
|
package/dist/stepper/index.wxml
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
wx:if="{{ showMinus }}"
|
7
7
|
data-type="minus"
|
8
8
|
style="{{ computed.buttonStyle({ buttonSize }) }}"
|
9
|
-
class="minus-class {{ utils.bem('stepper__minus', { disabled:
|
9
|
+
class="minus-class {{ utils.bem('stepper__minus', { disabled: computed.checkMin({ min, currentValue, disabled, disableMinus }) }) }}"
|
10
10
|
hover-class="smart-stepper__minus--hover"
|
11
11
|
hover-stay-time="70"
|
12
12
|
bind:tap="onTap"
|
@@ -32,7 +32,7 @@
|
|
32
32
|
wx:if="{{ showPlus }}"
|
33
33
|
data-type="plus"
|
34
34
|
style="{{ computed.buttonStyle({ buttonSize }) }}"
|
35
|
-
class="plus-class {{ utils.bem('stepper__plus', { disabled:
|
35
|
+
class="plus-class {{ utils.bem('stepper__plus', { disabled: computed.checkMax({ max, currentValue, disabled, disablePlus }) }) }}"
|
36
36
|
hover-class="smart-stepper__plus--hover"
|
37
37
|
hover-stay-time="70"
|
38
38
|
bind:tap="onTap"
|
package/dist/stepper/index.wxs
CHANGED
@@ -16,7 +16,17 @@ function inputStyle(data) {
|
|
16
16
|
});
|
17
17
|
}
|
18
18
|
|
19
|
+
function checkMin(data) {
|
20
|
+
return data.currentValue <= Number(data.min) || data.disabled || data.disableMinus
|
21
|
+
}
|
22
|
+
|
23
|
+
function checkMax(data) {
|
24
|
+
return data.currentValue >= Number(data.max) || data.disabled || data.disablePlus
|
25
|
+
}
|
26
|
+
|
19
27
|
module.exports = {
|
20
28
|
buttonStyle: buttonStyle,
|
21
29
|
inputStyle: inputStyle,
|
30
|
+
checkMin: checkMin,
|
31
|
+
checkMax: checkMax,
|
22
32
|
};
|
package/dist/stepper/index.wxss
CHANGED
@@ -1 +1 @@
|
|
1
|
-
@import '../common/index.wxss';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{
|
1
|
+
@import '../common/index.wxss';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{color:var(--stepper-button-disabled-icon-color,var(--app-B6-N7,rgba(0,0,0,.1)))}.smart-stepper__minus--disabled,.smart-stepper__minus--disabled.smart-stepper__minus--hover,.smart-stepper__minus--disabled.smart-stepper__plus--hover,.smart-stepper__plus--disabled,.smart-stepper__plus--disabled.smart-stepper__minus--hover,.smart-stepper__plus--disabled.smart-stepper__plus--hover{background-color:var(--stepper-button-disabled-color,var(--app-B6,#fff))}.smart-stepper--round .smart-stepper__input{background-color:initial!important}.smart-stepper--round .smart-stepper__minus,.smart-stepper--round .smart-stepper__plus{border-radius:100%}.smart-stepper--round .smart-stepper__minus:active,.smart-stepper--round .smart-stepper__plus:active{opacity:.7}.smart-stepper--round .smart-stepper__minus--disabled,.smart-stepper--round .smart-stepper__minus--disabled:active,.smart-stepper--round .smart-stepper__plus--disabled,.smart-stepper--round .smart-stepper__plus--disabled:active{opacity:.3}.smart-stepper--round .smart-stepper__plus{background-color:var(--stepper-button-round-theme-color,#ee0a24);color:#fff}.smart-stepper--round .smart-stepper__minus{background-color:#fff;border:1px solid var(--stepper-button-round-theme-color,#ee0a24);color:var(--stepper-button-round-theme-color,#ee0a24)}.smart-stepper__input{-webkit-appearance:none;border:0;border-radius:0;border-width:1px 0;box-sizing:border-box;color:var(--stepper-input-text-color,var(--app-B6-N1,#000));display:inline-block;font-size:var(--stepper-input-font-size,16px);height:var(--stepper-input-height,28px);min-height:0;padding:1px;text-align:center;vertical-align:middle;width:var(--stepper-input-width,50px)}.smart-stepper__input--disabled{color:var(--stepper-input-disabled-text-color,var(--app-B6-N7,rgba(0,0,0,.1)))}
|
package/lib/stepper/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
@import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{
|
1
|
+
@import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{color:var(--stepper-button-disabled-icon-color,var(--app-B6-N7,rgba(0,0,0,.1)))}.smart-stepper__minus--disabled,.smart-stepper__minus--disabled.smart-stepper__minus--hover,.smart-stepper__minus--disabled.smart-stepper__plus--hover,.smart-stepper__plus--disabled,.smart-stepper__plus--disabled.smart-stepper__minus--hover,.smart-stepper__plus--disabled.smart-stepper__plus--hover{background-color:var(--stepper-button-disabled-color,var(--app-B6,#fff))}.smart-stepper--round .smart-stepper__input{background-color:initial!important}.smart-stepper--round .smart-stepper__minus,.smart-stepper--round .smart-stepper__plus{border-radius:100%}.smart-stepper--round .smart-stepper__minus:active,.smart-stepper--round .smart-stepper__plus:active{opacity:.7}.smart-stepper--round .smart-stepper__minus--disabled,.smart-stepper--round .smart-stepper__minus--disabled:active,.smart-stepper--round .smart-stepper__plus--disabled,.smart-stepper--round .smart-stepper__plus--disabled:active{opacity:.3}.smart-stepper--round .smart-stepper__plus{background-color:var(--stepper-button-round-theme-color,#ee0a24);color:#fff}.smart-stepper--round .smart-stepper__minus{background-color:#fff;border:1px solid var(--stepper-button-round-theme-color,#ee0a24);color:var(--stepper-button-round-theme-color,#ee0a24)}.smart-stepper__input{-webkit-appearance:none;border:0;border-radius:0;border-width:1px 0;box-sizing:border-box;color:var(--stepper-input-text-color,var(--app-B6-N1,#000));display:inline-block;font-size:var(--stepper-input-font-size,16px);height:var(--stepper-input-height,28px);min-height:0;padding:1px;text-align:center;vertical-align:middle;width:var(--stepper-input-width,50px)}.smart-stepper__input--disabled{color:var(--stepper-input-disabled-text-color,var(--app-B6-N7,rgba(0,0,0,.1)))}
|
package/lib/stepper/index.js
CHANGED
@@ -85,6 +85,7 @@ function equal(value1, value2) {
|
|
85
85
|
currentValue: '',
|
86
86
|
Minus: icons_1.Minus,
|
87
87
|
Plus: icons_2.Plus,
|
88
|
+
isInit: false,
|
88
89
|
},
|
89
90
|
watch: {
|
90
91
|
value: function () {
|
@@ -92,14 +93,25 @@ function equal(value1, value2) {
|
|
92
93
|
},
|
93
94
|
},
|
94
95
|
created: function () {
|
96
|
+
var currentValue = this.format(this.data.value, true);
|
97
|
+
if (currentValue !== this.data.value) {
|
98
|
+
this.$emit('change', currentValue);
|
99
|
+
}
|
95
100
|
this.setData({
|
96
|
-
currentValue:
|
101
|
+
currentValue: currentValue,
|
102
|
+
isInit: true,
|
97
103
|
});
|
98
104
|
},
|
99
105
|
methods: {
|
100
106
|
observeValue: function () {
|
101
|
-
var
|
102
|
-
|
107
|
+
var _a = this.data, value = _a.value, isInit = _a.isInit;
|
108
|
+
if (!isInit)
|
109
|
+
return;
|
110
|
+
var currentValue = this.format(value, true);
|
111
|
+
if (currentValue !== value) {
|
112
|
+
this.$emit('change', currentValue);
|
113
|
+
}
|
114
|
+
this.setData({ currentValue: currentValue });
|
103
115
|
},
|
104
116
|
check: function () {
|
105
117
|
var val = this.format(this.data.currentValue);
|
@@ -118,7 +130,7 @@ function equal(value1, value2) {
|
|
118
130
|
this.$emit('focus', event.detail);
|
119
131
|
},
|
120
132
|
onBlur: function (event) {
|
121
|
-
var value = this.format(event.detail.value);
|
133
|
+
var value = this.format(event.detail.value, true);
|
122
134
|
this.setData({ currentValue: value });
|
123
135
|
this.emitChange(value);
|
124
136
|
this.$emit('blur', __assign(__assign({}, event.detail), { value: value }));
|
@@ -132,13 +144,17 @@ function equal(value1, value2) {
|
|
132
144
|
return value;
|
133
145
|
},
|
134
146
|
// limit value range
|
135
|
-
format: function (value) {
|
147
|
+
format: function (value, isFormatAll) {
|
148
|
+
if (isFormatAll === void 0) { isFormatAll = false; }
|
136
149
|
value = this.filter(value);
|
137
150
|
// format range
|
138
151
|
value = value === '' ? 0 : +value;
|
139
|
-
value = Math.
|
152
|
+
value = Math.min(this.data.max, value);
|
153
|
+
if (isFormatAll) {
|
154
|
+
value = Math.max(value, this.data.min);
|
155
|
+
}
|
140
156
|
// format decimal
|
141
|
-
if ((0, validator_1.isDef)(this.data.decimalLength)) {
|
157
|
+
if ((0, validator_1.isDef)(this.data.decimalLength) && isFormatAll) {
|
142
158
|
value = value.toFixed(this.data.decimalLength);
|
143
159
|
}
|
144
160
|
return value;
|
@@ -165,7 +181,7 @@ function equal(value1, value2) {
|
|
165
181
|
return;
|
166
182
|
}
|
167
183
|
var diff = type === 'minus' ? -this.data.step : +this.data.step;
|
168
|
-
var value = this.format(add(+this.data.currentValue, diff));
|
184
|
+
var value = this.format(add(+this.data.currentValue, diff), true);
|
169
185
|
this.emitChange(value);
|
170
186
|
this.$emit(type);
|
171
187
|
ty_1.default.vibrateShort({ type: 'light' });
|
package/lib/stepper/index.wxml
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
wx:if="{{ showMinus }}"
|
7
7
|
data-type="minus"
|
8
8
|
style="{{ computed.buttonStyle({ buttonSize }) }}"
|
9
|
-
class="minus-class {{ utils.bem('stepper__minus', { disabled:
|
9
|
+
class="minus-class {{ utils.bem('stepper__minus', { disabled: computed.checkMin({ min, currentValue, disabled, disableMinus }) }) }}"
|
10
10
|
hover-class="smart-stepper__minus--hover"
|
11
11
|
hover-stay-time="70"
|
12
12
|
bind:tap="onTap"
|
@@ -32,7 +32,7 @@
|
|
32
32
|
wx:if="{{ showPlus }}"
|
33
33
|
data-type="plus"
|
34
34
|
style="{{ computed.buttonStyle({ buttonSize }) }}"
|
35
|
-
class="plus-class {{ utils.bem('stepper__plus', { disabled:
|
35
|
+
class="plus-class {{ utils.bem('stepper__plus', { disabled: computed.checkMax({ max, currentValue, disabled, disablePlus }) }) }}"
|
36
36
|
hover-class="smart-stepper__plus--hover"
|
37
37
|
hover-stay-time="70"
|
38
38
|
bind:tap="onTap"
|
package/lib/stepper/index.wxs
CHANGED
@@ -16,7 +16,17 @@ function inputStyle(data) {
|
|
16
16
|
});
|
17
17
|
}
|
18
18
|
|
19
|
+
function checkMin(data) {
|
20
|
+
return data.currentValue <= Number(data.min) || data.disabled || data.disableMinus
|
21
|
+
}
|
22
|
+
|
23
|
+
function checkMax(data) {
|
24
|
+
return data.currentValue >= Number(data.max) || data.disabled || data.disablePlus
|
25
|
+
}
|
26
|
+
|
19
27
|
module.exports = {
|
20
28
|
buttonStyle: buttonStyle,
|
21
29
|
inputStyle: inputStyle,
|
30
|
+
checkMin: checkMin,
|
31
|
+
checkMax: checkMax,
|
22
32
|
};
|
package/lib/stepper/index.wxss
CHANGED
@@ -1 +1 @@
|
|
1
|
-
@import '../common/index.wxss';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{
|
1
|
+
@import '../common/index.wxss';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-stepper{background:var(--stepper-container-background-color,var(--app-B6-N9,rgba(0,0,0,.05)));border-radius:var(--stepper-background-border-radius,10px);display:inline-block;font-size:0;padding:var(--stepper-padding,2px)}.smart-stepper__minus,.smart-stepper__plus{--icon-color:currentColor;align-items:center;background-color:var(--stepper-background-color,var(--app-B6,#fff));border:var(--stepper-button-border,0);border-radius:var(--stepper-border-radius,8px);box-sizing:border-box;color:var(--stepper-button-icon-color,var(--app-B6-N3,rgba(0,0,0,.5)));display:inline-flex;font-size:var(--stepper-button-icon-font-size,27px);height:var(--stepper-input-height,28px);justify-content:center;padding:var(--padding-base,4px);position:relative;vertical-align:middle;width:var(--stepper-input-height,44px)}.smart-stepper__minus-icon,.smart-stepper__plus-icon{display:none}.smart-stepper__minus>.smart-stepper__minus-icon:first-child,.smart-stepper__minus>.smart-stepper__plus-icon:first-child,.smart-stepper__plus>.smart-stepper__minus-icon:first-child,.smart-stepper__plus>.smart-stepper__plus-icon:first-child{display:inline-flex}.smart-stepper__minus--hover,.smart-stepper__plus--hover{background-color:var(--stepper-active-color,#e8e8e8)}.smart-stepper__minus--disabled,.smart-stepper__plus--disabled{color:var(--stepper-button-disabled-icon-color,var(--app-B6-N7,rgba(0,0,0,.1)))}.smart-stepper__minus--disabled,.smart-stepper__minus--disabled.smart-stepper__minus--hover,.smart-stepper__minus--disabled.smart-stepper__plus--hover,.smart-stepper__plus--disabled,.smart-stepper__plus--disabled.smart-stepper__minus--hover,.smart-stepper__plus--disabled.smart-stepper__plus--hover{background-color:var(--stepper-button-disabled-color,var(--app-B6,#fff))}.smart-stepper--round .smart-stepper__input{background-color:initial!important}.smart-stepper--round .smart-stepper__minus,.smart-stepper--round .smart-stepper__plus{border-radius:100%}.smart-stepper--round .smart-stepper__minus:active,.smart-stepper--round .smart-stepper__plus:active{opacity:.7}.smart-stepper--round .smart-stepper__minus--disabled,.smart-stepper--round .smart-stepper__minus--disabled:active,.smart-stepper--round .smart-stepper__plus--disabled,.smart-stepper--round .smart-stepper__plus--disabled:active{opacity:.3}.smart-stepper--round .smart-stepper__plus{background-color:var(--stepper-button-round-theme-color,#ee0a24);color:#fff}.smart-stepper--round .smart-stepper__minus{background-color:#fff;border:1px solid var(--stepper-button-round-theme-color,#ee0a24);color:var(--stepper-button-round-theme-color,#ee0a24)}.smart-stepper__input{-webkit-appearance:none;border:0;border-radius:0;border-width:1px 0;box-sizing:border-box;color:var(--stepper-input-text-color,var(--app-B6-N1,#000));display:inline-block;font-size:var(--stepper-input-font-size,16px);height:var(--stepper-input-height,28px);min-height:0;padding:1px;text-align:center;vertical-align:middle;width:var(--stepper-input-width,50px)}.smart-stepper__input--disabled{color:var(--stepper-input-disabled-text-color,var(--app-B6-N7,rgba(0,0,0,.1)))}
|