@sheinx/base 3.4.2-beta.3 → 3.4.2-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.
@@ -1 +1 @@
1
- {"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;;AAgHtC,wBAAqC"}
1
+ {"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;;AA+HtC,wBAAqC"}
package/cjs/tabs/tab.js CHANGED
@@ -17,7 +17,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
17
17
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
19
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
- var Tab = function Tab(props, ref) {
20
+ var placeholderRefStyle = {
21
+ position: 'absolute',
22
+ inset: 0,
23
+ pointerEvents: 'none',
24
+ visibility: 'hidden'
25
+ };
26
+ var Tab = function Tab(props, _ref) {
21
27
  var _jssStyle$tabs;
22
28
  var jssStyle = props.jssStyle,
23
29
  propTab = props.tab,
@@ -87,7 +93,7 @@ var Tab = function Tab(props, ref) {
87
93
  }, getStateProps()), {}, {
88
94
  style: style,
89
95
  onClick: handleClick,
90
- ref: ref,
96
+ ref: _ref,
91
97
  dir: config.direction
92
98
  });
93
99
  if (shape === 'button') {
@@ -105,8 +111,19 @@ var Tab = function Tab(props, ref) {
105
111
  children: [shape === 'card' && renderCardTab(), shape === 'line' && renderLineTab(), shape === 'dash' && renderDashTab(), shape === 'fill' && renderFillTab()]
106
112
  });
107
113
  if (_hooks.util.isLink(propTab)) {
108
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", _objectSpread(_objectSpread({}, containerProps), {}, {
109
- children: $children
114
+ // 修正ref能够稳定的指向正确的dom节点
115
+ return /*#__PURE__*/_react.default.cloneElement(propTab, _objectSpread(_objectSpread({}, containerProps), {}, {
116
+ style: _objectSpread(_objectSpread({}, style), {}, {
117
+ position: 'relative'
118
+ }),
119
+ ref: null
120
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
121
+ children: [$children, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
122
+ ref: function ref(node) {
123
+ return _ref(node === null || node === void 0 ? void 0 : node.parentNode);
124
+ },
125
+ style: placeholderRefStyle
126
+ })]
110
127
  }));
111
128
  }
112
129
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, containerProps), {}, {
@@ -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,gBAqQzC,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,gBAsQzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -131,10 +131,12 @@ var TabsHeader = function TabsHeader(props) {
131
131
  setTransform(delta + headerRef.current.clientWidth * single);
132
132
  };
133
133
  var renderHeaderScrollBar = function renderHeaderScrollBar() {
134
+ var _currentTab$getBoundi;
134
135
  if (shape !== 'line' && shape !== 'dash') return;
135
136
  var currentTab = tabRef.current[active];
136
137
  if (!currentTab) return;
137
- var currentTabRect = currentTab.getBoundingClientRect();
138
+ var currentTabRect = currentTab === null || currentTab === void 0 || (_currentTab$getBoundi = currentTab.getBoundingClientRect) === null || _currentTab$getBoundi === void 0 ? void 0 : _currentTab$getBoundi.call(currentTab);
139
+ if (!currentTabRect) return;
138
140
  var scrollBarStyle = isVertical ? {
139
141
  right: getPosition !== null && getPosition !== void 0 && getPosition.startsWith('left') ? 0 : 'auto',
140
142
  left: getPosition !== null && getPosition !== void 0 && getPosition.startsWith('right') ? 0 : 'auto',
@@ -1 +1 @@
1
- {"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;;AAgHtC,wBAAqC"}
1
+ {"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;;AA+HtC,wBAAqC"}
package/esm/tabs/tab.js CHANGED
@@ -12,7 +12,13 @@ import { useTabsContext, util } from '@sheinx/hooks';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- var Tab = function Tab(props, ref) {
15
+ var placeholderRefStyle = {
16
+ position: 'absolute',
17
+ inset: 0,
18
+ pointerEvents: 'none',
19
+ visibility: 'hidden'
20
+ };
21
+ var Tab = function Tab(props, _ref) {
16
22
  var _jssStyle$tabs;
17
23
  var jssStyle = props.jssStyle,
18
24
  propTab = props.tab,
@@ -82,7 +88,7 @@ var Tab = function Tab(props, ref) {
82
88
  }, getStateProps()), {}, {
83
89
  style: style,
84
90
  onClick: handleClick,
85
- ref: ref,
91
+ ref: _ref,
86
92
  dir: config.direction
87
93
  });
88
94
  if (shape === 'button') {
@@ -100,8 +106,19 @@ var Tab = function Tab(props, ref) {
100
106
  children: [shape === 'card' && renderCardTab(), shape === 'line' && renderLineTab(), shape === 'dash' && renderDashTab(), shape === 'fill' && renderFillTab()]
101
107
  });
102
108
  if (util.isLink(propTab)) {
103
- return /*#__PURE__*/_jsx("a", _objectSpread(_objectSpread({}, containerProps), {}, {
104
- children: $children
109
+ // 修正ref能够稳定的指向正确的dom节点
110
+ return /*#__PURE__*/React.cloneElement(propTab, _objectSpread(_objectSpread({}, containerProps), {}, {
111
+ style: _objectSpread(_objectSpread({}, style), {}, {
112
+ position: 'relative'
113
+ }),
114
+ ref: null
115
+ }), /*#__PURE__*/_jsxs(_Fragment, {
116
+ children: [$children, /*#__PURE__*/_jsx("div", {
117
+ ref: function ref(node) {
118
+ return _ref(node === null || node === void 0 ? void 0 : node.parentNode);
119
+ },
120
+ style: placeholderRefStyle
121
+ })]
105
122
  }));
106
123
  }
107
124
  return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, containerProps), {}, {
@@ -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,gBAqQzC,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,gBAsQzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -125,10 +125,12 @@ var TabsHeader = function TabsHeader(props) {
125
125
  setTransform(delta + headerRef.current.clientWidth * single);
126
126
  };
127
127
  var renderHeaderScrollBar = function renderHeaderScrollBar() {
128
+ var _currentTab$getBoundi;
128
129
  if (shape !== 'line' && shape !== 'dash') return;
129
130
  var currentTab = tabRef.current[active];
130
131
  if (!currentTab) return;
131
- var currentTabRect = currentTab.getBoundingClientRect();
132
+ var currentTabRect = currentTab === null || currentTab === void 0 || (_currentTab$getBoundi = currentTab.getBoundingClientRect) === null || _currentTab$getBoundi === void 0 ? void 0 : _currentTab$getBoundi.call(currentTab);
133
+ if (!currentTabRect) return;
132
134
  var scrollBarStyle = isVertical ? {
133
135
  right: getPosition !== null && getPosition !== void 0 && getPosition.startsWith('left') ? 0 : 'auto',
134
136
  left: getPosition !== null && getPosition !== void 0 && getPosition.startsWith('right') ? 0 : 'auto',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.4.2-beta.3",
3
+ "version": "3.4.2-beta.4",
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.4.2-beta.3",
13
+ "@sheinx/hooks": "3.4.2-beta.4",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.1.3-alpha.0"