@ray-js/t-agent-ui-ray 0.2.4-beta-2 → 0.2.4-beta-4

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.
@@ -20,11 +20,12 @@ export class LazyItemContext {
20
20
  this.height = rect.height;
21
21
  this.eventName = `${this.prefix}${scrollViewId}/${itemId}`;
22
22
 
23
- ownerInstance.eventChannel.on(this.eventName, (event) => {
23
+ ownerInstance.eventChannel.on(this.eventName, event => {
24
24
  switch (event.type) {
25
25
  case 'refreshSize':
26
- this._refreshSize(ownerInstance, instance, false);
27
- ownerInstance.eventChannel.emit(`${this.eventName}/${event.id}`, this.height);
26
+ this._refreshSize(ownerInstance, instance, false).then(() => {
27
+ ownerInstance.eventChannel.emit(`${this.eventName}/${event.id}`, this.height);
28
+ });
28
29
  break;
29
30
  }
30
31
  });
@@ -36,16 +37,26 @@ export class LazyItemContext {
36
37
  }
37
38
 
38
39
  refreshSize(ownerInstance) {
39
- return new Promise((resolve) => {
40
- const id = Math.random()
41
- ownerInstance.eventChannel.once(`${this.eventName}/${id}`, resolve)
40
+ return new Promise(resolve => {
41
+ const id = Math.random();
42
+ ownerInstance.eventChannel.once(`${this.eventName}/${id}`, resolve);
42
43
  ownerInstance.eventChannel.emit(this.eventName, { type: 'refreshSize', id });
43
- })
44
+ });
45
+ }
46
+
47
+ _measureAndSetHeight(instance) {
48
+ const rect = instance.getBoundingClientRect();
49
+ this.height = rect.height;
50
+ if (this.ready) {
51
+ instance.setStyle({
52
+ minHeight: `${rect.height}px`,
53
+ });
54
+ }
44
55
  }
45
56
 
46
57
  _refreshSize(ownerInstance, instance, byUpdate = false) {
47
58
  if (this.show === false) {
48
- return;
59
+ return Promise.resolve();
49
60
  }
50
61
 
51
62
  if (byUpdate && this.ready && this.show === true) {
@@ -55,24 +66,28 @@ export class LazyItemContext {
55
66
  });
56
67
  }
57
68
 
58
- const rect = instance.getBoundingClientRect();
59
- this.height = rect.height;
60
- if (this.ready) {
61
- instance.setStyle({
62
- minHeight: `${rect.height}px`,
69
+ if (byUpdate) {
70
+ return new Promise(resolve => {
71
+ requestAnimationFrame(() => {
72
+ this._measureAndSetHeight(instance);
73
+ resolve();
74
+ });
63
75
  });
64
76
  }
77
+
78
+ this._measureAndSetHeight(instance);
79
+ return Promise.resolve();
65
80
  }
66
81
 
67
82
  onUpdate(ownerInstance, instance) {
68
- this._refreshSize(ownerInstance, instance, true);
69
-
70
- if (this.ready) {
71
- this.emitToScroll(ownerInstance,{
72
- type: 'itemUpdate',
73
- itemContext: this,
74
- });
75
- }
83
+ this._refreshSize(ownerInstance, instance, true).then(() => {
84
+ if (this.ready) {
85
+ this.emitToScroll(ownerInstance, {
86
+ type: 'itemUpdate',
87
+ itemContext: this,
88
+ });
89
+ }
90
+ });
76
91
  }
77
92
 
78
93
  onReady(ownerInstance, instance) {
@@ -17,7 +17,6 @@
17
17
  &-list {
18
18
  display: flex;
19
19
  flex-direction: column;
20
- gap: 24rpx;
21
20
  }
22
21
 
23
22
  &-item {
@@ -27,6 +26,10 @@
27
26
  background-color: var(--app-B1);
28
27
  border-radius: 12rpx;
29
28
 
29
+ & + & {
30
+ margin-top: 24rpx;
31
+ }
32
+
30
33
  &:active {
31
34
  opacity: 0.8;
32
35
  }
@@ -66,7 +69,6 @@
66
69
  &-list {
67
70
  display: flex;
68
71
  flex-direction: column;
69
- gap: 24rpx;
70
72
  }
71
73
 
72
74
  &-item {
@@ -76,6 +78,10 @@
76
78
  background-color: var(--app-B1);
77
79
  border-radius: 12rpx;
78
80
 
81
+ & + & {
82
+ margin-top: 24rpx;
83
+ }
84
+
79
85
  &:active {
80
86
  opacity: 0.8;
81
87
  }
@@ -104,7 +110,6 @@
104
110
  &-list {
105
111
  display: flex;
106
112
  flex-direction: column;
107
- gap: 24rpx;
108
113
  }
109
114
 
110
115
  &-item {
@@ -114,6 +119,10 @@
114
119
  background-color: var(--app-B1);
115
120
  border-radius: 12rpx;
116
121
 
122
+ & + & {
123
+ margin-top: 24rpx;
124
+ }
125
+
117
126
  &:active {
118
127
  opacity: 0.8;
119
128
  }
@@ -71,6 +71,7 @@ const handleDesc = (detail, t) => {
71
71
  items: desc.join(t('t-agent.operate-card-tile.description.separator'))
72
72
  });
73
73
  };
74
+ const globalExpandStateCache = new Map();
74
75
  export default function OperateCardTile(props) {
75
76
  const {
76
77
  tile,
@@ -83,7 +84,15 @@ export default function OperateCardTile(props) {
83
84
  changeInfo = []
84
85
  } = tile.data || {};
85
86
  const t = useTranslate();
86
- const [showDetail, setShowDetail] = useState(false);
87
+ const stateKey = "OperateCardTile.showDetail.".concat(tile.id);
88
+ const [showDetail, setShowDetailState] = useState(() => {
89
+ var _globalExpandStateCac;
90
+ return (_globalExpandStateCac = globalExpandStateCache.get(stateKey)) !== null && _globalExpandStateCac !== void 0 ? _globalExpandStateCac : false;
91
+ });
92
+ const setShowDetail = value => {
93
+ globalExpandStateCache.set(stateKey, value);
94
+ setShowDetailState(value);
95
+ };
87
96
  const tapDevice = e => {
88
97
  const deviceId = e.currentTarget.dataset.id;
89
98
  ty.openPanel({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-ui-ray",
3
- "version": "0.2.4-beta-2",
3
+ "version": "0.2.4-beta-4",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -40,5 +40,5 @@
40
40
  "@types/echarts": "^4.9.22",
41
41
  "@types/markdown-it": "^14.1.1"
42
42
  },
43
- "gitHead": "3566263a43775a512420e832d5d9bef68ff82ded"
43
+ "gitHead": "651120ff704ee5ff8430e4a3a5a741e1f913958a"
44
44
  }