shineout 3.7.6-beta.1 → 3.7.6-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.
package/cjs/index.js CHANGED
@@ -522,5 +522,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
522
522
  // 此文件由脚本自动生成,请勿直接修改。
523
523
  // This file was generated automatically by a script. Please do not modify it directly.
524
524
  var _default = exports.default = {
525
- version: '3.7.6-beta.1'
525
+ version: '3.7.6-beta.2'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12234,7 +12234,7 @@ var handleStyle = function handleStyle(style) {
12234
12234
  };
12235
12235
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12236
12236
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12237
- /* harmony default export */ var version = ('3.7.6-beta.1');
12237
+ /* harmony default export */ var version = ('3.7.6-beta.2');
12238
12238
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12239
12239
 
12240
12240
 
@@ -39992,6 +39992,7 @@ var VirtualList = function VirtualList(props) {
39992
39992
 
39993
39993
 
39994
39994
 
39995
+
39995
39996
  function getHighlightText(_ref) {
39996
39997
  var nodeList = _ref.nodeList,
39997
39998
  searchWords = _ref.searchWords,
@@ -40000,22 +40001,31 @@ function getHighlightText(_ref) {
40000
40001
  if (!enable || !searchWords) {
40001
40002
  return nodeList;
40002
40003
  }
40003
- var transformNode = function transformNode(node) {
40004
- var _node$props;
40005
- if (node && typeof ((_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.children) === 'string') {
40006
- return /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.cloneElement)(node, undefined, /*#__PURE__*/(0,jsx_runtime.jsx)(HighlightText, {
40007
- textToHighlight: node.props.children,
40004
+
40005
+ // 递归转换节点
40006
+ var transformNode = function transformNode(node, index) {
40007
+ // 如果是合法的 React 元素
40008
+ if ( /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().isValidElement(node) && node.props && node.props.children) {
40009
+ // 对 children 递归调用 getHighlightText 进行转换
40010
+ var transformedChildren = getHighlightText({
40011
+ nodeList: node.props.children,
40008
40012
  searchWords: searchWords,
40009
- highlightClassName: highlightClassName
40010
- }));
40013
+ highlightClassName: highlightClassName,
40014
+ enable: enable
40015
+ });
40016
+ return /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.cloneElement)(node, objectSpread2_default()(objectSpread2_default()({}, node.props), {}, {
40017
+ key: index
40018
+ }), transformedChildren);
40011
40019
  }
40012
- if (node && typeof node === 'string') {
40020
+ // 如果节点为字符串,则直接高亮替换
40021
+ if (typeof node === 'string') {
40013
40022
  return /*#__PURE__*/(0,jsx_runtime.jsx)(HighlightText, {
40014
40023
  textToHighlight: node,
40015
40024
  searchWords: searchWords,
40016
40025
  highlightClassName: highlightClassName
40017
40026
  });
40018
40027
  }
40028
+ // 其他情况直接返回原节点
40019
40029
  return node;
40020
40030
  };
40021
40031
  return isArray(nodeList) ? nodeList.map(transformNode) : transformNode(nodeList);
@@ -40031,8 +40041,7 @@ function HighlightText(_ref2) {
40031
40041
  searchWords = searchWords.slice(0, 500);
40032
40042
  }
40033
40043
 
40034
- // 注意这里的括号,这里使用了带capture group功能的正则,来split字符串
40035
- // 从而在strArr中可以保留匹配文本
40044
+ // capture group 的正则用于 split 保留匹配文本
40036
40045
  var re = new RegExp("(".concat(escapeRegExp(searchWords), ")"), 'i');
40037
40046
  var strArr = textToHighlight.split(re);
40038
40047
  return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
@@ -71660,7 +71669,7 @@ var upload_interface = __webpack_require__(8821);
71660
71669
 
71661
71670
 
71662
71671
  /* harmony default export */ var src_0 = ({
71663
- version: '3.7.6-beta.1'
71672
+ version: '3.7.6-beta.2'
71664
71673
  });
71665
71674
  }();
71666
71675
  /******/ return __webpack_exports__;