@hi-ui/highlighter 4.1.1 → 5.0.0-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @hi-ui/highlighter
2
2
 
3
+ ## 5.0.0-alpha.0
4
+
5
+ ### Major Changes
6
+
7
+ - 1b05b44a4: feat: 组件的 package.json 中的 exports 统一加上 types 配置 (5.0)
8
+
9
+ ### Patch Changes
10
+
11
+ - 61d132802: build: 将 package.json 中 exports 配置中的 types 配置放在最上面 (5.0)
12
+ - Updated dependencies [1b05b44a4]
13
+ - Updated dependencies [77ed66eac]
14
+ - Updated dependencies [61d132802]
15
+ - Updated dependencies [6eac4b78b]
16
+ - @hi-ui/core@5.0.0-alpha.0
17
+ - @hi-ui/classname@5.0.0-alpha.0
18
+ - @hi-ui/env@5.0.0-alpha.0
19
+
20
+ ## 4.1.2
21
+
22
+ ### Patch Changes
23
+
24
+ - [#3179](https://github.com/XiaoMi/hiui/pull/3179) [`7bf0630`](https://github.com/XiaoMi/hiui/commit/7bf063053a73923af41c33370c31371325206276) Thanks [@fcppddl](https://github.com/fcppddl)! - fix(highlighter): 修复 CheckSelect 搜索模式下搜索(时报错(#3178)
25
+
3
26
  ## 4.1.1
4
27
 
5
28
  ### Patch Changes
@@ -24,6 +24,10 @@ function _interopDefaultCompat(e) {
24
24
  }
25
25
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
26
26
  var HIGHLIGHTER_PREFIX = classname.getPrefixCls('highlighter');
27
+ var addGlobalFlag = function addGlobalFlag(regex) {
28
+ var newFlags = regex.flags.includes('g') ? regex.flags : regex.flags + 'g';
29
+ return new RegExp(regex.source, newFlags);
30
+ };
27
31
  /**
28
32
  * 高亮文本内容
29
33
  */
@@ -43,7 +47,10 @@ var Highlighter = /*#__PURE__*/React.forwardRef(function (_a, ref) {
43
47
  if (typeof children !== 'string') return children;
44
48
  // 支持多个匹配高亮
45
49
  var parts = children.split(keyword);
46
- var matches = children.match(keyword);
50
+ var matches;
51
+ if (keyword instanceof RegExp) {
52
+ matches = children.match(addGlobalFlag(keyword));
53
+ }
47
54
  // 未匹配到
48
55
  if (parts.length < 2) return children;
49
56
  var lastPart = parts.pop();
@@ -12,7 +12,7 @@
12
12
  Object.defineProperty(exports, '__esModule', {
13
13
  value: true
14
14
  });
15
- var css_248z = ".hi-v4-highlighter--matched {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}";
15
+ var css_248z = ".hi-v5-highlighter--matched {color: var(--hi-v5-color-primary-500, var(--hi-v5-color-brandblue-500, #2660ff));}";
16
16
  var __styleInject__ = require('@hi-ui/style-inject')["default"];
17
17
  __styleInject__(css_248z);
18
18
  exports["default"] = css_248z;
@@ -12,6 +12,10 @@ import React, { forwardRef, useRef } from 'react';
12
12
  import { getPrefixCls, cx } from '@hi-ui/classname';
13
13
  import { __DEV__ } from '@hi-ui/env';
14
14
  var HIGHLIGHTER_PREFIX = getPrefixCls('highlighter');
15
+ var addGlobalFlag = function addGlobalFlag(regex) {
16
+ var newFlags = regex.flags.includes('g') ? regex.flags : regex.flags + 'g';
17
+ return new RegExp(regex.source, newFlags);
18
+ };
15
19
  /**
16
20
  * 高亮文本内容
17
21
  */
@@ -31,7 +35,10 @@ var Highlighter = /*#__PURE__*/forwardRef(function (_a, ref) {
31
35
  if (typeof children !== 'string') return children;
32
36
  // 支持多个匹配高亮
33
37
  var parts = children.split(keyword);
34
- var matches = children.match(keyword);
38
+ var matches;
39
+ if (keyword instanceof RegExp) {
40
+ matches = children.match(addGlobalFlag(keyword));
41
+ }
35
42
  // 未匹配到
36
43
  if (parts.length < 2) return children;
37
44
  var lastPart = parts.pop();
@@ -8,6 +8,6 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
  import __styleInject__ from '@hi-ui/style-inject';
11
- var css_248z = ".hi-v4-highlighter--matched {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}";
11
+ var css_248z = ".hi-v5-highlighter--matched {color: var(--hi-v5-color-primary-500, var(--hi-v5-color-brandblue-500, #2660ff));}";
12
12
  __styleInject__(css_248z);
13
13
  export { css_248z as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/highlighter",
3
- "version": "4.1.1",
3
+ "version": "5.0.0-alpha.0",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -19,6 +19,7 @@
19
19
  "typings": "lib/types/index.d.ts",
20
20
  "exports": {
21
21
  ".": {
22
+ "types": "./lib/types/index.d.ts",
22
23
  "require": "./lib/cjs/index.js",
23
24
  "default": "./lib/esm/index.js"
24
25
  }
@@ -43,17 +44,17 @@
43
44
  "url": "https://github.com/XiaoMi/hiui/issues"
44
45
  },
45
46
  "dependencies": {
46
- "@hi-ui/classname": "^4.0.5",
47
- "@hi-ui/env": "^4.0.5"
47
+ "@hi-ui/classname": "^5.0.0-alpha.0",
48
+ "@hi-ui/env": "^5.0.0-alpha.0"
48
49
  },
49
50
  "peerDependencies": {
50
- "@hi-ui/core": ">=4.0.8",
51
+ "@hi-ui/core": ">=5.0.0-alpha.0",
51
52
  "react": ">=16.8.6",
52
53
  "react-dom": ">=16.8.6"
53
54
  },
54
55
  "devDependencies": {
55
- "@hi-ui/core": "^4.0.8",
56
- "@hi-ui/core-css": "^4.1.5",
56
+ "@hi-ui/core": "^5.0.0-alpha.0",
57
+ "@hi-ui/core-css": "^5.0.0-alpha.0",
57
58
  "react": "^17.0.1",
58
59
  "react-dom": "^17.0.1"
59
60
  }