@sheinx/hooks 3.7.6-beta.3 → 3.8.0-beta.10

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":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA8S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA8S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -30,6 +30,19 @@ var hideStyle = {
30
30
  position: 'fixed',
31
31
  visibility: 'hidden'
32
32
  };
33
+ function setTransform(style, transform, addon) {
34
+ if (addon) {
35
+ style.transform += ' ' + transform;
36
+ } else {
37
+ style.transform = transform;
38
+ }
39
+ // 提供给动画侧合并使用
40
+ if (addon) {
41
+ style['--soui-popup-transform'] += ' ' + transform;
42
+ } else {
43
+ style['--soui-popup-transform'] = transform;
44
+ }
45
+ }
33
46
  var usePositionStyle = exports.usePositionStyle = function usePositionStyle(config) {
34
47
  var _ref = config || {},
35
48
  absolute = _ref.absolute,
@@ -187,7 +200,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
187
200
  var overLeft = 0;
188
201
  if (h === 'left') {
189
202
  style.left = rect.left - containerRect.left + containerScroll.left - (offset ? offset[0] : 0);
190
- style.transform = '';
203
+ setTransform(style, '');
191
204
  if (adjust) {
192
205
  overRight = rect.left + context.popUpWidth - bodyRect.right + containerScrollBarWidth;
193
206
  if (style.left < 0 && targetRect) {
@@ -197,11 +210,11 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
197
210
  } else if (h === 'right') {
198
211
  style.right = containerRect.right - rect.right + containerScrollBarWidth - containerScroll.left - (offset ? offset[0] : 0);
199
212
  style.left = 'auto';
200
- style.transform = '';
213
+ setTransform(style, '');
201
214
  } else {
202
215
  // 居中对齐
203
216
  style.left = rect.left + rect.width / 2 - containerRect.left + containerScroll.left;
204
- style.transform = 'translateX(-50%)';
217
+ setTransform(style, 'translateX(-50%)');
205
218
  if (adjust) {
206
219
  overRight = rect.left + rect.width / 2 + context.popUpWidth / 2 - bodyRect.width + containerScrollBarWidth;
207
220
  overLeft = bodyRect.left - (rect.left + rect.width / 2 - context.popUpWidth / 2);
@@ -223,7 +236,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
223
236
  style.top = rect.bottom - containerRect.top + containerScroll.top + popupGap;
224
237
  } else {
225
238
  style.top = rect.top - containerRect.top + containerScroll.top - popupGap;
226
- style.transform += 'translateY(-100%)';
239
+ setTransform(style, 'translateY(-100%)', true);
227
240
  }
228
241
  } else if (horizontalPosition.includes(targetPosition)) {
229
242
  var _targetPosition$split3 = targetPosition.split('-'),
@@ -232,19 +245,19 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
232
245
  _v = _targetPosition$split4[1];
233
246
  if (_v === 'top') {
234
247
  style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
235
- style.transform = '';
248
+ setTransform(style, '');
236
249
  } else if (_v === 'bottom') {
237
250
  style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
238
- style.transform = 'translateY(-100%)';
251
+ setTransform(style, 'translateY(-100%)');
239
252
  } else {
240
253
  // 居中对齐
241
254
  style.top = rect.top - containerRect.top + containerScroll.top + rect.height / 2;
242
- style.transform = 'translateY(-50%)';
255
+ setTransform(style, 'translateY(-50%)');
243
256
  }
244
257
  if (_h === 'right') {
245
258
  style.left = rect.right - containerRect.left + containerScroll.left + popupGap;
246
259
  } else {
247
- style.right = containerRect.right - rect.left;
260
+ style.right = containerRect.right - rect.left + popupGap;
248
261
  }
249
262
  } else if (position === 'cover') {
250
263
  style.top = rect.top - containerRect.top + containerScroll.top;
@@ -1,3 +1,4 @@
1
+ export * from './transfer-context';
1
2
  export { default, default as useTransfer } from './use-transfer';
2
3
  export type { BaseTransferProps, TransferListType } from './use-transfer.type';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -4,6 +4,9 @@
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ var _exportNames = {
8
+ useTransfer: true
9
+ };
7
10
  Object.defineProperty(exports, "default", {
8
11
  enumerable: true,
9
12
  get: function get() {
@@ -16,5 +19,17 @@ Object.defineProperty(exports, "useTransfer", {
16
19
  return _useTransfer.default;
17
20
  }
18
21
  });
22
+ var _transferContext = require("./transfer-context");
23
+ Object.keys(_transferContext).forEach(function (key) {
24
+ if (key === "default" || key === "__esModule") return;
25
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
+ if (key in exports && exports[key] === _transferContext[key]) return;
27
+ Object.defineProperty(exports, key, {
28
+ enumerable: true,
29
+ get: function get() {
30
+ return _transferContext[key];
31
+ }
32
+ });
33
+ });
19
34
  var _useTransfer = _interopRequireDefault(require("./use-transfer"));
20
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const TransferContext: import("react").Context<{
3
+ filterSourceText?: string | undefined;
4
+ filterTargetText?: string | undefined;
5
+ highlight?: boolean | undefined;
6
+ }>;
7
+ //# sourceMappingURL=transfer-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer-context.d.ts","sourceRoot":"","sources":["transfer-context.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,eAAe;;;;EAQ1B,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TransferContext = void 0;
7
+ var _react = require("react");
8
+ var TransferContext = exports.TransferContext = /*#__PURE__*/(0, _react.createContext)({
9
+ filterSourceText: '',
10
+ filterTargetText: '',
11
+ highlight: false
12
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["highlight.tsx"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,EAClC,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,MAAM,GACP,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GAAG,CAAC,CAkCJ"}
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["highlight.tsx"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,EAClC,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,MAAM,GACP,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GAAG,CAAC,CA8BJ"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -10,12 +11,6 @@ var _is = require("./is");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
11
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
- 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; }
17
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
- 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); }
19
14
  function getHighlightText(_ref) {
20
15
  var nodeList = _ref.nodeList,
21
16
  searchWords = _ref.searchWords,
@@ -24,31 +19,22 @@ function getHighlightText(_ref) {
24
19
  if (!enable || !searchWords) {
25
20
  return nodeList;
26
21
  }
27
-
28
- // 递归转换节点
29
- var transformNode = function transformNode(node, index) {
30
- // 如果是合法的 React 元素
31
- if ( /*#__PURE__*/_react.default.isValidElement(node) && node.props && node.props.children) {
32
- // 对 children 递归调用 getHighlightText 进行转换
33
- var transformedChildren = getHighlightText({
34
- nodeList: node.props.children,
22
+ var transformNode = function transformNode(node) {
23
+ var _node$props;
24
+ if (node && typeof ((_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.children) === 'string') {
25
+ return /*#__PURE__*/(0, _react.cloneElement)(node, undefined, /*#__PURE__*/(0, _jsxRuntime.jsx)(HighlightText, {
26
+ textToHighlight: node.props.children,
35
27
  searchWords: searchWords,
36
- highlightClassName: highlightClassName,
37
- enable: enable
38
- });
39
- return /*#__PURE__*/(0, _react.cloneElement)(node, _objectSpread(_objectSpread({}, node.props), {}, {
40
- key: index
41
- }), transformedChildren);
28
+ highlightClassName: highlightClassName
29
+ }));
42
30
  }
43
- // 如果节点为字符串,则直接高亮替换
44
- if (typeof node === 'string') {
31
+ if (node && typeof node === 'string') {
45
32
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(HighlightText, {
46
33
  textToHighlight: node,
47
34
  searchWords: searchWords,
48
35
  highlightClassName: highlightClassName
49
36
  });
50
37
  }
51
- // 其他情况直接返回原节点
52
38
  return node;
53
39
  };
54
40
  return (0, _is.isArray)(nodeList) ? nodeList.map(transformNode) : transformNode(nodeList);
@@ -64,7 +50,8 @@ function HighlightText(_ref2) {
64
50
  searchWords = searchWords.slice(0, 500);
65
51
  }
66
52
 
67
- // capture group 的正则用于 split 保留匹配文本
53
+ // 注意这里的括号,这里使用了带capture group功能的正则,来split字符串
54
+ // 从而在strArr中可以保留匹配文本
68
55
  var re = new RegExp("(".concat((0, _string.escapeRegExp)(searchWords), ")"), 'i');
69
56
  var strArr = textToHighlight.split(re);
70
57
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA8S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA8S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -21,6 +21,19 @@ var hideStyle = {
21
21
  position: 'fixed',
22
22
  visibility: 'hidden'
23
23
  };
24
+ function setTransform(style, transform, addon) {
25
+ if (addon) {
26
+ style.transform += ' ' + transform;
27
+ } else {
28
+ style.transform = transform;
29
+ }
30
+ // 提供给动画侧合并使用
31
+ if (addon) {
32
+ style['--soui-popup-transform'] += ' ' + transform;
33
+ } else {
34
+ style['--soui-popup-transform'] = transform;
35
+ }
36
+ }
24
37
  export var usePositionStyle = function usePositionStyle(config) {
25
38
  var _ref = config || {},
26
39
  absolute = _ref.absolute,
@@ -178,7 +191,7 @@ export var usePositionStyle = function usePositionStyle(config) {
178
191
  var overLeft = 0;
179
192
  if (h === 'left') {
180
193
  style.left = rect.left - containerRect.left + containerScroll.left - (offset ? offset[0] : 0);
181
- style.transform = '';
194
+ setTransform(style, '');
182
195
  if (adjust) {
183
196
  overRight = rect.left + context.popUpWidth - bodyRect.right + containerScrollBarWidth;
184
197
  if (style.left < 0 && targetRect) {
@@ -188,11 +201,11 @@ export var usePositionStyle = function usePositionStyle(config) {
188
201
  } else if (h === 'right') {
189
202
  style.right = containerRect.right - rect.right + containerScrollBarWidth - containerScroll.left - (offset ? offset[0] : 0);
190
203
  style.left = 'auto';
191
- style.transform = '';
204
+ setTransform(style, '');
192
205
  } else {
193
206
  // 居中对齐
194
207
  style.left = rect.left + rect.width / 2 - containerRect.left + containerScroll.left;
195
- style.transform = 'translateX(-50%)';
208
+ setTransform(style, 'translateX(-50%)');
196
209
  if (adjust) {
197
210
  overRight = rect.left + rect.width / 2 + context.popUpWidth / 2 - bodyRect.width + containerScrollBarWidth;
198
211
  overLeft = bodyRect.left - (rect.left + rect.width / 2 - context.popUpWidth / 2);
@@ -214,7 +227,7 @@ export var usePositionStyle = function usePositionStyle(config) {
214
227
  style.top = rect.bottom - containerRect.top + containerScroll.top + popupGap;
215
228
  } else {
216
229
  style.top = rect.top - containerRect.top + containerScroll.top - popupGap;
217
- style.transform += 'translateY(-100%)';
230
+ setTransform(style, 'translateY(-100%)', true);
218
231
  }
219
232
  } else if (horizontalPosition.includes(targetPosition)) {
220
233
  var _targetPosition$split3 = targetPosition.split('-'),
@@ -223,19 +236,19 @@ export var usePositionStyle = function usePositionStyle(config) {
223
236
  _v = _targetPosition$split4[1];
224
237
  if (_v === 'top') {
225
238
  style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
226
- style.transform = '';
239
+ setTransform(style, '');
227
240
  } else if (_v === 'bottom') {
228
241
  style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
229
- style.transform = 'translateY(-100%)';
242
+ setTransform(style, 'translateY(-100%)');
230
243
  } else {
231
244
  // 居中对齐
232
245
  style.top = rect.top - containerRect.top + containerScroll.top + rect.height / 2;
233
- style.transform = 'translateY(-50%)';
246
+ setTransform(style, 'translateY(-50%)');
234
247
  }
235
248
  if (_h === 'right') {
236
249
  style.left = rect.right - containerRect.left + containerScroll.left + popupGap;
237
250
  } else {
238
- style.right = containerRect.right - rect.left;
251
+ style.right = containerRect.right - rect.left + popupGap;
239
252
  }
240
253
  } else if (position === 'cover') {
241
254
  style.top = rect.top - containerRect.top + containerScroll.top;
@@ -1,3 +1,4 @@
1
+ export * from './transfer-context';
1
2
  export { default, default as useTransfer } from './use-transfer';
2
3
  export type { BaseTransferProps, TransferListType } from './use-transfer.type';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  "use client";
2
+ export * from "./transfer-context";
2
3
  export { default, default as useTransfer } from "./use-transfer";
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const TransferContext: import("react").Context<{
3
+ filterSourceText?: string | undefined;
4
+ filterTargetText?: string | undefined;
5
+ highlight?: boolean | undefined;
6
+ }>;
7
+ //# sourceMappingURL=transfer-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer-context.d.ts","sourceRoot":"","sources":["transfer-context.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,eAAe;;;;EAQ1B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { createContext } from 'react';
2
+ export var TransferContext = /*#__PURE__*/createContext({
3
+ filterSourceText: '',
4
+ filterTargetText: '',
5
+ highlight: false
6
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["highlight.tsx"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,EAClC,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,MAAM,GACP,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GAAG,CAAC,CAkCJ"}
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["highlight.tsx"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,EAClC,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,MAAM,GACP,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GAAG,CAAC,CA8BJ"}
@@ -1,9 +1,3 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- 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; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- 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); }
7
1
  import React, { cloneElement } from 'react';
8
2
  import { escapeRegExp } from "./string";
9
3
  import { isArray } from "./is";
@@ -17,31 +11,22 @@ export function getHighlightText(_ref) {
17
11
  if (!enable || !searchWords) {
18
12
  return nodeList;
19
13
  }
20
-
21
- // 递归转换节点
22
- var transformNode = function transformNode(node, index) {
23
- // 如果是合法的 React 元素
24
- if ( /*#__PURE__*/React.isValidElement(node) && node.props && node.props.children) {
25
- // 对 children 递归调用 getHighlightText 进行转换
26
- var transformedChildren = getHighlightText({
27
- nodeList: node.props.children,
14
+ var transformNode = function transformNode(node) {
15
+ var _node$props;
16
+ if (node && typeof ((_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.children) === 'string') {
17
+ return /*#__PURE__*/cloneElement(node, undefined, /*#__PURE__*/_jsx(HighlightText, {
18
+ textToHighlight: node.props.children,
28
19
  searchWords: searchWords,
29
- highlightClassName: highlightClassName,
30
- enable: enable
31
- });
32
- return /*#__PURE__*/cloneElement(node, _objectSpread(_objectSpread({}, node.props), {}, {
33
- key: index
34
- }), transformedChildren);
20
+ highlightClassName: highlightClassName
21
+ }));
35
22
  }
36
- // 如果节点为字符串,则直接高亮替换
37
- if (typeof node === 'string') {
23
+ if (node && typeof node === 'string') {
38
24
  return /*#__PURE__*/_jsx(HighlightText, {
39
25
  textToHighlight: node,
40
26
  searchWords: searchWords,
41
27
  highlightClassName: highlightClassName
42
28
  });
43
29
  }
44
- // 其他情况直接返回原节点
45
30
  return node;
46
31
  };
47
32
  return isArray(nodeList) ? nodeList.map(transformNode) : transformNode(nodeList);
@@ -57,7 +42,8 @@ function HighlightText(_ref2) {
57
42
  searchWords = searchWords.slice(0, 500);
58
43
  }
59
44
 
60
- // capture group 的正则用于 split 保留匹配文本
45
+ // 注意这里的括号,这里使用了带capture group功能的正则,来split字符串
46
+ // 从而在strArr中可以保留匹配文本
61
47
  var re = new RegExp("(".concat(escapeRegExp(searchWords), ")"), 'i');
62
48
  var strArr = textToHighlight.split(re);
63
49
  return /*#__PURE__*/_jsx(_Fragment, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.7.6-beta.3",
3
+ "version": "3.8.0-beta.10",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",