@tuya-miniapp/smart-ui 2.7.3-beta-1 → 2.7.4-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/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}