@tuya-miniapp/smart-ui 2.3.0-beta-8 → 2.3.0-beta-9

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.
@@ -9,13 +9,12 @@ function percentToDecimal(percent) {
9
9
  percent = percent.replace('%', '');
10
10
  return percent / 100;
11
11
  }
12
+ const idListRef = {
13
+ value: [],
14
+ };
12
15
  SmartComponent({
13
16
  props: {
14
17
  className: String,
15
- canvasId: {
16
- type: String,
17
- value: 'circle_' + Date.now(),
18
- },
19
18
  customStyle: String,
20
19
  size: {
21
20
  type: String,
@@ -44,7 +43,9 @@ SmartComponent({
44
43
  type: Number,
45
44
  value: 0,
46
45
  observer(val) {
47
- this.render(val);
46
+ if (this.data.canvasId) {
47
+ this.render(val, this.data.canvasId);
48
+ }
48
49
  },
49
50
  },
50
51
  mode: {
@@ -57,7 +58,44 @@ SmartComponent({
57
58
  value: true,
58
59
  },
59
60
  },
61
+ data: {
62
+ canvasId: '',
63
+ dpr: 1,
64
+ },
65
+ created() {
66
+ this.initId();
67
+ this.initRate();
68
+ },
69
+ mounted() {
70
+ this.render(this.data.percent, this.data.canvasId);
71
+ },
72
+ destroyed() {
73
+ idListRef.value = idListRef.value.filter(id => id !== this.data.canvasId);
74
+ },
60
75
  methods: {
76
+ initId() {
77
+ if (this.data.canvasId)
78
+ return;
79
+ const id = `smart-ui-circle_${String(+new Date()).slice(-4)}_${String(Math.random()).slice(-2)}`;
80
+ if (idListRef.value.includes(id)) {
81
+ this.initId();
82
+ return;
83
+ }
84
+ this.setData({
85
+ canvasId: id,
86
+ });
87
+ idListRef.value.push(id);
88
+ },
89
+ initRate() {
90
+ wx.getSystemInfo({
91
+ success: res => {
92
+ const dpr = res.pixelRatio; // 获取设备像素比
93
+ this.setData({
94
+ dpr: dpr,
95
+ });
96
+ },
97
+ });
98
+ },
61
99
  renderAll(canvas, ctx, progress, ops = {
62
100
  lineCap: 'round',
63
101
  }) {
@@ -97,6 +135,7 @@ SmartComponent({
97
135
  }
98
136
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
99
137
  ctx.stroke();
138
+ ctx.scale(canvas.dpr, canvas.dpr);
100
139
  ctx.draw();
101
140
  }
102
141
  // 示例:绘制不同的进度条
@@ -141,6 +180,7 @@ SmartComponent({
141
180
  }
142
181
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
143
182
  ctx.stroke();
183
+ ctx.scale(canvas.dpr, canvas.dpr);
144
184
  ctx.draw();
145
185
  }
146
186
  // 示例:绘制不同的进度条
@@ -196,24 +236,29 @@ SmartComponent({
196
236
  }
197
237
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
198
238
  ctx.stroke();
239
+ ctx.scale(canvas.dpr, canvas.dpr);
199
240
  ctx.draw();
200
241
  }
201
242
  // 示例:绘制不同的进度条
202
243
  drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
203
244
  },
204
- render(val) {
245
+ render(val, canvasId) {
205
246
  // @ts-ignore
206
- const context = ty.createCanvasContext(this.data.canvasId);
247
+ const context = ty.createCanvasContext(canvasId);
207
248
  const sizeVal = this.parseSize();
208
249
  const params = {
209
- width: sizeVal,
210
- height: sizeVal,
250
+ canvasWidth: +sizeVal,
251
+ canvasHeight: +sizeVal,
252
+ width: +sizeVal,
253
+ height: +sizeVal,
211
254
  lineWidth: this.data.trackWidth,
212
255
  trackColor: this.data.trackColor,
213
256
  fillColor: this.data.fillColor,
214
257
  fillColorStops: this.data.fillColorStops,
215
258
  maskColor: this.data.maskColor,
259
+ dpr: this.data.dpr,
216
260
  };
261
+ this.setData(params);
217
262
  if (this.data.mode === 'basic') {
218
263
  this.renderAll(params, context, val / 100, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
219
264
  }
@@ -1 +1,9 @@
1
- <canvas class="smart-progress-circle" type="2d" canvas-id="{{canvasId}}" style="width: {{size}}; height:{{size}};"></canvas>
1
+ <canvas
2
+ class="smart-progress-circle"
3
+ type="2d"
4
+ wx:if="{{canvasId}}"
5
+ width="{{ canvasWidth * dpr }}"
6
+ height="{{ canvasHeight * dpr }}"
7
+ canvas-id="{{canvasId}}"
8
+ style="width: {{width}}px; height:{{height}}px;"
9
+ ></canvas>
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /// <reference types="miniprogram-api-typings" />
3
2
  /// <reference types="miniprogram-api-typings" />
4
3
  /// <reference types="miniprogram-api-typings" />
@@ -8,7 +7,7 @@ export { getSystemInfoSync } from './version';
8
7
  export declare function range(num: number, min: number, max: number): number;
9
8
  export declare function nextTick(cb: (...args: any[]) => void): void;
10
9
  export declare function addUnit(value?: string | number): string | undefined;
11
- export declare function requestAnimationFrame(cb: () => void): NodeJS.Timeout;
10
+ export declare function requestAnimationFrame(cb?: () => void): Promise<void>;
12
11
  export declare function pickExclude(obj: unknown, keys: string[]): {};
13
12
  export declare function getRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult>;
14
13
  export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
@@ -23,9 +23,12 @@ export function addUnit(value) {
23
23
  return isNumber(value) ? `${value}px` : value;
24
24
  }
25
25
  export function requestAnimationFrame(cb) {
26
- return setTimeout(() => {
27
- cb();
28
- }, 1000 / 30);
26
+ return new Promise(resolve => {
27
+ setTimeout(() => {
28
+ cb === null || cb === void 0 ? void 0 : cb();
29
+ resolve();
30
+ }, 1000 / 30);
31
+ });
29
32
  }
30
33
  export function pickExclude(obj, keys) {
31
34
  if (!isPlainObject(obj)) {
@@ -114,6 +114,9 @@ SmartComponent({
114
114
  },
115
115
  formatterFunc(type, value, data) {
116
116
  var _a, _b;
117
+ if (type === 'part') {
118
+ return value === 0 ? this.data.amText : this.data.pmText;
119
+ }
117
120
  const { formatterMap, formatter = defaultFormatter } = (_a = this === null || this === void 0 ? void 0 : this.data) !== null && _a !== void 0 ? _a : data;
118
121
  const mapDetail = formatterMap === null || formatterMap === void 0 ? void 0 : formatterMap[type];
119
122
  if (typeof mapDetail === 'string') {
@@ -339,8 +342,8 @@ SmartComponent({
339
342
  part,
340
343
  });
341
344
  values = [
342
- part,
343
- formatter('hour', part ? (!hour ? 12 : hour - 12) : hour, this.data),
345
+ formatter('part', part, this.data),
346
+ formatter('hour', part ? (!hour ? '12' : (hour - 12).toString().padStart(2, '0')) : hour, this.data),
344
347
  formatter('minute', minute, this.data),
345
348
  ];
346
349
  }
@@ -82,6 +82,7 @@ const Dialog = (options) => {
82
82
  prom.catch(err => {
83
83
  appLog.info(`Dialog promise Error`, err);
84
84
  console.log(err, '---Dialog-error');
85
+ queueRef.value = [];
85
86
  });
86
87
  return prom;
87
88
  };
@@ -191,5 +191,12 @@ SmartComponent({
191
191
  callback(actionType, this);
192
192
  }
193
193
  },
194
+ // 兜底防止 通过api方式打开组件失败 导致队列没有清除
195
+ onPopUpError() {
196
+ const { callback, actionType } = this.data;
197
+ if (callback) {
198
+ callback(actionType, this);
199
+ }
200
+ },
194
201
  },
195
202
  });
@@ -17,6 +17,8 @@
17
17
  bind:before-leave="onBeforeLeave"
18
18
  bind:leave="onLeave"
19
19
  bind:after-leave="onAfterLeave"
20
+ bind:enter-error="onPopUpError"
21
+ bind:leave-error="onPopUpError"
20
22
  >
21
23
  <view
22
24
  wx:if="{{ title || useTitleSlot }}"
@@ -1,5 +1,13 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  // @ts-nocheck
2
- import appLog from '../common/appLog';
3
11
  import { requestAnimationFrame } from '../common/utils';
4
12
  import { isObj } from '../common/validator';
5
13
  const getClassNames = (name) => ({
@@ -32,6 +40,8 @@ export function transition(showDefaultValue) {
32
40
  type: '',
33
41
  inited: false,
34
42
  display: false,
43
+ animating: false,
44
+ status: '',
35
45
  },
36
46
  ready() {
37
47
  if (this.data.show === true) {
@@ -40,110 +50,100 @@ export function transition(showDefaultValue) {
40
50
  },
41
51
  methods: {
42
52
  observeShow(value, old) {
43
- appLog.info(`transition component observeShow value: ${value};old: ${old}`);
44
53
  if (value === old) {
45
54
  return;
46
55
  }
47
56
  value ? this.enter() : this.leave();
48
57
  },
49
58
  enter() {
50
- if (this.enterFinishedPromise)
59
+ if (this.enterFinishedPromise || this.data.animating)
51
60
  return;
52
- appLog.info(`transition component enter success`);
53
- this.enterFinishedPromise = new Promise(resolve => {
61
+ this.setData({
62
+ animating: true,
63
+ status: 'enter',
64
+ });
65
+ // eslint-disable-next-line no-async-promise-executor
66
+ this.enterFinishedPromise = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
54
67
  const { duration, name } = this.data;
55
68
  const classNames = getClassNames(name);
56
69
  const currentDuration = isObj(duration) ? duration.enter : duration;
57
- if (this.status === 'enter') {
58
- return;
59
- }
60
- this.status = 'enter';
61
70
  this.$emit('before-enter');
62
- requestAnimationFrame(() => {
63
- if (this.status !== 'enter') {
64
- return;
65
- }
66
- this.$emit('enter');
71
+ yield requestAnimationFrame();
72
+ this.$emit('enter');
73
+ this.setData({
74
+ inited: true,
75
+ display: true,
76
+ classes: classNames.enter,
77
+ currentDuration,
78
+ });
79
+ yield requestAnimationFrame();
80
+ this.transitionEnded = false;
81
+ this.setData({ classes: classNames['enter-to'] });
82
+ clearTimeout(this.timer);
83
+ this.timer = setTimeout(() => {
84
+ this.$emit(`after-enter`);
67
85
  this.setData({
68
- inited: true,
69
- display: true,
70
- classes: classNames.enter,
71
- currentDuration,
86
+ animating: false,
72
87
  });
73
- requestAnimationFrame(() => {
74
- if (this.status !== 'enter') {
75
- return;
76
- }
77
- this.transitionEnded = false;
78
- appLog.info(`transition component enter transitionEnded false`);
79
- this.setData({ classes: classNames['enter-to'] });
80
- resolve();
81
- });
82
- });
83
- });
88
+ this.checkShowStatus();
89
+ }, currentDuration + 20);
90
+ resolve();
91
+ }));
84
92
  this.enterFinishedPromise.catch(err => {
85
93
  this.enterFinishedPromise = null;
86
- appLog.info(`enter enterFinishedPromise catch`, err);
87
94
  console.log(err, '---error-enter');
95
+ this.$emit('enter-error', err);
88
96
  });
89
97
  },
90
98
  leave() {
91
- if (!this.enterFinishedPromise)
92
- return;
93
- appLog.info(`transition component leave success`);
94
- this.enterFinishedPromise
95
- .then(() => {
96
- if (!this.data.display) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ if (!this.enterFinishedPromise || this.data.animating)
97
101
  return;
98
- }
99
- const { duration, name } = this.data;
100
- const classNames = getClassNames(name);
101
- const currentDuration = isObj(duration) ? duration.leave : duration;
102
- this.status = 'leave';
103
- this.$emit('before-leave');
104
- requestAnimationFrame(() => {
105
- if (this.status !== 'leave') {
106
- return;
107
- }
102
+ this.setData({
103
+ animating: true,
104
+ status: 'leave',
105
+ });
106
+ this.enterFinishedPromise
107
+ .then(() => __awaiter(this, void 0, void 0, function* () {
108
+ const { duration, name } = this.data;
109
+ const classNames = getClassNames(name);
110
+ const currentDuration = isObj(duration) ? duration.leave : duration;
111
+ this.$emit('before-leave');
112
+ yield requestAnimationFrame();
108
113
  this.$emit('leave');
109
114
  this.setData({
110
115
  classes: classNames.leave,
111
116
  currentDuration,
112
117
  });
113
- requestAnimationFrame(() => {
114
- if (this.status !== 'leave') {
115
- return;
116
- }
117
- this.transitionEnded = false;
118
- appLog.info(`transition component leave transitionEnded false`);
119
- setTimeout(() => {
120
- this.enterFinishedPromise = null;
121
- appLog.info(`transition component enterFinishedPromise cleared`);
122
- this.onTransitionEnd();
123
- }, currentDuration);
124
- this.setData({ classes: classNames['leave-to'] });
125
- });
118
+ yield requestAnimationFrame();
119
+ this.transitionEnded = false;
120
+ clearTimeout(this.timer);
121
+ setTimeout(() => {
122
+ this.enterFinishedPromise = null;
123
+ this.$emit(`after-leave`);
124
+ this.setData({ display: false });
125
+ this.setData({
126
+ animating: false,
127
+ });
128
+ this.checkShowStatus();
129
+ }, currentDuration + 20);
130
+ this.setData({ classes: classNames['leave-to'] });
131
+ }))
132
+ .catch(err => {
133
+ this.enterFinishedPromise = null;
134
+ console.log(err, '---error-leave');
135
+ this.$emit('leave-error', err);
126
136
  });
127
- })
128
- .catch(err => {
129
- this.enterFinishedPromise = null;
130
- appLog.info(`leave enterFinishedPromise catch`, err);
131
- console.log(err, '---error-enter');
132
137
  });
133
138
  },
134
- onTransitionEnd() {
135
- appLog.info(`transition component in transitionEnded ${this.transitionEnded}`);
136
- if (this.transitionEnded) {
137
- return;
138
- }
139
- this.transitionEnded = true;
140
- appLog.info(`transition component in transitionEnded true`);
141
- this.$emit(`after-${this.status}`);
142
- appLog.info(`transition component onTransitionEnd ${this.status} success`);
143
- const { show, display } = this.data;
144
- if (!show && display) {
145
- this.setData({ display: false });
146
- }
139
+ checkShowStatus() {
140
+ return __awaiter(this, void 0, void 0, function* () {
141
+ const { status, show } = this.data;
142
+ yield requestAnimationFrame();
143
+ if ((status === 'enter' && show) || (status === 'leave' && !show))
144
+ return;
145
+ show ? this.enter() : this.leave();
146
+ });
147
147
  },
148
148
  },
149
149
  });
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));padding:var(--popover-padding,12px);position:absolute;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
1
+ @import '../common/index.css';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));opacity:0;padding:var(--popover-padding,12px);position:absolute;transition:opacity .3s ease-in-out;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable prefer-destructuring */
2
2
  import { SmartComponent } from '../common/component';
3
- import { transition } from '../mixins/transition';
4
3
  const IconSrc = (deg) => `<svg style="transform: rotate(${deg})" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18.00000052453666" height="6.000001573609978" viewBox="0 0 18.00000052453666 6.000001573609978"><g transform="matrix(-1,-8.742277657347586e-8,-8.742277657347586e-8,1,36.00000104907346,0.0000015736100241790166)"><path d="M18.026037824536658,0.006179333609978323C18.827028524536658,0.014487173609978322,19.72353052453666,0.026256673609978323,20.50303052453666,0.3038745736099783C21.34506052453666,0.6038775736099783,21.90250052453666,1.1284215736099783,22.46337052453666,1.7457315736099783C22.867160524536658,2.1897415736099783,23.66033052453666,3.137051573609978,24.04654052453666,3.5944415736099784C24.36263052453666,3.9694415736099784,24.98139052453666,4.710681573609978,25.31923052453666,5.0693015736099785C25.74452052453666,5.520461573609978,26.270210524536658,6.000001573609978,27.00036052453666,6.000001573609978C27.730510524536662,6.000001573609978,28.25600052453666,5.520461573609978,28.681000524536657,5.069761573609978C29.01880052453666,4.711371573609978,29.63760052453666,3.969671573609978,29.95390052453666,3.5949015736099783C30.33970052453666,3.137511573609978,31.13280052453666,2.1902015736099782,31.53690052453666,1.7461915736099782C32.09870052453666,1.1288815736099784,32.65520052453666,0.6043385736099783,33.49700052453666,0.3043355736099783C34.276700524536665,0.027410573609978322,35.17340052453666,0.014948673609978322,35.97390052453666,0.006640913609978322C36.811100524536656,-0.0018975863900216774,17.189137524536658,-0.0023591663900216775,18.026037824536658,0.006179333609978323Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g></svg>`;
5
4
  function createSvgIcon(svg) {
6
5
  return `data:image/svg+xml,${encodeURIComponent(`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">${svg}`)}`;
@@ -15,7 +14,6 @@ SmartComponent({
15
14
  'leave-to-class',
16
15
  'close-icon-class',
17
16
  ],
18
- mixins: [transition(false)],
19
17
  props: {
20
18
  // `top`、`topLeft`、`topRight`、`bottom`、`bottomLeft`、`bottomRight`、`left`、`leftTop`、`leftBottom`、`right`、`rightTop`、`rightBottom`
21
19
  placement: {
@@ -26,9 +24,12 @@ SmartComponent({
26
24
  type: Boolean,
27
25
  observer(value) {
28
26
  if (value !== this.data.currentShow) {
29
- this.setData({
30
- currentShow: value,
31
- });
27
+ if (value) {
28
+ this.onOpen();
29
+ }
30
+ else {
31
+ this.onClose();
32
+ }
32
33
  }
33
34
  },
34
35
  },
@@ -42,10 +43,10 @@ SmartComponent({
42
43
  },
43
44
  duration: {
44
45
  type: Number,
45
- value: 2000,
46
+ value: 20000,
46
47
  },
47
48
  },
48
- data: { currentShow: false },
49
+ data: { currentShow: false, showStyle: '' },
49
50
  mounted() { },
50
51
  created() { },
51
52
  methods: {
@@ -157,10 +158,18 @@ SmartComponent({
157
158
  this.setData(params);
158
159
  },
159
160
  onClick() {
161
+ this.onOpen();
162
+ },
163
+ onOpen() {
160
164
  this.getButtonPosition();
161
165
  this.setData({
162
166
  currentShow: true,
163
167
  });
168
+ setTimeout(() => {
169
+ this.setData({
170
+ showStyle: 'opacity: 1;',
171
+ });
172
+ }, 100);
164
173
  this.$emit('show-change', true);
165
174
  if (this.data.duration) {
166
175
  setTimeout(() => {
@@ -170,10 +179,15 @@ SmartComponent({
170
179
  },
171
180
  onClose() {
172
181
  this.setData({
173
- currentShow: false,
182
+ showStyle: 'opacity: 0;',
174
183
  });
175
- this.$emit('show-change', false);
176
- this.$emit('close', false);
184
+ setTimeout(() => {
185
+ this.setData({
186
+ currentShow: false,
187
+ });
188
+ this.$emit('show-change', false);
189
+ this.$emit('close', false);
190
+ }, 300);
177
191
  },
178
192
  },
179
193
  });
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "component": true,
3
3
  "usingComponents": {
4
- "smart-transition": "../transition/index",
5
4
  "smart-overlay": "../overlay/index"
6
5
  }
7
6
  }
@@ -12,14 +12,12 @@
12
12
 
13
13
  </smart-overlay>
14
14
 
15
- <view class="smart-popover-button" id="{{popoverId}}" catch:tap="onClick">
15
+ <view class="smart-popover-button" catch:tap="onClick">
16
16
  <slot />
17
- <smart-transition show="{{currentShow}}">
18
- <view class="smart-popover-overlay" style="left: {{left}};top: {{top}}; bottom:{{bottom}};right:{{right}}; transform:{{transform}}; {{customStyle}}">
19
- <slot name="overlay" />
20
- <view class="smart-popover-overlay-arrow" style="background-image: url('{{iconSrc}}'); transform: {{iconTransform}}; {{iconPos}}: {{iconPosVal}}px;width: {{iconWidth}};height:{{iconHeight}};background-size: {{iconWidth}} {{iconHeight}};{{iconStyle}}"></view>
21
- </view>
22
- </smart-transition>
17
+ <view wx:if="{{currentShow}}" class="smart-popover-overlay" style="left: {{left}};top: {{top}}; bottom:{{bottom}};right:{{right}}; transform:{{transform}}; {{customStyle}}; {{showStyle}}">
18
+ <slot name="overlay" />
19
+ <view class="smart-popover-overlay-arrow" style="background-image: url('{{iconSrc}}'); transform: {{iconTransform}}; {{iconPos}}: {{iconPosVal}}px;width: {{iconWidth}};height:{{iconHeight}};background-size: {{iconWidth}} {{iconHeight}};{{iconStyle}}"></view>
20
+ </view>
23
21
  </view>
24
22
 
25
23
  </view>
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));padding:var(--popover-padding,12px);position:absolute;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
1
+ @import '../common/index.wxss';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));opacity:0;padding:var(--popover-padding,12px);position:absolute;transition:opacity .3s ease-in-out;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
@@ -4,7 +4,6 @@
4
4
  wx:if="{{ inited }}"
5
5
  class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
6
6
  style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle, bottomSafeHeight }) }}"
7
- bind:transitionend="onTransitionEnd"
8
7
  catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
9
8
  >
10
9
  <slot />
@@ -4,7 +4,6 @@
4
4
  wx:if="{{ inited }}"
5
5
  class="smart-transition custom-class {{ classes }}"
6
6
  style="{{ computed.rootStyle({ currentDuration, display, customStyle }) }}"
7
- bind:transitionend="onTransitionEnd"
8
7
  >
9
8
  <slot />
10
9
  </view>
@@ -11,13 +11,12 @@ function percentToDecimal(percent) {
11
11
  percent = percent.replace('%', '');
12
12
  return percent / 100;
13
13
  }
14
+ var idListRef = {
15
+ value: [],
16
+ };
14
17
  (0, component_1.SmartComponent)({
15
18
  props: {
16
19
  className: String,
17
- canvasId: {
18
- type: String,
19
- value: 'circle_' + Date.now(),
20
- },
21
20
  customStyle: String,
22
21
  size: {
23
22
  type: String,
@@ -46,7 +45,9 @@ function percentToDecimal(percent) {
46
45
  type: Number,
47
46
  value: 0,
48
47
  observer: function (val) {
49
- this.render(val);
48
+ if (this.data.canvasId) {
49
+ this.render(val, this.data.canvasId);
50
+ }
50
51
  },
51
52
  },
52
53
  mode: {
@@ -59,7 +60,46 @@ function percentToDecimal(percent) {
59
60
  value: true,
60
61
  },
61
62
  },
63
+ data: {
64
+ canvasId: '',
65
+ dpr: 1,
66
+ },
67
+ created: function () {
68
+ this.initId();
69
+ this.initRate();
70
+ },
71
+ mounted: function () {
72
+ this.render(this.data.percent, this.data.canvasId);
73
+ },
74
+ destroyed: function () {
75
+ var _this = this;
76
+ idListRef.value = idListRef.value.filter(function (id) { return id !== _this.data.canvasId; });
77
+ },
62
78
  methods: {
79
+ initId: function () {
80
+ if (this.data.canvasId)
81
+ return;
82
+ var id = "smart-ui-circle_".concat(String(+new Date()).slice(-4), "_").concat(String(Math.random()).slice(-2));
83
+ if (idListRef.value.includes(id)) {
84
+ this.initId();
85
+ return;
86
+ }
87
+ this.setData({
88
+ canvasId: id,
89
+ });
90
+ idListRef.value.push(id);
91
+ },
92
+ initRate: function () {
93
+ var _this = this;
94
+ wx.getSystemInfo({
95
+ success: function (res) {
96
+ var dpr = res.pixelRatio; // 获取设备像素比
97
+ _this.setData({
98
+ dpr: dpr,
99
+ });
100
+ },
101
+ });
102
+ },
63
103
  renderAll: function (canvas, ctx, progress, ops) {
64
104
  if (ops === void 0) { ops = {
65
105
  lineCap: 'round',
@@ -100,6 +140,7 @@ function percentToDecimal(percent) {
100
140
  }
101
141
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
102
142
  ctx.stroke();
143
+ ctx.scale(canvas.dpr, canvas.dpr);
103
144
  ctx.draw();
104
145
  }
105
146
  // 示例:绘制不同的进度条
@@ -145,6 +186,7 @@ function percentToDecimal(percent) {
145
186
  }
146
187
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
147
188
  ctx.stroke();
189
+ ctx.scale(canvas.dpr, canvas.dpr);
148
190
  ctx.draw();
149
191
  }
150
192
  // 示例:绘制不同的进度条
@@ -201,24 +243,29 @@ function percentToDecimal(percent) {
201
243
  }
202
244
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
203
245
  ctx.stroke();
246
+ ctx.scale(canvas.dpr, canvas.dpr);
204
247
  ctx.draw();
205
248
  }
206
249
  // 示例:绘制不同的进度条
207
250
  drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
208
251
  },
209
- render: function (val) {
252
+ render: function (val, canvasId) {
210
253
  // @ts-ignore
211
- var context = ty.createCanvasContext(this.data.canvasId);
254
+ var context = ty.createCanvasContext(canvasId);
212
255
  var sizeVal = this.parseSize();
213
256
  var params = {
214
- width: sizeVal,
215
- height: sizeVal,
257
+ canvasWidth: +sizeVal,
258
+ canvasHeight: +sizeVal,
259
+ width: +sizeVal,
260
+ height: +sizeVal,
216
261
  lineWidth: this.data.trackWidth,
217
262
  trackColor: this.data.trackColor,
218
263
  fillColor: this.data.fillColor,
219
264
  fillColorStops: this.data.fillColorStops,
220
265
  maskColor: this.data.maskColor,
266
+ dpr: this.data.dpr,
221
267
  };
268
+ this.setData(params);
222
269
  if (this.data.mode === 'basic') {
223
270
  this.renderAll(params, context, val / 100, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
224
271
  }
@@ -1 +1,9 @@
1
- <canvas class="smart-progress-circle" type="2d" canvas-id="{{canvasId}}" style="width: {{size}}; height:{{size}};"></canvas>
1
+ <canvas
2
+ class="smart-progress-circle"
3
+ type="2d"
4
+ wx:if="{{canvasId}}"
5
+ width="{{ canvasWidth * dpr }}"
6
+ height="{{ canvasHeight * dpr }}"
7
+ canvas-id="{{canvasId}}"
8
+ style="width: {{width}}px; height:{{height}}px;"
9
+ ></canvas>
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /// <reference types="miniprogram-api-typings" />
3
2
  /// <reference types="miniprogram-api-typings" />
4
3
  /// <reference types="miniprogram-api-typings" />
@@ -8,7 +7,7 @@ export { getSystemInfoSync } from './version';
8
7
  export declare function range(num: number, min: number, max: number): number;
9
8
  export declare function nextTick(cb: (...args: any[]) => void): void;
10
9
  export declare function addUnit(value?: string | number): string | undefined;
11
- export declare function requestAnimationFrame(cb: () => void): NodeJS.Timeout;
10
+ export declare function requestAnimationFrame(cb?: () => void): Promise<void>;
12
11
  export declare function pickExclude(obj: unknown, keys: string[]): {};
13
12
  export declare function getRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult>;
14
13
  export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
@@ -31,9 +31,12 @@ function addUnit(value) {
31
31
  }
32
32
  exports.addUnit = addUnit;
33
33
  function requestAnimationFrame(cb) {
34
- return setTimeout(function () {
35
- cb();
36
- }, 1000 / 30);
34
+ return new Promise(function (resolve) {
35
+ setTimeout(function () {
36
+ cb === null || cb === void 0 ? void 0 : cb();
37
+ resolve();
38
+ }, 1000 / 30);
39
+ });
37
40
  }
38
41
  exports.requestAnimationFrame = requestAnimationFrame;
39
42
  function pickExclude(obj, keys) {
@@ -146,6 +146,9 @@ var defaultFormatter = function (type, value) {
146
146
  formatterFunc: function (type, value, data) {
147
147
  var _a;
148
148
  var _b, _c;
149
+ if (type === 'part') {
150
+ return value === 0 ? this.data.amText : this.data.pmText;
151
+ }
149
152
  var _d = (_b = this === null || this === void 0 ? void 0 : this.data) !== null && _b !== void 0 ? _b : data, formatterMap = _d.formatterMap, _e = _d.formatter, formatter = _e === void 0 ? defaultFormatter : _e;
150
153
  var mapDetail = formatterMap === null || formatterMap === void 0 ? void 0 : formatterMap[type];
151
154
  if (typeof mapDetail === 'string') {
@@ -375,8 +378,8 @@ var defaultFormatter = function (type, value) {
375
378
  part: part,
376
379
  });
377
380
  values = [
378
- part,
379
- formatter('hour', part ? (!hour ? 12 : hour - 12) : hour, this.data),
381
+ formatter('part', part, this.data),
382
+ formatter('hour', part ? (!hour ? '12' : (hour - 12).toString().padStart(2, '0')) : hour, this.data),
380
383
  formatter('minute', minute, this.data),
381
384
  ];
382
385
  }
@@ -99,6 +99,7 @@ var Dialog = function (options) {
99
99
  prom.catch(function (err) {
100
100
  appLog_1.default.info("Dialog promise Error", err);
101
101
  console.log(err, '---Dialog-error');
102
+ queueRef.value = [];
102
103
  });
103
104
  return prom;
104
105
  };
@@ -199,5 +199,12 @@ var dialog_1 = require("./dialog");
199
199
  callback(actionType, this);
200
200
  }
201
201
  },
202
+ // 兜底防止 通过api方式打开组件失败 导致队列没有清除
203
+ onPopUpError: function () {
204
+ var _a = this.data, callback = _a.callback, actionType = _a.actionType;
205
+ if (callback) {
206
+ callback(actionType, this);
207
+ }
208
+ },
202
209
  },
203
210
  });
@@ -17,6 +17,8 @@
17
17
  bind:before-leave="onBeforeLeave"
18
18
  bind:leave="onLeave"
19
19
  bind:after-leave="onAfterLeave"
20
+ bind:enter-error="onPopUpError"
21
+ bind:leave-error="onPopUpError"
20
22
  >
21
23
  <view
22
24
  wx:if="{{ title || useTitleSlot }}"
@@ -1,11 +1,43 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.transition = void 0;
7
40
  // @ts-nocheck
8
- var appLog_1 = __importDefault(require("../common/appLog"));
9
41
  var utils_1 = require("../common/utils");
10
42
  var validator_1 = require("../common/validator");
11
43
  var getClassNames = function (name) { return ({
@@ -38,6 +70,8 @@ function transition(showDefaultValue) {
38
70
  type: '',
39
71
  inited: false,
40
72
  display: false,
73
+ animating: false,
74
+ status: '',
41
75
  },
42
76
  ready: function () {
43
77
  if (this.data.show === true) {
@@ -46,7 +80,6 @@ function transition(showDefaultValue) {
46
80
  },
47
81
  methods: {
48
82
  observeShow: function (value, old) {
49
- appLog_1.default.info("transition component observeShow value: ".concat(value, ";old: ").concat(old));
50
83
  if (value === old) {
51
84
  return;
52
85
  }
@@ -54,104 +87,131 @@ function transition(showDefaultValue) {
54
87
  },
55
88
  enter: function () {
56
89
  var _this = this;
57
- if (this.enterFinishedPromise)
90
+ if (this.enterFinishedPromise || this.data.animating)
58
91
  return;
59
- appLog_1.default.info("transition component enter success");
60
- this.enterFinishedPromise = new Promise(function (resolve) {
61
- var _a = _this.data, duration = _a.duration, name = _a.name;
62
- var classNames = getClassNames(name);
63
- var currentDuration = (0, validator_1.isObj)(duration) ? duration.enter : duration;
64
- if (_this.status === 'enter') {
65
- return;
66
- }
67
- _this.status = 'enter';
68
- _this.$emit('before-enter');
69
- (0, utils_1.requestAnimationFrame)(function () {
70
- if (_this.status !== 'enter') {
71
- return;
92
+ this.setData({
93
+ animating: true,
94
+ status: 'enter',
95
+ });
96
+ // eslint-disable-next-line no-async-promise-executor
97
+ this.enterFinishedPromise = new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
98
+ var _a, duration, name, classNames, currentDuration;
99
+ var _this = this;
100
+ return __generator(this, function (_b) {
101
+ switch (_b.label) {
102
+ case 0:
103
+ _a = this.data, duration = _a.duration, name = _a.name;
104
+ classNames = getClassNames(name);
105
+ currentDuration = (0, validator_1.isObj)(duration) ? duration.enter : duration;
106
+ this.$emit('before-enter');
107
+ return [4 /*yield*/, (0, utils_1.requestAnimationFrame)()];
108
+ case 1:
109
+ _b.sent();
110
+ this.$emit('enter');
111
+ this.setData({
112
+ inited: true,
113
+ display: true,
114
+ classes: classNames.enter,
115
+ currentDuration: currentDuration,
116
+ });
117
+ return [4 /*yield*/, (0, utils_1.requestAnimationFrame)()];
118
+ case 2:
119
+ _b.sent();
120
+ this.transitionEnded = false;
121
+ this.setData({ classes: classNames['enter-to'] });
122
+ clearTimeout(this.timer);
123
+ this.timer = setTimeout(function () {
124
+ _this.$emit("after-enter");
125
+ _this.setData({
126
+ animating: false,
127
+ });
128
+ _this.checkShowStatus();
129
+ }, currentDuration + 20);
130
+ resolve();
131
+ return [2 /*return*/];
72
132
  }
73
- _this.$emit('enter');
74
- _this.setData({
75
- inited: true,
76
- display: true,
77
- classes: classNames.enter,
78
- currentDuration: currentDuration,
79
- });
80
- (0, utils_1.requestAnimationFrame)(function () {
81
- if (_this.status !== 'enter') {
82
- return;
83
- }
84
- _this.transitionEnded = false;
85
- appLog_1.default.info("transition component enter transitionEnded false");
86
- _this.setData({ classes: classNames['enter-to'] });
87
- resolve();
88
- });
89
133
  });
90
- });
134
+ }); });
91
135
  this.enterFinishedPromise.catch(function (err) {
92
136
  _this.enterFinishedPromise = null;
93
- appLog_1.default.info("enter enterFinishedPromise catch", err);
94
137
  console.log(err, '---error-enter');
138
+ _this.$emit('enter-error', err);
95
139
  });
96
140
  },
97
141
  leave: function () {
98
- var _this = this;
99
- if (!this.enterFinishedPromise)
100
- return;
101
- appLog_1.default.info("transition component leave success");
102
- this.enterFinishedPromise
103
- .then(function () {
104
- if (!_this.data.display) {
105
- return;
106
- }
107
- var _a = _this.data, duration = _a.duration, name = _a.name;
108
- var classNames = getClassNames(name);
109
- var currentDuration = (0, validator_1.isObj)(duration) ? duration.leave : duration;
110
- _this.status = 'leave';
111
- _this.$emit('before-leave');
112
- (0, utils_1.requestAnimationFrame)(function () {
113
- if (_this.status !== 'leave') {
114
- return;
115
- }
116
- _this.$emit('leave');
117
- _this.setData({
118
- classes: classNames.leave,
119
- currentDuration: currentDuration,
142
+ return __awaiter(this, void 0, void 0, function () {
143
+ var _this = this;
144
+ return __generator(this, function (_a) {
145
+ if (!this.enterFinishedPromise || this.data.animating)
146
+ return [2 /*return*/];
147
+ this.setData({
148
+ animating: true,
149
+ status: 'leave',
120
150
  });
121
- (0, utils_1.requestAnimationFrame)(function () {
122
- if (_this.status !== 'leave') {
123
- return;
124
- }
125
- _this.transitionEnded = false;
126
- appLog_1.default.info("transition component leave transitionEnded false");
127
- setTimeout(function () {
128
- _this.enterFinishedPromise = null;
129
- appLog_1.default.info("transition component enterFinishedPromise cleared");
130
- _this.onTransitionEnd();
131
- }, currentDuration);
132
- _this.setData({ classes: classNames['leave-to'] });
151
+ this.enterFinishedPromise
152
+ .then(function () { return __awaiter(_this, void 0, void 0, function () {
153
+ var _a, duration, name, classNames, currentDuration;
154
+ var _this = this;
155
+ return __generator(this, function (_b) {
156
+ switch (_b.label) {
157
+ case 0:
158
+ _a = this.data, duration = _a.duration, name = _a.name;
159
+ classNames = getClassNames(name);
160
+ currentDuration = (0, validator_1.isObj)(duration) ? duration.leave : duration;
161
+ this.$emit('before-leave');
162
+ return [4 /*yield*/, (0, utils_1.requestAnimationFrame)()];
163
+ case 1:
164
+ _b.sent();
165
+ this.$emit('leave');
166
+ this.setData({
167
+ classes: classNames.leave,
168
+ currentDuration: currentDuration,
169
+ });
170
+ return [4 /*yield*/, (0, utils_1.requestAnimationFrame)()];
171
+ case 2:
172
+ _b.sent();
173
+ this.transitionEnded = false;
174
+ clearTimeout(this.timer);
175
+ setTimeout(function () {
176
+ _this.enterFinishedPromise = null;
177
+ _this.$emit("after-leave");
178
+ _this.setData({ display: false });
179
+ _this.setData({
180
+ animating: false,
181
+ });
182
+ _this.checkShowStatus();
183
+ }, currentDuration + 20);
184
+ this.setData({ classes: classNames['leave-to'] });
185
+ return [2 /*return*/];
186
+ }
187
+ });
188
+ }); })
189
+ .catch(function (err) {
190
+ _this.enterFinishedPromise = null;
191
+ console.log(err, '---error-leave');
192
+ _this.$emit('leave-error', err);
133
193
  });
194
+ return [2 /*return*/];
134
195
  });
135
- })
136
- .catch(function (err) {
137
- _this.enterFinishedPromise = null;
138
- appLog_1.default.info("leave enterFinishedPromise catch", err);
139
- console.log(err, '---error-enter');
140
196
  });
141
197
  },
142
- onTransitionEnd: function () {
143
- appLog_1.default.info("transition component in transitionEnded ".concat(this.transitionEnded));
144
- if (this.transitionEnded) {
145
- return;
146
- }
147
- this.transitionEnded = true;
148
- appLog_1.default.info("transition component in transitionEnded true");
149
- this.$emit("after-".concat(this.status));
150
- appLog_1.default.info("transition component onTransitionEnd ".concat(this.status, " success"));
151
- var _a = this.data, show = _a.show, display = _a.display;
152
- if (!show && display) {
153
- this.setData({ display: false });
154
- }
198
+ checkShowStatus: function () {
199
+ return __awaiter(this, void 0, void 0, function () {
200
+ var _a, status, show;
201
+ return __generator(this, function (_b) {
202
+ switch (_b.label) {
203
+ case 0:
204
+ _a = this.data, status = _a.status, show = _a.show;
205
+ return [4 /*yield*/, (0, utils_1.requestAnimationFrame)()];
206
+ case 1:
207
+ _b.sent();
208
+ if ((status === 'enter' && show) || (status === 'leave' && !show))
209
+ return [2 /*return*/];
210
+ show ? this.enter() : this.leave();
211
+ return [2 /*return*/];
212
+ }
213
+ });
214
+ });
155
215
  },
156
216
  },
157
217
  });
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));padding:var(--popover-padding,12px);position:absolute;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
1
+ @import '../common/index.css';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));opacity:0;padding:var(--popover-padding,12px);position:absolute;transition:opacity .3s ease-in-out;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
@@ -13,7 +13,6 @@ var __assign = (this && this.__assign) || function () {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  /* eslint-disable prefer-destructuring */
15
15
  var component_1 = require("../common/component");
16
- var transition_1 = require("../mixins/transition");
17
16
  var IconSrc = function (deg) {
18
17
  return "<svg style=\"transform: rotate(".concat(deg, ")\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"none\" version=\"1.1\" width=\"18.00000052453666\" height=\"6.000001573609978\" viewBox=\"0 0 18.00000052453666 6.000001573609978\"><g transform=\"matrix(-1,-8.742277657347586e-8,-8.742277657347586e-8,1,36.00000104907346,0.0000015736100241790166)\"><path d=\"M18.026037824536658,0.006179333609978323C18.827028524536658,0.014487173609978322,19.72353052453666,0.026256673609978323,20.50303052453666,0.3038745736099783C21.34506052453666,0.6038775736099783,21.90250052453666,1.1284215736099783,22.46337052453666,1.7457315736099783C22.867160524536658,2.1897415736099783,23.66033052453666,3.137051573609978,24.04654052453666,3.5944415736099784C24.36263052453666,3.9694415736099784,24.98139052453666,4.710681573609978,25.31923052453666,5.0693015736099785C25.74452052453666,5.520461573609978,26.270210524536658,6.000001573609978,27.00036052453666,6.000001573609978C27.730510524536662,6.000001573609978,28.25600052453666,5.520461573609978,28.681000524536657,5.069761573609978C29.01880052453666,4.711371573609978,29.63760052453666,3.969671573609978,29.95390052453666,3.5949015736099783C30.33970052453666,3.137511573609978,31.13280052453666,2.1902015736099782,31.53690052453666,1.7461915736099782C32.09870052453666,1.1288815736099784,32.65520052453666,0.6043385736099783,33.49700052453666,0.3043355736099783C34.276700524536665,0.027410573609978322,35.17340052453666,0.014948673609978322,35.97390052453666,0.006640913609978322C36.811100524536656,-0.0018975863900216774,17.189137524536658,-0.0023591663900216775,18.026037824536658,0.006179333609978323Z\" fill-rule=\"evenodd\" fill=\"#FFFFFF\" fill-opacity=\"1\"/></g></svg>");
19
18
  };
@@ -30,7 +29,6 @@ function createSvgIcon(svg) {
30
29
  'leave-to-class',
31
30
  'close-icon-class',
32
31
  ],
33
- mixins: [(0, transition_1.transition)(false)],
34
32
  props: {
35
33
  // `top`、`topLeft`、`topRight`、`bottom`、`bottomLeft`、`bottomRight`、`left`、`leftTop`、`leftBottom`、`right`、`rightTop`、`rightBottom`
36
34
  placement: {
@@ -41,9 +39,12 @@ function createSvgIcon(svg) {
41
39
  type: Boolean,
42
40
  observer: function (value) {
43
41
  if (value !== this.data.currentShow) {
44
- this.setData({
45
- currentShow: value,
46
- });
42
+ if (value) {
43
+ this.onOpen();
44
+ }
45
+ else {
46
+ this.onClose();
47
+ }
47
48
  }
48
49
  },
49
50
  },
@@ -57,10 +58,10 @@ function createSvgIcon(svg) {
57
58
  },
58
59
  duration: {
59
60
  type: Number,
60
- value: 2000,
61
+ value: 20000,
61
62
  },
62
63
  },
63
- data: { currentShow: false },
64
+ data: { currentShow: false, showStyle: '' },
64
65
  mounted: function () { },
65
66
  created: function () { },
66
67
  methods: {
@@ -172,11 +173,19 @@ function createSvgIcon(svg) {
172
173
  this.setData(params);
173
174
  },
174
175
  onClick: function () {
176
+ this.onOpen();
177
+ },
178
+ onOpen: function () {
175
179
  var _this = this;
176
180
  this.getButtonPosition();
177
181
  this.setData({
178
182
  currentShow: true,
179
183
  });
184
+ setTimeout(function () {
185
+ _this.setData({
186
+ showStyle: 'opacity: 1;',
187
+ });
188
+ }, 100);
180
189
  this.$emit('show-change', true);
181
190
  if (this.data.duration) {
182
191
  setTimeout(function () {
@@ -185,11 +194,17 @@ function createSvgIcon(svg) {
185
194
  }
186
195
  },
187
196
  onClose: function () {
197
+ var _this = this;
188
198
  this.setData({
189
- currentShow: false,
199
+ showStyle: 'opacity: 0;',
190
200
  });
191
- this.$emit('show-change', false);
192
- this.$emit('close', false);
201
+ setTimeout(function () {
202
+ _this.setData({
203
+ currentShow: false,
204
+ });
205
+ _this.$emit('show-change', false);
206
+ _this.$emit('close', false);
207
+ }, 300);
193
208
  },
194
209
  },
195
210
  });
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "component": true,
3
3
  "usingComponents": {
4
- "smart-transition": "../transition/index",
5
4
  "smart-overlay": "../overlay/index"
6
5
  }
7
6
  }
@@ -12,14 +12,12 @@
12
12
 
13
13
  </smart-overlay>
14
14
 
15
- <view class="smart-popover-button" id="{{popoverId}}" catch:tap="onClick">
15
+ <view class="smart-popover-button" catch:tap="onClick">
16
16
  <slot />
17
- <smart-transition show="{{currentShow}}">
18
- <view class="smart-popover-overlay" style="left: {{left}};top: {{top}}; bottom:{{bottom}};right:{{right}}; transform:{{transform}}; {{customStyle}}">
19
- <slot name="overlay" />
20
- <view class="smart-popover-overlay-arrow" style="background-image: url('{{iconSrc}}'); transform: {{iconTransform}}; {{iconPos}}: {{iconPosVal}}px;width: {{iconWidth}};height:{{iconHeight}};background-size: {{iconWidth}} {{iconHeight}};{{iconStyle}}"></view>
21
- </view>
22
- </smart-transition>
17
+ <view wx:if="{{currentShow}}" class="smart-popover-overlay" style="left: {{left}};top: {{top}}; bottom:{{bottom}};right:{{right}}; transform:{{transform}}; {{customStyle}}; {{showStyle}}">
18
+ <slot name="overlay" />
19
+ <view class="smart-popover-overlay-arrow" style="background-image: url('{{iconSrc}}'); transform: {{iconTransform}}; {{iconPos}}: {{iconPosVal}}px;width: {{iconWidth}};height:{{iconHeight}};background-size: {{iconWidth}} {{iconHeight}};{{iconStyle}}"></view>
20
+ </view>
23
21
  </view>
24
22
 
25
23
  </view>
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));padding:var(--popover-padding,12px);position:absolute;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
1
+ @import '../common/index.wxss';.smart-popover{--overlay-background-color:transparent;position:relative}.smart-popover,.smart-popover-button{display:inline-block}.smart-popover-overlay{background-color:var(--popover-background-color,var(--app-B4,#fff));border-radius:var(--popover-border-radius,12px);box-shadow:var(--popover-box-shadow,0 6px 12px 0 rgba(0,0,0,.1));opacity:0;padding:var(--popover-padding,12px);position:absolute;transition:opacity .3s ease-in-out;z-index:102}.smart-popover-overlay-arrow{background-position:50%;background-repeat:no-repeat;position:absolute}
@@ -4,7 +4,6 @@
4
4
  wx:if="{{ inited }}"
5
5
  class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
6
6
  style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle, bottomSafeHeight }) }}"
7
- bind:transitionend="onTransitionEnd"
8
7
  catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
9
8
  >
10
9
  <slot />
@@ -4,7 +4,6 @@
4
4
  wx:if="{{ inited }}"
5
5
  class="smart-transition custom-class {{ classes }}"
6
6
  style="{{ computed.rootStyle({ currentDuration, display, customStyle }) }}"
7
- bind:transitionend="onTransitionEnd"
8
7
  >
9
8
  <slot />
10
9
  </view>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.3.0-beta-8",
3
+ "version": "2.3.0-beta-9",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",