@tuya-miniapp/smart-ui 2.13.1 → 2.13.2-beta-0
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.js +16 -1
- package/dist/stepper/index.wxml +1 -1
- package/lib/stepper/index.js +16 -1
- package/lib/stepper/index.wxml +1 -1
- package/package.json +5 -4
package/dist/stepper/index.js
CHANGED
|
@@ -138,6 +138,12 @@ SmartComponent({
|
|
|
138
138
|
// limit value range
|
|
139
139
|
format(value, isFormatAll = false) {
|
|
140
140
|
value = String(value).replace(/[^0-9.-]/g, '');
|
|
141
|
+
// handle negative sign: only allow at the beginning, and only one
|
|
142
|
+
const isNegative = value.charAt(0) === '-';
|
|
143
|
+
value = value.replace(/-/g, '');
|
|
144
|
+
if (isNegative && this.data.min < 0) {
|
|
145
|
+
value = '-' + value;
|
|
146
|
+
}
|
|
141
147
|
if (this.data.integer && value.indexOf('.') !== -1) {
|
|
142
148
|
value = value.split('.')[0];
|
|
143
149
|
}
|
|
@@ -148,9 +154,13 @@ SmartComponent({
|
|
|
148
154
|
value.substring(0, firstDotIndex + 1) +
|
|
149
155
|
value.substring(firstDotIndex + 1).replace(/\./g, '');
|
|
150
156
|
}
|
|
157
|
+
// allow typing a lone minus sign without clamping
|
|
158
|
+
if (value === '-' && !isFormatAll) {
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
151
161
|
// format range
|
|
152
162
|
if (isFormatAll) {
|
|
153
|
-
value = value === '' ? 0 : +value;
|
|
163
|
+
value = value === '' || value === '-' ? 0 : +value;
|
|
154
164
|
value = Math.min(this.data.max, value);
|
|
155
165
|
value = Math.max(value, this.data.min);
|
|
156
166
|
}
|
|
@@ -167,6 +177,11 @@ SmartComponent({
|
|
|
167
177
|
return;
|
|
168
178
|
}
|
|
169
179
|
const formatted = this.format(value);
|
|
180
|
+
// allow typing a lone minus sign without triggering change
|
|
181
|
+
if (formatted === '-') {
|
|
182
|
+
this.setData({ currentValue: formatted });
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
170
185
|
this.emitChange(formatted);
|
|
171
186
|
},
|
|
172
187
|
emitChange(value) {
|
package/dist/stepper/index.wxml
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<smart-icon name="{{ Minus }}" class="{{ utils.bem('stepper__minus-icon') }}" />
|
|
21
21
|
</view>
|
|
22
22
|
<input
|
|
23
|
-
type="{{ integer ? 'number' : 'digit' }}"
|
|
23
|
+
type="{{ min < 0 ? 'text' : (integer ? 'number' : 'digit') }}"
|
|
24
24
|
class="smart-manrope input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}"
|
|
25
25
|
style="{{ computed.inputStyle({ buttonSize, inputWidth }) }}"
|
|
26
26
|
value="{{ currentValue }}"
|
package/lib/stepper/index.js
CHANGED
|
@@ -155,6 +155,12 @@ function equal(value1, value2) {
|
|
|
155
155
|
format: function (value, isFormatAll) {
|
|
156
156
|
if (isFormatAll === void 0) { isFormatAll = false; }
|
|
157
157
|
value = String(value).replace(/[^0-9.-]/g, '');
|
|
158
|
+
// handle negative sign: only allow at the beginning, and only one
|
|
159
|
+
var isNegative = value.charAt(0) === '-';
|
|
160
|
+
value = value.replace(/-/g, '');
|
|
161
|
+
if (isNegative && this.data.min < 0) {
|
|
162
|
+
value = '-' + value;
|
|
163
|
+
}
|
|
158
164
|
if (this.data.integer && value.indexOf('.') !== -1) {
|
|
159
165
|
value = value.split('.')[0];
|
|
160
166
|
}
|
|
@@ -165,9 +171,13 @@ function equal(value1, value2) {
|
|
|
165
171
|
value.substring(0, firstDotIndex + 1) +
|
|
166
172
|
value.substring(firstDotIndex + 1).replace(/\./g, '');
|
|
167
173
|
}
|
|
174
|
+
// allow typing a lone minus sign without clamping
|
|
175
|
+
if (value === '-' && !isFormatAll) {
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
168
178
|
// format range
|
|
169
179
|
if (isFormatAll) {
|
|
170
|
-
value = value === '' ? 0 : +value;
|
|
180
|
+
value = value === '' || value === '-' ? 0 : +value;
|
|
171
181
|
value = Math.min(this.data.max, value);
|
|
172
182
|
value = Math.max(value, this.data.min);
|
|
173
183
|
}
|
|
@@ -184,6 +194,11 @@ function equal(value1, value2) {
|
|
|
184
194
|
return;
|
|
185
195
|
}
|
|
186
196
|
var formatted = this.format(value);
|
|
197
|
+
// allow typing a lone minus sign without triggering change
|
|
198
|
+
if (formatted === '-') {
|
|
199
|
+
this.setData({ currentValue: formatted });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
187
202
|
this.emitChange(formatted);
|
|
188
203
|
},
|
|
189
204
|
emitChange: function (value) {
|
package/lib/stepper/index.wxml
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<smart-icon name="{{ Minus }}" class="{{ utils.bem('stepper__minus-icon') }}" />
|
|
21
21
|
</view>
|
|
22
22
|
<input
|
|
23
|
-
type="{{ integer ? 'number' : 'digit' }}"
|
|
23
|
+
type="{{ min < 0 ? 'text' : (integer ? 'number' : 'digit') }}"
|
|
24
24
|
class="smart-manrope input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}"
|
|
25
25
|
style="{{ computed.inputStyle({ buttonSize, inputWidth }) }}"
|
|
26
26
|
value="{{ currentValue }}"
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-miniapp/smart-ui",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.2-beta-0",
|
|
4
4
|
"author": "MiniApp Team",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"miniprogram": "lib",
|
|
7
7
|
"description": "轻量、可靠的智能小程序 UI 组件库",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"prepublishOnly": "node ./build/prepublishOnly.js",
|
|
10
|
-
"dev": "NODE_OPTIONS=--no-experimental-fetch node build/dev.mjs",
|
|
10
|
+
"dev": "cross-env NODE_OPTIONS=--no-experimental-fetch node build/dev.mjs",
|
|
11
11
|
"lint": "eslint ./packages --ext .js,.ts --fix",
|
|
12
12
|
"lint:style": "stylelint \"packages/**/*.less\" --fix",
|
|
13
13
|
"prepare": "husky install",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@types/jest": "^27.0.2",
|
|
55
55
|
"canvas": "^3.1.0",
|
|
56
56
|
"conventional-changelog-cli": "^5.0.0",
|
|
57
|
+
"cross-env": "^10.1.0",
|
|
57
58
|
"eslint-config-tuya-panel": "^0.4.2",
|
|
58
59
|
"eslint-plugin-literal-check": "^0.1.2",
|
|
59
60
|
"eslint-plugin-prettier": "^5.2.1",
|
|
@@ -87,9 +88,9 @@
|
|
|
87
88
|
"iOS >= 9"
|
|
88
89
|
],
|
|
89
90
|
"dependencies": {
|
|
91
|
+
"@ray-core/event-propagation": "^0.4.13",
|
|
90
92
|
"@ray-js/components-ty-slider": "^0.3.9",
|
|
91
|
-
"@tuya-miniapp/icons": "^2.3.0"
|
|
92
|
-
"@ray-core/event-propagation": "^0.4.13"
|
|
93
|
+
"@tuya-miniapp/icons": "^2.3.0"
|
|
93
94
|
},
|
|
94
95
|
"maintainers": [
|
|
95
96
|
{
|