@sheinx/base 3.8.0-beta.34 → 3.8.0-beta.36

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.
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-header.d.ts","sourceRoot":"","sources":["tabs-header.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAwBrD,QAAA,MAAM,UAAU,UAAW,eAAe,4CAuQzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"tabs-header.d.ts","sourceRoot":"","sources":["tabs-header.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAwBrD,QAAA,MAAM,UAAU,UAAW,eAAe,4CA4RzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -144,10 +144,33 @@ var TabsHeader = function TabsHeader(props) {
144
144
 
145
145
  // 使用 offsetWidth/offsetHeight 而不是 getBoundingClientRect()
146
146
  // 这样可以避免受到外部容器 CSS transform scale 的影响
147
- setCurrentTabSize({
148
- width: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetWidth) || 0,
149
- height: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetHeight) || 0
150
- });
147
+ var width = (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetWidth) || 0;
148
+ var height = (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetHeight) || 0;
149
+ // 微前端场景下,可能出现获取不到元素的尺寸信息
150
+ if (width === 0 || height === 0) {
151
+ var timerCount = 0;
152
+ var timer = setInterval(function () {
153
+ timerCount++;
154
+ if (currentTab !== null && currentTab !== void 0 && currentTab.offsetWidth && currentTab !== null && currentTab !== void 0 && currentTab.offsetHeight) {
155
+ setCurrentTabSize({
156
+ width: currentTab.offsetWidth,
157
+ height: currentTab.offsetHeight
158
+ });
159
+ clearInterval(timer);
160
+ }
161
+ if (timerCount >= 100) {
162
+ clearInterval(timer);
163
+ }
164
+ }, 16);
165
+ return function () {
166
+ return clearInterval(timer);
167
+ };
168
+ } else {
169
+ setCurrentTabSize({
170
+ width: width,
171
+ height: height
172
+ });
173
+ }
151
174
  }, [active, tabs]);
152
175
  var renderHeaderScrollBar = function renderHeaderScrollBar() {
153
176
  if (shape !== 'line' && shape !== 'dash') return;
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-header.d.ts","sourceRoot":"","sources":["tabs-header.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAwBrD,QAAA,MAAM,UAAU,UAAW,eAAe,4CAuQzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"tabs-header.d.ts","sourceRoot":"","sources":["tabs-header.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAwBrD,QAAA,MAAM,UAAU,UAAW,eAAe,4CA4RzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -138,10 +138,33 @@ var TabsHeader = function TabsHeader(props) {
138
138
 
139
139
  // 使用 offsetWidth/offsetHeight 而不是 getBoundingClientRect()
140
140
  // 这样可以避免受到外部容器 CSS transform scale 的影响
141
- setCurrentTabSize({
142
- width: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetWidth) || 0,
143
- height: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetHeight) || 0
144
- });
141
+ var width = (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetWidth) || 0;
142
+ var height = (currentTab === null || currentTab === void 0 ? void 0 : currentTab.offsetHeight) || 0;
143
+ // 微前端场景下,可能出现获取不到元素的尺寸信息
144
+ if (width === 0 || height === 0) {
145
+ var timerCount = 0;
146
+ var timer = setInterval(function () {
147
+ timerCount++;
148
+ if (currentTab !== null && currentTab !== void 0 && currentTab.offsetWidth && currentTab !== null && currentTab !== void 0 && currentTab.offsetHeight) {
149
+ setCurrentTabSize({
150
+ width: currentTab.offsetWidth,
151
+ height: currentTab.offsetHeight
152
+ });
153
+ clearInterval(timer);
154
+ }
155
+ if (timerCount >= 100) {
156
+ clearInterval(timer);
157
+ }
158
+ }, 16);
159
+ return function () {
160
+ return clearInterval(timer);
161
+ };
162
+ } else {
163
+ setCurrentTabSize({
164
+ width: width,
165
+ height: height
166
+ });
167
+ }
145
168
  }, [active, tabs]);
146
169
  var renderHeaderScrollBar = function renderHeaderScrollBar() {
147
170
  if (shape !== 'line' && shape !== 'dash') return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.8.0-beta.34",
3
+ "version": "3.8.0-beta.36",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "module": "./esm/index.js",
11
11
  "typings": "./cjs/index.d.ts",
12
12
  "dependencies": {
13
- "@sheinx/hooks": "3.8.0-beta.34",
13
+ "@sheinx/hooks": "3.8.0-beta.36",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.1.3-alpha.0"