@tuya-miniapp/smart-ui 2.7.3-beta-0 → 2.7.3

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.
@@ -69,6 +69,7 @@ SmartComponent({
69
69
  currentValue: '',
70
70
  Minus,
71
71
  Plus,
72
+ focus: false,
72
73
  isInit: false,
73
74
  },
74
75
  watch: {
@@ -88,10 +89,10 @@ SmartComponent({
88
89
  },
89
90
  methods: {
90
91
  observeValue() {
91
- const { value, isInit } = this.data;
92
- if (!isInit)
92
+ const { value, isInit, focus } = this.data;
93
+ if (!isInit || `${value}` === `${this.data.currentValue}` || focus)
93
94
  return;
94
- const currentValue = this.format(value, true);
95
+ const currentValue = this.format(value, !this.data.focus);
95
96
  if (currentValue !== value) {
96
97
  this.$emit('change', currentValue);
97
98
  }
@@ -112,6 +113,7 @@ SmartComponent({
112
113
  },
113
114
  onFocus(event) {
114
115
  this.$emit('focus', event.detail);
116
+ this.setData({ focus: true });
115
117
  },
116
118
  onBlur(event) {
117
119
  const value = this.format(event.detail.value, true);
@@ -120,7 +122,7 @@ SmartComponent({
120
122
  const strStepValue = isDef(this.data.decimalLength)
121
123
  ? stepValue.toFixed(this.data.decimalLength)
122
124
  : stepValue.toString();
123
- this.setData({ currentValue: strStepValue });
125
+ this.setData({ currentValue: strStepValue, focus: false });
124
126
  this.emitChange(strStepValue);
125
127
  this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value: strStepValue }));
126
128
  },
@@ -21,7 +21,6 @@
21
21
  class="smart-manrope input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}"
22
22
  style="{{ computed.inputStyle({ buttonSize, inputWidth }) }}"
23
23
  value="{{ currentValue }}"
24
- focus="{{ focus }}"
25
24
  disabled="{{ disabled || disableInput }}"
26
25
  always-embed="{{ alwaysEmbed }}"
27
26
  bindinput="onInput"
@@ -85,6 +85,7 @@ function equal(value1, value2) {
85
85
  currentValue: '',
86
86
  Minus: Minus_1.default,
87
87
  Plus: Plus_1.default,
88
+ focus: false,
88
89
  isInit: false,
89
90
  },
90
91
  watch: {
@@ -104,10 +105,10 @@ function equal(value1, value2) {
104
105
  },
105
106
  methods: {
106
107
  observeValue: function () {
107
- var _a = this.data, value = _a.value, isInit = _a.isInit;
108
- if (!isInit)
108
+ var _a = this.data, value = _a.value, isInit = _a.isInit, focus = _a.focus;
109
+ if (!isInit || "".concat(value) === "".concat(this.data.currentValue) || focus)
109
110
  return;
110
- var currentValue = this.format(value, true);
111
+ var currentValue = this.format(value, !this.data.focus);
111
112
  if (currentValue !== value) {
112
113
  this.$emit('change', currentValue);
113
114
  }
@@ -128,6 +129,7 @@ function equal(value1, value2) {
128
129
  },
129
130
  onFocus: function (event) {
130
131
  this.$emit('focus', event.detail);
132
+ this.setData({ focus: true });
131
133
  },
132
134
  onBlur: function (event) {
133
135
  var value = this.format(event.detail.value, true);
@@ -136,7 +138,7 @@ function equal(value1, value2) {
136
138
  var strStepValue = (0, validator_1.isDef)(this.data.decimalLength)
137
139
  ? stepValue.toFixed(this.data.decimalLength)
138
140
  : stepValue.toString();
139
- this.setData({ currentValue: strStepValue });
141
+ this.setData({ currentValue: strStepValue, focus: false });
140
142
  this.emitChange(strStepValue);
141
143
  this.$emit('blur', __assign(__assign({}, event.detail), { value: strStepValue }));
142
144
  },
@@ -21,7 +21,6 @@
21
21
  class="smart-manrope input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}"
22
22
  style="{{ computed.inputStyle({ buttonSize, inputWidth }) }}"
23
23
  value="{{ currentValue }}"
24
- focus="{{ focus }}"
25
24
  disabled="{{ disabled || disableInput }}"
26
25
  always-embed="{{ alwaysEmbed }}"
27
26
  bindinput="onInput"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.7.3-beta-0",
3
+ "version": "2.7.3",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",
@@ -17,6 +17,7 @@
17
17
  "build:wx": "node build/wx.mjs",
18
18
  "test": "TZ=Asia/Shanghai jest",
19
19
  "test:watch": "jest --watch",
20
+ "test:cover": "jest --coverage",
20
21
  "preMinipackBuild": "yarn && MODE=build NODE_OPTIONS=--no-experimental-fetch npx gulp -f build/compiler.js --series buildEs buildLib buildExample",
21
22
  "changelog": "conventional-changelog -p -i CHANGELOG.md -s"
22
23
  },
@@ -1 +0,0 @@
1
- @import '../common/index.css';
@@ -1 +0,0 @@
1
- export {};
@@ -1,219 +0,0 @@
1
- import { SmartComponent } from '../common/component';
2
- import { pickerProps } from '../picker/shared';
3
- import { requestAnimationFrame } from '../common/utils';
4
- const EMPTY_CODE = '000000';
5
- SmartComponent({
6
- classes: ['active-class', 'toolbar-class', 'column-class'],
7
- props: Object.assign(Object.assign({}, pickerProps), { showToolbar: {
8
- type: Boolean,
9
- value: true,
10
- }, value: {
11
- type: String,
12
- observer(value) {
13
- this.code = value;
14
- this.setValues();
15
- },
16
- }, areaList: {
17
- type: Object,
18
- value: {},
19
- observer: 'setValues',
20
- }, columnsNum: {
21
- type: null,
22
- value: 3,
23
- }, columnsPlaceholder: {
24
- type: Array,
25
- observer(val) {
26
- this.setData({
27
- typeToColumnsPlaceholder: {
28
- province: val[0] || '',
29
- city: val[1] || '',
30
- county: val[2] || '',
31
- },
32
- });
33
- },
34
- } }),
35
- data: {
36
- columns: [{ values: [] }, { values: [] }, { values: [] }],
37
- typeToColumnsPlaceholder: {},
38
- },
39
- mounted() {
40
- requestAnimationFrame(() => {
41
- this.setValues();
42
- });
43
- },
44
- methods: {
45
- getPicker() {
46
- if (this.picker == null) {
47
- this.picker = this.selectComponent('.smart-area__picker');
48
- }
49
- return this.picker;
50
- },
51
- onCancel(event) {
52
- this.emit('cancel', event.detail);
53
- },
54
- onConfirm(event) {
55
- const { index } = event.detail;
56
- let { value } = event.detail;
57
- value = this.parseValues(value);
58
- this.emit('confirm', { value, index });
59
- },
60
- emit(type, detail) {
61
- detail.values = detail.value;
62
- delete detail.value;
63
- this.$emit(type, detail);
64
- },
65
- parseValues(values) {
66
- const { columnsPlaceholder } = this.data;
67
- return values.map((value, index) => {
68
- if (value && (!value.code || value.name === columnsPlaceholder[index])) {
69
- return Object.assign(Object.assign({}, value), { code: '', name: '' });
70
- }
71
- return value;
72
- });
73
- },
74
- onChange(event) {
75
- var _a;
76
- const { index, picker, value } = event.detail;
77
- this.code = value[index].code;
78
- (_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(() => {
79
- this.$emit('change', {
80
- picker,
81
- values: this.parseValues(picker.getValues()),
82
- index,
83
- });
84
- });
85
- },
86
- getConfig(type) {
87
- const { areaList } = this.data;
88
- return (areaList && areaList[`${type}_list`]) || {};
89
- },
90
- getList(type, code) {
91
- if (type !== 'province' && !code) {
92
- return [];
93
- }
94
- const { typeToColumnsPlaceholder } = this.data;
95
- const list = this.getConfig(type);
96
- let result = Object.keys(list).map(code => ({
97
- code,
98
- name: list[code],
99
- }));
100
- if (code != null) {
101
- // oversea code
102
- if (code[0] === '9' && type === 'city') {
103
- code = '9';
104
- }
105
- result = result.filter(item => item.code.indexOf(code) === 0);
106
- }
107
- if (typeToColumnsPlaceholder[type] && result.length) {
108
- // set columns placeholder
109
- const codeFill = type === 'province'
110
- ? ''
111
- : type === 'city'
112
- ? EMPTY_CODE.slice(2, 4)
113
- : EMPTY_CODE.slice(4, 6);
114
- result.unshift({
115
- code: `${code}${codeFill}`,
116
- name: typeToColumnsPlaceholder[type],
117
- });
118
- }
119
- return result;
120
- },
121
- getIndex(type, code) {
122
- let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
123
- const list = this.getList(type, code.slice(0, compareNum - 2));
124
- // oversea code
125
- if (code[0] === '9' && type === 'province') {
126
- compareNum = 1;
127
- }
128
- code = code.slice(0, compareNum);
129
- for (let i = 0; i < list.length; i++) {
130
- if (list[i].code.slice(0, compareNum) === code) {
131
- return i;
132
- }
133
- }
134
- return 0;
135
- },
136
- setValues() {
137
- const picker = this.getPicker();
138
- if (!picker) {
139
- return;
140
- }
141
- let code = this.code || this.getDefaultCode();
142
- const provinceList = this.getList('province');
143
- const cityList = this.getList('city', code.slice(0, 2));
144
- const stack = [];
145
- const indexes = [];
146
- const { columnsNum } = this.data;
147
- if (columnsNum >= 1) {
148
- stack.push(picker.setColumnValues(0, provinceList, false));
149
- indexes.push(this.getIndex('province', code));
150
- }
151
- if (columnsNum >= 2) {
152
- stack.push(picker.setColumnValues(1, cityList, false));
153
- indexes.push(this.getIndex('city', code));
154
- if (cityList.length && code.slice(2, 4) === '00') {
155
- [{ code }] = cityList;
156
- }
157
- }
158
- if (columnsNum === 3) {
159
- stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
160
- indexes.push(this.getIndex('county', code));
161
- }
162
- return Promise.all(stack)
163
- .catch(() => { })
164
- .then(() => picker.setIndexes(indexes))
165
- .catch(() => { });
166
- },
167
- getDefaultCode() {
168
- const { columnsPlaceholder } = this.data;
169
- if (columnsPlaceholder.length) {
170
- return EMPTY_CODE;
171
- }
172
- const countyCodes = Object.keys(this.getConfig('county'));
173
- if (countyCodes[0]) {
174
- return countyCodes[0];
175
- }
176
- const cityCodes = Object.keys(this.getConfig('city'));
177
- if (cityCodes[0]) {
178
- return cityCodes[0];
179
- }
180
- return '';
181
- },
182
- getValues() {
183
- const picker = this.getPicker();
184
- if (!picker) {
185
- return [];
186
- }
187
- return this.parseValues(picker.getValues().filter(value => !!value));
188
- },
189
- getDetail() {
190
- const values = this.getValues();
191
- const area = {
192
- code: '',
193
- country: '',
194
- province: '',
195
- city: '',
196
- county: '',
197
- };
198
- if (!values.length) {
199
- return area;
200
- }
201
- const names = values.map((item) => item.name);
202
- area.code = values[values.length - 1].code;
203
- if (area.code[0] === '9') {
204
- area.country = names[1] || '';
205
- area.province = names[2] || '';
206
- }
207
- else {
208
- area.province = names[0] || '';
209
- area.city = names[1] || '';
210
- area.county = names[2] || '';
211
- }
212
- return area;
213
- },
214
- reset(code) {
215
- this.code = code || '';
216
- return this.setValues();
217
- },
218
- },
219
- });
@@ -1,6 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "smart-picker": "../picker/index"
5
- }
6
- }
@@ -1,20 +0,0 @@
1
- <wxs src="./index.wxs" module="computed" />
2
-
3
- <smart-picker
4
- class="smart-area__picker"
5
- active-class="active-class"
6
- toolbar-class="toolbar-class"
7
- column-class="column-class"
8
- show-toolbar="{{ showToolbar }}"
9
- value-key="name"
10
- title="{{ title }}"
11
- loading="{{ loading }}"
12
- columns="{{ computed.displayColumns(columns, columnsNum) }}"
13
- item-height="{{ itemHeight }}"
14
- visible-item-count="{{ visibleItemCount }}"
15
- cancel-button-text="{{ cancelButtonText }}"
16
- confirm-button-text="{{ confirmButtonText }}"
17
- bind:change="onChange"
18
- bind:confirm="onConfirm"
19
- bind:cancel="onCancel"
20
- />
@@ -1,8 +0,0 @@
1
- /* eslint-disable */
2
- function displayColumns(columns, columnsNum) {
3
- return columns.slice(0, +columnsNum);
4
- }
5
-
6
- module.exports = {
7
- displayColumns: displayColumns,
8
- };
@@ -1 +0,0 @@
1
- @import '../common/index.wxss';
@@ -1 +0,0 @@
1
- @import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-bottom-sheet-dragger-node-background:rgba(0,0,0,.3);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-bottom-sheet-dragger-node-background:hsla(0,0%,100%,.3);--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-manrope{font-family:Manrope,sans-serif}.smart-steps{background-color:var(--steps-background-color,var(--app-B3,#fff));overflow:hidden}.smart-steps--horizontal{padding:10px}.smart-steps--horizontal .smart-step__wrapper{display:flex;overflow:hidden;position:relative}.smart-steps--vertical{padding-left:10px}.smart-steps--vertical .smart-step__wrapper{padding:0 0 0 20px}.smart-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.smart-step--finish{color:var(--step-finish-text-color,#323233)}.smart-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.smart-step--horizontal{padding-bottom:14px}.smart-step--horizontal:first-child .smart-step__title{transform:none}.smart-step--horizontal:first-child .smart-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.smart-step--horizontal:last-child{position:absolute;right:0;width:auto}.smart-step--horizontal:last-child .smart-step__title{text-align:right;transform:none}.smart-step--horizontal:last-child .smart-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal .smart-step__circle-container{background-color:var(--app-B3);bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.smart-step--horizontal .smart-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.smart-step--horizontal .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal.smart-step--process{color:var(--step-process-text-color,#323233)}.smart-step--horizontal.smart-step--process .smart-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical{line-height:18px;padding:10px 10px 10px 0}.smart-step--vertical:after{border-bottom-width:1px}.smart-step--vertical:last-child:after{border-bottom-width:none}.smart-step--vertical:first-child:before{content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.smart-step--vertical .smart-step__circle,.smart-step--vertical .smart-step__icon,.smart-step--vertical .smart-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.smart-step--vertical .smart-step__icon{background-color:var(--steps-background-color,var(--app-B3,#fff));font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1}
@@ -1 +0,0 @@
1
- export {};
@@ -1,34 +0,0 @@
1
- import Checkmark from '@tuya-miniapp/icons/dist/svg/Checkmark';
2
- import { SmartComponent } from '../common/component';
3
- import { GREEN, GRAY_DARK } from '../common/color';
4
- SmartComponent({
5
- classes: ['desc-class'],
6
- props: {
7
- icon: String,
8
- steps: Array,
9
- active: Number,
10
- direction: {
11
- type: String,
12
- value: 'horizontal',
13
- },
14
- activeColor: {
15
- type: String,
16
- value: GREEN,
17
- },
18
- inactiveColor: {
19
- type: String,
20
- value: GRAY_DARK,
21
- },
22
- activeIcon: {
23
- type: String,
24
- value: Checkmark,
25
- },
26
- inactiveIcon: String,
27
- },
28
- methods: {
29
- onClick(event) {
30
- const { index } = event.currentTarget.dataset;
31
- this.$emit('click-step', index);
32
- },
33
- },
34
- });
@@ -1,6 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "smart-icon": "../icon/index"
5
- }
6
- }
@@ -1,54 +0,0 @@
1
- <wxs src="../wxs/utils.wxs" module="utils" />
2
-
3
- <view class="custom-class {{ utils.bem('steps', [direction]) }}">
4
- <view class="smart-step__wrapper">
5
- <view
6
- wx:for="{{ steps }}"
7
- wx:key="index"
8
- bindtap="onClick"
9
- data-index="{{ index }}"
10
- class="{{ utils.bem('step', [direction, status(index, active)]) }} smart-hairline"
11
- style="{{ status(index, active) === 'inactive' ? 'color: ' + inactiveColor: '' }}"
12
- >
13
- <view class="smart-step__title" style="{{ index === active ? 'color: ' + activeColor : '' }}">
14
- <view>{{ item.text }}</view>
15
- <view class="desc-class">{{ item.desc }}</view>
16
- </view>
17
- <view class="smart-step__circle-container">
18
- <block wx:if="{{ index !== active }}">
19
- <smart-icon
20
- wx:if="{{ item.inactiveIcon || inactiveIcon }}"
21
- color="{{ status(index, active) === 'inactive' ? inactiveColor: activeColor }}"
22
- name="{{ item.inactiveIcon || inactiveIcon }}"
23
- class="smart-step__icon"
24
- />
25
- <view
26
- wx:else
27
- class="smart-step__circle"
28
- style="{{ 'background-color: ' + (index < active ? activeColor : inactiveColor) }}"
29
- />
30
- </block>
31
-
32
- <smart-icon wx:else name="{{ item.activeIcon || activeIcon }}" color="{{ activeColor }}" class="smart-step__icon" />
33
- </view>
34
- <view
35
- wx:if="{{ index !== steps.length - 1 }}"
36
- class="smart-step__line" style="{{ 'background-color: ' + (index < active ? activeColor : inactiveColor) }}"
37
- />
38
- </view>
39
- </view>
40
- </view>
41
-
42
- <wxs module="status">
43
- function get(index, active) {
44
- if (index < active) {
45
- return 'finish';
46
- } else if (index === active) {
47
- return 'process';
48
- }
49
-
50
- return 'inactive';
51
- }
52
-
53
- module.exports = get;
54
- </wxs>
@@ -1 +0,0 @@
1
- @import '../common/index.wxss';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-bottom-sheet-dragger-node-background:rgba(0,0,0,.3);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-bottom-sheet-dragger-node-background:hsla(0,0%,100%,.3);--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-manrope{font-family:Manrope,sans-serif}.smart-steps{background-color:var(--steps-background-color,var(--app-B3,#fff));overflow:hidden}.smart-steps--horizontal{padding:10px}.smart-steps--horizontal .smart-step__wrapper{display:flex;overflow:hidden;position:relative}.smart-steps--vertical{padding-left:10px}.smart-steps--vertical .smart-step__wrapper{padding:0 0 0 20px}.smart-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.smart-step--finish{color:var(--step-finish-text-color,#323233)}.smart-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.smart-step--horizontal{padding-bottom:14px}.smart-step--horizontal:first-child .smart-step__title{transform:none}.smart-step--horizontal:first-child .smart-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.smart-step--horizontal:last-child{position:absolute;right:0;width:auto}.smart-step--horizontal:last-child .smart-step__title{text-align:right;transform:none}.smart-step--horizontal:last-child .smart-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal .smart-step__circle-container{background-color:var(--app-B3);bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.smart-step--horizontal .smart-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.smart-step--horizontal .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal.smart-step--process{color:var(--step-process-text-color,#323233)}.smart-step--horizontal.smart-step--process .smart-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical{line-height:18px;padding:10px 10px 10px 0}.smart-step--vertical:after{border-bottom-width:1px}.smart-step--vertical:last-child:after{border-bottom-width:none}.smart-step--vertical:first-child:before{content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.smart-step--vertical .smart-step__circle,.smart-step--vertical .smart-step__icon,.smart-step--vertical .smart-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.smart-step--vertical .smart-step__icon{background-color:var(--steps-background-color,var(--app-B3,#fff));font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1}
@@ -1 +0,0 @@
1
- @import '../common/index.css';
@@ -1 +0,0 @@
1
- export {};
package/lib/area/index.js DELETED
@@ -1,234 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var component_1 = require("../common/component");
15
- var shared_1 = require("../picker/shared");
16
- var utils_1 = require("../common/utils");
17
- var EMPTY_CODE = '000000';
18
- (0, component_1.SmartComponent)({
19
- classes: ['active-class', 'toolbar-class', 'column-class'],
20
- props: __assign(__assign({}, shared_1.pickerProps), { showToolbar: {
21
- type: Boolean,
22
- value: true,
23
- }, value: {
24
- type: String,
25
- observer: function (value) {
26
- this.code = value;
27
- this.setValues();
28
- },
29
- }, areaList: {
30
- type: Object,
31
- value: {},
32
- observer: 'setValues',
33
- }, columnsNum: {
34
- type: null,
35
- value: 3,
36
- }, columnsPlaceholder: {
37
- type: Array,
38
- observer: function (val) {
39
- this.setData({
40
- typeToColumnsPlaceholder: {
41
- province: val[0] || '',
42
- city: val[1] || '',
43
- county: val[2] || '',
44
- },
45
- });
46
- },
47
- } }),
48
- data: {
49
- columns: [{ values: [] }, { values: [] }, { values: [] }],
50
- typeToColumnsPlaceholder: {},
51
- },
52
- mounted: function () {
53
- var _this = this;
54
- (0, utils_1.requestAnimationFrame)(function () {
55
- _this.setValues();
56
- });
57
- },
58
- methods: {
59
- getPicker: function () {
60
- if (this.picker == null) {
61
- this.picker = this.selectComponent('.smart-area__picker');
62
- }
63
- return this.picker;
64
- },
65
- onCancel: function (event) {
66
- this.emit('cancel', event.detail);
67
- },
68
- onConfirm: function (event) {
69
- var index = event.detail.index;
70
- var value = event.detail.value;
71
- value = this.parseValues(value);
72
- this.emit('confirm', { value: value, index: index });
73
- },
74
- emit: function (type, detail) {
75
- detail.values = detail.value;
76
- delete detail.value;
77
- this.$emit(type, detail);
78
- },
79
- parseValues: function (values) {
80
- var columnsPlaceholder = this.data.columnsPlaceholder;
81
- return values.map(function (value, index) {
82
- if (value && (!value.code || value.name === columnsPlaceholder[index])) {
83
- return __assign(__assign({}, value), { code: '', name: '' });
84
- }
85
- return value;
86
- });
87
- },
88
- onChange: function (event) {
89
- var _this = this;
90
- var _a;
91
- var _b = event.detail, index = _b.index, picker = _b.picker, value = _b.value;
92
- this.code = value[index].code;
93
- (_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(function () {
94
- _this.$emit('change', {
95
- picker: picker,
96
- values: _this.parseValues(picker.getValues()),
97
- index: index,
98
- });
99
- });
100
- },
101
- getConfig: function (type) {
102
- var areaList = this.data.areaList;
103
- return (areaList && areaList["".concat(type, "_list")]) || {};
104
- },
105
- getList: function (type, code) {
106
- if (type !== 'province' && !code) {
107
- return [];
108
- }
109
- var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
110
- var list = this.getConfig(type);
111
- var result = Object.keys(list).map(function (code) { return ({
112
- code: code,
113
- name: list[code],
114
- }); });
115
- if (code != null) {
116
- // oversea code
117
- if (code[0] === '9' && type === 'city') {
118
- code = '9';
119
- }
120
- result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
121
- }
122
- if (typeToColumnsPlaceholder[type] && result.length) {
123
- // set columns placeholder
124
- var codeFill = type === 'province'
125
- ? ''
126
- : type === 'city'
127
- ? EMPTY_CODE.slice(2, 4)
128
- : EMPTY_CODE.slice(4, 6);
129
- result.unshift({
130
- code: "".concat(code).concat(codeFill),
131
- name: typeToColumnsPlaceholder[type],
132
- });
133
- }
134
- return result;
135
- },
136
- getIndex: function (type, code) {
137
- var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
138
- var list = this.getList(type, code.slice(0, compareNum - 2));
139
- // oversea code
140
- if (code[0] === '9' && type === 'province') {
141
- compareNum = 1;
142
- }
143
- code = code.slice(0, compareNum);
144
- for (var i = 0; i < list.length; i++) {
145
- if (list[i].code.slice(0, compareNum) === code) {
146
- return i;
147
- }
148
- }
149
- return 0;
150
- },
151
- setValues: function () {
152
- var picker = this.getPicker();
153
- if (!picker) {
154
- return;
155
- }
156
- var code = this.code || this.getDefaultCode();
157
- var provinceList = this.getList('province');
158
- var cityList = this.getList('city', code.slice(0, 2));
159
- var stack = [];
160
- var indexes = [];
161
- var columnsNum = this.data.columnsNum;
162
- if (columnsNum >= 1) {
163
- stack.push(picker.setColumnValues(0, provinceList, false));
164
- indexes.push(this.getIndex('province', code));
165
- }
166
- if (columnsNum >= 2) {
167
- stack.push(picker.setColumnValues(1, cityList, false));
168
- indexes.push(this.getIndex('city', code));
169
- if (cityList.length && code.slice(2, 4) === '00') {
170
- code = cityList[0].code;
171
- }
172
- }
173
- if (columnsNum === 3) {
174
- stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
175
- indexes.push(this.getIndex('county', code));
176
- }
177
- return Promise.all(stack)
178
- .catch(function () { })
179
- .then(function () { return picker.setIndexes(indexes); })
180
- .catch(function () { });
181
- },
182
- getDefaultCode: function () {
183
- var columnsPlaceholder = this.data.columnsPlaceholder;
184
- if (columnsPlaceholder.length) {
185
- return EMPTY_CODE;
186
- }
187
- var countyCodes = Object.keys(this.getConfig('county'));
188
- if (countyCodes[0]) {
189
- return countyCodes[0];
190
- }
191
- var cityCodes = Object.keys(this.getConfig('city'));
192
- if (cityCodes[0]) {
193
- return cityCodes[0];
194
- }
195
- return '';
196
- },
197
- getValues: function () {
198
- var picker = this.getPicker();
199
- if (!picker) {
200
- return [];
201
- }
202
- return this.parseValues(picker.getValues().filter(function (value) { return !!value; }));
203
- },
204
- getDetail: function () {
205
- var values = this.getValues();
206
- var area = {
207
- code: '',
208
- country: '',
209
- province: '',
210
- city: '',
211
- county: '',
212
- };
213
- if (!values.length) {
214
- return area;
215
- }
216
- var names = values.map(function (item) { return item.name; });
217
- area.code = values[values.length - 1].code;
218
- if (area.code[0] === '9') {
219
- area.country = names[1] || '';
220
- area.province = names[2] || '';
221
- }
222
- else {
223
- area.province = names[0] || '';
224
- area.city = names[1] || '';
225
- area.county = names[2] || '';
226
- }
227
- return area;
228
- },
229
- reset: function (code) {
230
- this.code = code || '';
231
- return this.setValues();
232
- },
233
- },
234
- });
@@ -1,6 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "smart-picker": "../picker/index"
5
- }
6
- }
@@ -1,20 +0,0 @@
1
- <wxs src="./index.wxs" module="computed" />
2
-
3
- <smart-picker
4
- class="smart-area__picker"
5
- active-class="active-class"
6
- toolbar-class="toolbar-class"
7
- column-class="column-class"
8
- show-toolbar="{{ showToolbar }}"
9
- value-key="name"
10
- title="{{ title }}"
11
- loading="{{ loading }}"
12
- columns="{{ computed.displayColumns(columns, columnsNum) }}"
13
- item-height="{{ itemHeight }}"
14
- visible-item-count="{{ visibleItemCount }}"
15
- cancel-button-text="{{ cancelButtonText }}"
16
- confirm-button-text="{{ confirmButtonText }}"
17
- bind:change="onChange"
18
- bind:confirm="onConfirm"
19
- bind:cancel="onCancel"
20
- />
@@ -1,8 +0,0 @@
1
- /* eslint-disable */
2
- function displayColumns(columns, columnsNum) {
3
- return columns.slice(0, +columnsNum);
4
- }
5
-
6
- module.exports = {
7
- displayColumns: displayColumns,
8
- };
@@ -1 +0,0 @@
1
- @import '../common/index.wxss';
@@ -1 +0,0 @@
1
- @import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-bottom-sheet-dragger-node-background:rgba(0,0,0,.3);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-bottom-sheet-dragger-node-background:hsla(0,0%,100%,.3);--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-manrope{font-family:Manrope,sans-serif}.smart-steps{background-color:var(--steps-background-color,var(--app-B3,#fff));overflow:hidden}.smart-steps--horizontal{padding:10px}.smart-steps--horizontal .smart-step__wrapper{display:flex;overflow:hidden;position:relative}.smart-steps--vertical{padding-left:10px}.smart-steps--vertical .smart-step__wrapper{padding:0 0 0 20px}.smart-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.smart-step--finish{color:var(--step-finish-text-color,#323233)}.smart-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.smart-step--horizontal{padding-bottom:14px}.smart-step--horizontal:first-child .smart-step__title{transform:none}.smart-step--horizontal:first-child .smart-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.smart-step--horizontal:last-child{position:absolute;right:0;width:auto}.smart-step--horizontal:last-child .smart-step__title{text-align:right;transform:none}.smart-step--horizontal:last-child .smart-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal .smart-step__circle-container{background-color:var(--app-B3);bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.smart-step--horizontal .smart-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.smart-step--horizontal .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal.smart-step--process{color:var(--step-process-text-color,#323233)}.smart-step--horizontal.smart-step--process .smart-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical{line-height:18px;padding:10px 10px 10px 0}.smart-step--vertical:after{border-bottom-width:1px}.smart-step--vertical:last-child:after{border-bottom-width:none}.smart-step--vertical:first-child:before{content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.smart-step--vertical .smart-step__circle,.smart-step--vertical .smart-step__icon,.smart-step--vertical .smart-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.smart-step--vertical .smart-step__icon{background-color:var(--steps-background-color,var(--app-B3,#fff));font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1}
@@ -1 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var Checkmark_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Checkmark"));
7
- var component_1 = require("../common/component");
8
- var color_1 = require("../common/color");
9
- (0, component_1.SmartComponent)({
10
- classes: ['desc-class'],
11
- props: {
12
- icon: String,
13
- steps: Array,
14
- active: Number,
15
- direction: {
16
- type: String,
17
- value: 'horizontal',
18
- },
19
- activeColor: {
20
- type: String,
21
- value: color_1.GREEN,
22
- },
23
- inactiveColor: {
24
- type: String,
25
- value: color_1.GRAY_DARK,
26
- },
27
- activeIcon: {
28
- type: String,
29
- value: Checkmark_1.default,
30
- },
31
- inactiveIcon: String,
32
- },
33
- methods: {
34
- onClick: function (event) {
35
- var index = event.currentTarget.dataset.index;
36
- this.$emit('click-step', index);
37
- },
38
- },
39
- });
@@ -1,6 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "smart-icon": "../icon/index"
5
- }
6
- }
@@ -1,54 +0,0 @@
1
- <wxs src="../wxs/utils.wxs" module="utils" />
2
-
3
- <view class="custom-class {{ utils.bem('steps', [direction]) }}">
4
- <view class="smart-step__wrapper">
5
- <view
6
- wx:for="{{ steps }}"
7
- wx:key="index"
8
- bindtap="onClick"
9
- data-index="{{ index }}"
10
- class="{{ utils.bem('step', [direction, status(index, active)]) }} smart-hairline"
11
- style="{{ status(index, active) === 'inactive' ? 'color: ' + inactiveColor: '' }}"
12
- >
13
- <view class="smart-step__title" style="{{ index === active ? 'color: ' + activeColor : '' }}">
14
- <view>{{ item.text }}</view>
15
- <view class="desc-class">{{ item.desc }}</view>
16
- </view>
17
- <view class="smart-step__circle-container">
18
- <block wx:if="{{ index !== active }}">
19
- <smart-icon
20
- wx:if="{{ item.inactiveIcon || inactiveIcon }}"
21
- color="{{ status(index, active) === 'inactive' ? inactiveColor: activeColor }}"
22
- name="{{ item.inactiveIcon || inactiveIcon }}"
23
- class="smart-step__icon"
24
- />
25
- <view
26
- wx:else
27
- class="smart-step__circle"
28
- style="{{ 'background-color: ' + (index < active ? activeColor : inactiveColor) }}"
29
- />
30
- </block>
31
-
32
- <smart-icon wx:else name="{{ item.activeIcon || activeIcon }}" color="{{ activeColor }}" class="smart-step__icon" />
33
- </view>
34
- <view
35
- wx:if="{{ index !== steps.length - 1 }}"
36
- class="smart-step__line" style="{{ 'background-color: ' + (index < active ? activeColor : inactiveColor) }}"
37
- />
38
- </view>
39
- </view>
40
- </view>
41
-
42
- <wxs module="status">
43
- function get(index, active) {
44
- if (index < active) {
45
- return 'finish';
46
- } else if (index === active) {
47
- return 'process';
48
- }
49
-
50
- return 'inactive';
51
- }
52
-
53
- module.exports = get;
54
- </wxs>
@@ -1 +0,0 @@
1
- @import '../common/index.wxss';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-bottom-sheet-dragger-node-background:rgba(0,0,0,.3);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-bottom-sheet-dragger-node-background:hsla(0,0%,100%,.3);--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-manrope{font-family:Manrope,sans-serif}.smart-steps{background-color:var(--steps-background-color,var(--app-B3,#fff));overflow:hidden}.smart-steps--horizontal{padding:10px}.smart-steps--horizontal .smart-step__wrapper{display:flex;overflow:hidden;position:relative}.smart-steps--vertical{padding-left:10px}.smart-steps--vertical .smart-step__wrapper{padding:0 0 0 20px}.smart-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.smart-step--finish{color:var(--step-finish-text-color,#323233)}.smart-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.smart-step--horizontal{padding-bottom:14px}.smart-step--horizontal:first-child .smart-step__title{transform:none}.smart-step--horizontal:first-child .smart-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.smart-step--horizontal:last-child{position:absolute;right:0;width:auto}.smart-step--horizontal:last-child .smart-step__title{text-align:right;transform:none}.smart-step--horizontal:last-child .smart-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal .smart-step__circle-container{background-color:var(--app-B3);bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.smart-step--horizontal .smart-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.smart-step--horizontal .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.smart-step--horizontal.smart-step--process{color:var(--step-process-text-color,#323233)}.smart-step--horizontal.smart-step--process .smart-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical{line-height:18px;padding:10px 10px 10px 0}.smart-step--vertical:after{border-bottom-width:1px}.smart-step--vertical:last-child:after{border-bottom-width:none}.smart-step--vertical:first-child:before{content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.smart-step--vertical .smart-step__circle,.smart-step--vertical .smart-step__icon,.smart-step--vertical .smart-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.smart-step--vertical .smart-step__icon{background-color:var(--steps-background-color,var(--app-B3,#fff));font-size:var(--step-icon-size,12px);line-height:1}.smart-step--vertical .smart-step__line{background-color:var(--step-line-color,var(--app-B6-N7,rgba(0,0,0,.1)));height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1}