@sheinx/base 3.8.4 → 3.8.5-beta.2

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":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA8C9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDA0YtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2D9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDAyYtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -29,7 +29,8 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
29
29
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
30
  var hasMask = false;
31
31
  var config = {
32
- instanceIds: []
32
+ instanceIds: [],
33
+ originDocumentStyle: null
33
34
  };
34
35
  var state = (0, _reactive.create)(config);
35
36
  var useModalConfig = function useModalConfig() {
@@ -46,6 +47,12 @@ var removeModalInstance = function removeModalInstance(instanceId) {
46
47
  var getInstanceIds = function getInstanceIds() {
47
48
  return state.mutate.instanceIds;
48
49
  };
50
+ var setOriginDocumentStyle = function setOriginDocumentStyle(style) {
51
+ state.mutate.originDocumentStyle = style;
52
+ };
53
+ var getOriginDocumentStyle = function getOriginDocumentStyle() {
54
+ return state.mutate.originDocumentStyle;
55
+ };
49
56
  var mousePosition = null;
50
57
  var getClickPosition = function getClickPosition(e) {
51
58
  mousePosition = {
@@ -88,7 +95,6 @@ var Modal = function Modal(props) {
88
95
  mouseDownTarget: null,
89
96
  mouseUpTarget: null,
90
97
  content: null,
91
- originDocumentStyle: null,
92
98
  instanceId: _hooks.util.generateUUID()
93
99
  }),
94
100
  context = _useRef.current;
@@ -203,15 +209,16 @@ var Modal = function Modal(props) {
203
209
  setAnimation(true);
204
210
  }
205
211
  }, [props.visible]);
212
+ var originDocumentStyle = getOriginDocumentStyle();
206
213
 
207
214
  // 设置 document.body.style.overflow 和 document.body.style.paddingRight,并记录原始值到 context 中
208
215
  var setDocumentOverflow = (0, _hooks.usePersistFn)(function () {
209
216
  var doc = document.body.parentNode;
210
- if (context.isMask && !context.originDocumentStyle) {
211
- context.originDocumentStyle = {
217
+ if (context.isMask && !originDocumentStyle) {
218
+ setOriginDocumentStyle({
212
219
  overflow: doc.style.overflow,
213
220
  paddingRight: doc.style.paddingRight
214
- };
221
+ });
215
222
  }
216
223
  doc.style.overflow = 'hidden';
217
224
  if (!doc.style.paddingRight) {
@@ -222,9 +229,10 @@ var Modal = function Modal(props) {
222
229
  // 还原 document.body.style.overflow 和 document.body.style.paddingRight
223
230
  var resetDocumentOverflow = (0, _hooks.usePersistFn)(function () {
224
231
  var doc = document.body.parentNode;
225
- if (context.originDocumentStyle) {
226
- doc.style.overflow = context.originDocumentStyle.overflow;
227
- doc.style.paddingRight = context.originDocumentStyle.paddingRight;
232
+ // originDocumentStyle放到全局管理后,多个modal连续打开关闭场景下,可以正确还原
233
+ if (originDocumentStyle) {
234
+ doc.style.overflow = originDocumentStyle.overflow;
235
+ doc.style.paddingRight = originDocumentStyle.paddingRight;
228
236
  }
229
237
  });
230
238
  (0, _react.useEffect)(function () {
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["tooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,QAAA,MAAM,OAAO,UAAW,YAAY,mDA8JnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["tooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,QAAA,MAAM,OAAO,UAAW,YAAY,mDA+JnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -48,6 +48,13 @@ var Tooltip = function Tooltip(props) {
48
48
  popsitionProps = _props$position === void 0 ? 'auto' : _props$position,
49
49
  _props$popupGap = props.popupGap,
50
50
  popupGap = _props$popupGap === void 0 ? 0 : _props$popupGap;
51
+
52
+ // Early validation checks BEFORE any hooks
53
+ if (! /*#__PURE__*/(0, _react.isValidElement)(children)) {
54
+ devUseWarning.error('Tooltip children expect a single ReactElement.');
55
+ return null;
56
+ }
57
+ if (!tip) return children;
51
58
  var tooltipClasses = jssStyle === null || jssStyle === void 0 || (_jssStyle$tooltip = jssStyle.tooltip) === null || _jssStyle$tooltip === void 0 ? void 0 : _jssStyle$tooltip.call(jssStyle);
52
59
  var config = (0, _config.useConfig)();
53
60
  var persistent = persistentProp !== null && persistentProp !== void 0 ? persistentProp : (_config$tooltip = config.tooltip) === null || _config$tooltip === void 0 ? void 0 : _config$tooltip.persistent;
@@ -106,22 +113,6 @@ var Tooltip = function Tooltip(props) {
106
113
  unbindEvents();
107
114
  };
108
115
  }, [persistent]);
109
- if (! /*#__PURE__*/(0, _react.isValidElement)(children)) {
110
- devUseWarning.error('Tooltip children expect a single ReactElement.');
111
- return null;
112
- }
113
- if (!tip) return children;
114
- var inner = disabledChild ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
115
- className: tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.target,
116
- style: {
117
- cursor: 'not-allowed'
118
- },
119
- children: /*#__PURE__*/(0, _react.cloneElement)(children, {
120
- style: _objectSpread(_objectSpread({}, childrenProps.style), {}, {
121
- pointerEvents: 'none'
122
- })
123
- })
124
- }) : children;
125
116
  var innerProps = (0, _react.useMemo)(function () {
126
117
  if (persistent) {
127
118
  return trigger === 'hover' ? _objectSpread(_objectSpread({}, events), {}, {
@@ -133,6 +124,17 @@ var Tooltip = function Tooltip(props) {
133
124
  }
134
125
  return events;
135
126
  }, [persistent, events, trigger]);
127
+ var inner = disabledChild ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
128
+ className: tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.target,
129
+ style: {
130
+ cursor: 'not-allowed'
131
+ },
132
+ children: /*#__PURE__*/(0, _react.cloneElement)(children, {
133
+ style: _objectSpread(_objectSpread({}, childrenProps.style), {}, {
134
+ pointerEvents: 'none'
135
+ })
136
+ })
137
+ }) : children;
136
138
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
137
139
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("noscript", {
138
140
  ref: function ref(el) {
@@ -1 +1 @@
1
- {"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA8C9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDA0YtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2D9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDAyYtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -23,7 +23,8 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
23
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
24
24
  var hasMask = false;
25
25
  var config = {
26
- instanceIds: []
26
+ instanceIds: [],
27
+ originDocumentStyle: null
27
28
  };
28
29
  var state = create(config);
29
30
  var useModalConfig = function useModalConfig() {
@@ -40,6 +41,12 @@ var removeModalInstance = function removeModalInstance(instanceId) {
40
41
  var getInstanceIds = function getInstanceIds() {
41
42
  return state.mutate.instanceIds;
42
43
  };
44
+ var setOriginDocumentStyle = function setOriginDocumentStyle(style) {
45
+ state.mutate.originDocumentStyle = style;
46
+ };
47
+ var getOriginDocumentStyle = function getOriginDocumentStyle() {
48
+ return state.mutate.originDocumentStyle;
49
+ };
43
50
  var mousePosition = null;
44
51
  var getClickPosition = function getClickPosition(e) {
45
52
  mousePosition = {
@@ -82,7 +89,6 @@ var Modal = function Modal(props) {
82
89
  mouseDownTarget: null,
83
90
  mouseUpTarget: null,
84
91
  content: null,
85
- originDocumentStyle: null,
86
92
  instanceId: util.generateUUID()
87
93
  }),
88
94
  context = _useRef.current;
@@ -197,15 +203,16 @@ var Modal = function Modal(props) {
197
203
  setAnimation(true);
198
204
  }
199
205
  }, [props.visible]);
206
+ var originDocumentStyle = getOriginDocumentStyle();
200
207
 
201
208
  // 设置 document.body.style.overflow 和 document.body.style.paddingRight,并记录原始值到 context 中
202
209
  var setDocumentOverflow = usePersistFn(function () {
203
210
  var doc = document.body.parentNode;
204
- if (context.isMask && !context.originDocumentStyle) {
205
- context.originDocumentStyle = {
211
+ if (context.isMask && !originDocumentStyle) {
212
+ setOriginDocumentStyle({
206
213
  overflow: doc.style.overflow,
207
214
  paddingRight: doc.style.paddingRight
208
- };
215
+ });
209
216
  }
210
217
  doc.style.overflow = 'hidden';
211
218
  if (!doc.style.paddingRight) {
@@ -216,9 +223,10 @@ var Modal = function Modal(props) {
216
223
  // 还原 document.body.style.overflow 和 document.body.style.paddingRight
217
224
  var resetDocumentOverflow = usePersistFn(function () {
218
225
  var doc = document.body.parentNode;
219
- if (context.originDocumentStyle) {
220
- doc.style.overflow = context.originDocumentStyle.overflow;
221
- doc.style.paddingRight = context.originDocumentStyle.paddingRight;
226
+ // originDocumentStyle放到全局管理后,多个modal连续打开关闭场景下,可以正确还原
227
+ if (originDocumentStyle) {
228
+ doc.style.overflow = originDocumentStyle.overflow;
229
+ doc.style.paddingRight = originDocumentStyle.paddingRight;
222
230
  }
223
231
  });
224
232
  useEffect(function () {
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["tooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,QAAA,MAAM,OAAO,UAAW,YAAY,mDA8JnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["tooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,QAAA,MAAM,OAAO,UAAW,YAAY,mDA+JnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -41,6 +41,13 @@ var Tooltip = function Tooltip(props) {
41
41
  popsitionProps = _props$position === void 0 ? 'auto' : _props$position,
42
42
  _props$popupGap = props.popupGap,
43
43
  popupGap = _props$popupGap === void 0 ? 0 : _props$popupGap;
44
+
45
+ // Early validation checks BEFORE any hooks
46
+ if (! /*#__PURE__*/isValidElement(children)) {
47
+ devUseWarning.error('Tooltip children expect a single ReactElement.');
48
+ return null;
49
+ }
50
+ if (!tip) return children;
44
51
  var tooltipClasses = jssStyle === null || jssStyle === void 0 || (_jssStyle$tooltip = jssStyle.tooltip) === null || _jssStyle$tooltip === void 0 ? void 0 : _jssStyle$tooltip.call(jssStyle);
45
52
  var config = useConfig();
46
53
  var persistent = persistentProp !== null && persistentProp !== void 0 ? persistentProp : (_config$tooltip = config.tooltip) === null || _config$tooltip === void 0 ? void 0 : _config$tooltip.persistent;
@@ -99,22 +106,6 @@ var Tooltip = function Tooltip(props) {
99
106
  unbindEvents();
100
107
  };
101
108
  }, [persistent]);
102
- if (! /*#__PURE__*/isValidElement(children)) {
103
- devUseWarning.error('Tooltip children expect a single ReactElement.');
104
- return null;
105
- }
106
- if (!tip) return children;
107
- var inner = disabledChild ? /*#__PURE__*/_jsx("span", {
108
- className: tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.target,
109
- style: {
110
- cursor: 'not-allowed'
111
- },
112
- children: /*#__PURE__*/cloneElement(children, {
113
- style: _objectSpread(_objectSpread({}, childrenProps.style), {}, {
114
- pointerEvents: 'none'
115
- })
116
- })
117
- }) : children;
118
109
  var innerProps = useMemo(function () {
119
110
  if (persistent) {
120
111
  return trigger === 'hover' ? _objectSpread(_objectSpread({}, events), {}, {
@@ -126,6 +117,17 @@ var Tooltip = function Tooltip(props) {
126
117
  }
127
118
  return events;
128
119
  }, [persistent, events, trigger]);
120
+ var inner = disabledChild ? /*#__PURE__*/_jsx("span", {
121
+ className: tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.target,
122
+ style: {
123
+ cursor: 'not-allowed'
124
+ },
125
+ children: /*#__PURE__*/cloneElement(children, {
126
+ style: _objectSpread(_objectSpread({}, childrenProps.style), {}, {
127
+ pointerEvents: 'none'
128
+ })
129
+ })
130
+ }) : children;
129
131
  return /*#__PURE__*/_jsxs(_Fragment, {
130
132
  children: [/*#__PURE__*/_jsx("noscript", {
131
133
  ref: function ref(el) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.8.4",
3
+ "version": "3.8.5-beta.2",
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.4",
13
+ "@sheinx/hooks": "3.8.5-beta.2",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.1.3-alpha.0"