@sheinx/hooks 3.7.0-beta.8 → 3.7.0-fix.1

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.
Files changed (151) hide show
  1. package/cjs/common/use-component-memo/index.d.ts +1 -1
  2. package/cjs/common/use-component-memo/index.d.ts.map +1 -1
  3. package/cjs/common/use-component-memo/index.js +2 -9
  4. package/cjs/common/use-component-memo/use-memo.d.ts +1 -1
  5. package/cjs/common/use-component-memo/use-memo.d.ts.map +1 -1
  6. package/cjs/common/use-component-memo/use-memo.js +2 -2
  7. package/cjs/common/use-filter/index.d.ts +1 -0
  8. package/cjs/common/use-filter/index.d.ts.map +1 -1
  9. package/cjs/common/use-filter/index.js +7 -0
  10. package/cjs/common/use-filter/use-filter-context.d.ts +7 -0
  11. package/cjs/common/use-filter/use-filter-context.d.ts.map +1 -0
  12. package/cjs/common/use-filter/use-filter-context.js +10 -0
  13. package/cjs/common/use-filter/use-filter.d.ts +1 -0
  14. package/cjs/common/use-filter/use-filter.d.ts.map +1 -1
  15. package/cjs/common/use-filter/use-filter.js +2 -0
  16. package/cjs/common/use-input-able/use-Input-able.d.ts.map +1 -1
  17. package/cjs/common/use-input-able/use-Input-able.js +6 -7
  18. package/cjs/common/use-position-style/check-element-size.d.ts +10 -0
  19. package/cjs/common/use-position-style/check-element-size.d.ts.map +1 -0
  20. package/cjs/common/use-position-style/check-element-size.js +65 -0
  21. package/cjs/common/use-position-style/index.d.ts.map +1 -1
  22. package/cjs/common/use-position-style/index.js +5 -1
  23. package/cjs/components/use-datepicker/index.d.ts +1 -1
  24. package/cjs/components/use-datepicker/index.d.ts.map +1 -1
  25. package/cjs/components/use-datepicker/index.js +23 -2
  26. package/cjs/components/use-datepicker/use-datepicker-format.d.ts +17 -0
  27. package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  28. package/cjs/components/use-datepicker/use-datepicker-format.js +15 -3
  29. package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  30. package/cjs/components/use-form/use-form-control/use-form-control.js +9 -4
  31. package/cjs/components/use-form/use-form.d.ts +4 -4
  32. package/cjs/components/use-form/use-form.d.ts.map +1 -1
  33. package/cjs/components/use-form/use-form.js +31 -25
  34. package/cjs/components/use-form/use-form.type.d.ts +8 -0
  35. package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
  36. package/cjs/components/use-image/use-image.d.ts +2 -0
  37. package/cjs/components/use-image/use-image.d.ts.map +1 -1
  38. package/cjs/components/use-image/use-image.js +40 -2
  39. package/cjs/components/use-popup/popup-context.d.ts +2 -0
  40. package/cjs/components/use-popup/popup-context.d.ts.map +1 -1
  41. package/cjs/components/use-popup/popup-context.js +2 -0
  42. package/cjs/components/use-popup/use-popup.d.ts +4 -0
  43. package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
  44. package/cjs/components/use-popup/use-popup.js +33 -13
  45. package/cjs/components/use-table/index.d.ts +1 -1
  46. package/cjs/components/use-table/index.d.ts.map +1 -1
  47. package/cjs/components/use-table/use-table-filter.d.ts.map +1 -1
  48. package/cjs/components/use-table/use-table-filter.js +2 -1
  49. package/cjs/components/use-table/use-table-group.d.ts.map +1 -1
  50. package/cjs/components/use-table/use-table-group.js +3 -1
  51. package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
  52. package/cjs/components/use-table/use-table-layout.js +0 -1
  53. package/cjs/components/use-table/use-table-virtual.js +1 -1
  54. package/cjs/components/use-table/use-table.type.d.ts +13 -21
  55. package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
  56. package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
  57. package/cjs/components/use-tree/use-tree.js +25 -7
  58. package/cjs/components/use-tree/use-tree.type.d.ts +1 -0
  59. package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
  60. package/cjs/components/use-upload/use-upload.d.ts.map +1 -1
  61. package/cjs/components/use-upload/use-upload.js +54 -34
  62. package/cjs/components/use-upload/use-upload.type.d.ts +7 -0
  63. package/cjs/components/use-upload/use-upload.type.d.ts.map +1 -1
  64. package/cjs/utils/clean-props.d.ts +11 -0
  65. package/cjs/utils/clean-props.d.ts.map +1 -0
  66. package/cjs/utils/clean-props.js +21 -0
  67. package/cjs/utils/highlight.d.ts +7 -0
  68. package/cjs/utils/highlight.d.ts.map +1 -0
  69. package/cjs/utils/highlight.js +67 -0
  70. package/cjs/utils/index.d.ts +2 -0
  71. package/cjs/utils/index.d.ts.map +1 -1
  72. package/cjs/utils/index.js +24 -0
  73. package/cjs/utils/string.d.ts +1 -0
  74. package/cjs/utils/string.d.ts.map +1 -1
  75. package/cjs/utils/string.js +13 -0
  76. package/esm/common/use-component-memo/index.d.ts +1 -1
  77. package/esm/common/use-component-memo/index.d.ts.map +1 -1
  78. package/esm/common/use-component-memo/index.js +1 -1
  79. package/esm/common/use-component-memo/use-memo.d.ts +1 -1
  80. package/esm/common/use-component-memo/use-memo.d.ts.map +1 -1
  81. package/esm/common/use-component-memo/use-memo.js +1 -1
  82. package/esm/common/use-filter/index.d.ts +1 -0
  83. package/esm/common/use-filter/index.d.ts.map +1 -1
  84. package/esm/common/use-filter/index.js +2 -1
  85. package/esm/common/use-filter/use-filter-context.d.ts +7 -0
  86. package/esm/common/use-filter/use-filter-context.d.ts.map +1 -0
  87. package/esm/common/use-filter/use-filter-context.js +3 -0
  88. package/esm/common/use-filter/use-filter.d.ts +1 -0
  89. package/esm/common/use-filter/use-filter.d.ts.map +1 -1
  90. package/esm/common/use-filter/use-filter.js +2 -0
  91. package/esm/common/use-input-able/use-Input-able.d.ts.map +1 -1
  92. package/esm/common/use-input-able/use-Input-able.js +7 -8
  93. package/esm/common/use-position-style/check-element-size.d.ts +10 -0
  94. package/esm/common/use-position-style/check-element-size.d.ts.map +1 -0
  95. package/esm/common/use-position-style/check-element-size.js +59 -0
  96. package/esm/common/use-position-style/index.d.ts.map +1 -1
  97. package/esm/common/use-position-style/index.js +5 -1
  98. package/esm/components/use-datepicker/index.d.ts +1 -1
  99. package/esm/components/use-datepicker/index.d.ts.map +1 -1
  100. package/esm/components/use-datepicker/index.js +1 -1
  101. package/esm/components/use-datepicker/use-datepicker-format.d.ts +17 -0
  102. package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  103. package/esm/components/use-datepicker/use-datepicker-format.js +14 -2
  104. package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  105. package/esm/components/use-form/use-form-control/use-form-control.js +9 -4
  106. package/esm/components/use-form/use-form.d.ts +4 -4
  107. package/esm/components/use-form/use-form.d.ts.map +1 -1
  108. package/esm/components/use-form/use-form.js +31 -25
  109. package/esm/components/use-form/use-form.type.d.ts +8 -0
  110. package/esm/components/use-form/use-form.type.d.ts.map +1 -1
  111. package/esm/components/use-image/use-image.d.ts +2 -0
  112. package/esm/components/use-image/use-image.d.ts.map +1 -1
  113. package/esm/components/use-image/use-image.js +40 -2
  114. package/esm/components/use-popup/popup-context.d.ts +2 -0
  115. package/esm/components/use-popup/popup-context.d.ts.map +1 -1
  116. package/esm/components/use-popup/popup-context.js +2 -0
  117. package/esm/components/use-popup/use-popup.d.ts +4 -0
  118. package/esm/components/use-popup/use-popup.d.ts.map +1 -1
  119. package/esm/components/use-popup/use-popup.js +34 -14
  120. package/esm/components/use-table/index.d.ts +1 -1
  121. package/esm/components/use-table/index.d.ts.map +1 -1
  122. package/esm/components/use-table/use-table-filter.d.ts.map +1 -1
  123. package/esm/components/use-table/use-table-filter.js +2 -1
  124. package/esm/components/use-table/use-table-group.d.ts.map +1 -1
  125. package/esm/components/use-table/use-table-group.js +3 -1
  126. package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
  127. package/esm/components/use-table/use-table-layout.js +0 -1
  128. package/esm/components/use-table/use-table-virtual.js +1 -1
  129. package/esm/components/use-table/use-table.type.d.ts +13 -21
  130. package/esm/components/use-table/use-table.type.d.ts.map +1 -1
  131. package/esm/components/use-tree/use-tree.d.ts.map +1 -1
  132. package/esm/components/use-tree/use-tree.js +26 -8
  133. package/esm/components/use-tree/use-tree.type.d.ts +1 -0
  134. package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
  135. package/esm/components/use-upload/use-upload.d.ts.map +1 -1
  136. package/esm/components/use-upload/use-upload.js +54 -34
  137. package/esm/components/use-upload/use-upload.type.d.ts +7 -0
  138. package/esm/components/use-upload/use-upload.type.d.ts.map +1 -1
  139. package/esm/utils/clean-props.d.ts +11 -0
  140. package/esm/utils/clean-props.d.ts.map +1 -0
  141. package/esm/utils/clean-props.js +15 -0
  142. package/esm/utils/highlight.d.ts +7 -0
  143. package/esm/utils/highlight.d.ts.map +1 -0
  144. package/esm/utils/highlight.js +59 -0
  145. package/esm/utils/index.d.ts +2 -0
  146. package/esm/utils/index.d.ts.map +1 -1
  147. package/esm/utils/index.js +3 -1
  148. package/esm/utils/string.d.ts +1 -0
  149. package/esm/utils/string.d.ts.map +1 -1
  150. package/esm/utils/string.js +12 -0
  151. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import { produce } from "./immer";
2
+ var names = ['delay', 'onDatumBind', 'rules', 'formDatum', 'forceChange', 'trim', 'beforeChange', 'validateHook', 'innerFormNamePath', 'fieldSetValidate', 'combineRules', 'popoverProps', 'inputFocus', 'placeTitle', 'cancelChange', 'integerLimit', 'autoSelect', 'autoFix', 'numType'];
3
+
4
+ /**
5
+ * delete some props if needed, will not modify the pass argument
6
+ * @param props
7
+ * @returns {Produced<*, *>}
8
+ */
9
+ export function cleanProps(props) {
10
+ return produce(props, function (draft) {
11
+ names.forEach(function (p) {
12
+ return delete draft[p];
13
+ });
14
+ });
15
+ }
@@ -0,0 +1,7 @@
1
+ export declare function getHighlightText<T>({ nodeList, searchWords, highlightClassName, enable, }: {
2
+ enable?: boolean;
3
+ nodeList: T;
4
+ searchWords?: string;
5
+ highlightClassName: string;
6
+ }): T;
7
+ //# sourceMappingURL=highlight.d.ts.map
@@ -0,0 +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,CA8BJ"}
@@ -0,0 +1,59 @@
1
+ import React, { cloneElement } from 'react';
2
+ import { escapeRegExp } from "./string";
3
+ import { isArray } from "./is";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ export function getHighlightText(_ref) {
7
+ var nodeList = _ref.nodeList,
8
+ searchWords = _ref.searchWords,
9
+ highlightClassName = _ref.highlightClassName,
10
+ enable = _ref.enable;
11
+ if (!enable || !searchWords) {
12
+ return nodeList;
13
+ }
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,
19
+ searchWords: searchWords,
20
+ highlightClassName: highlightClassName
21
+ }));
22
+ }
23
+ if (node && typeof node === 'string') {
24
+ return /*#__PURE__*/_jsx(HighlightText, {
25
+ textToHighlight: node,
26
+ searchWords: searchWords,
27
+ highlightClassName: highlightClassName
28
+ });
29
+ }
30
+ return node;
31
+ };
32
+ return isArray(nodeList) ? nodeList.map(transformNode) : transformNode(nodeList);
33
+ }
34
+ function HighlightText(_ref2) {
35
+ var textToHighlight = _ref2.textToHighlight,
36
+ searchWords = _ref2.searchWords,
37
+ highlightClassName = _ref2.highlightClassName;
38
+ if (!searchWords) return /*#__PURE__*/_jsx(_Fragment, {
39
+ children: textToHighlight
40
+ });
41
+ if (searchWords.length > 500) {
42
+ searchWords = searchWords.slice(0, 500);
43
+ }
44
+
45
+ // 注意这里的括号,这里使用了带capture group功能的正则,来split字符串
46
+ // 从而在strArr中可以保留匹配文本
47
+ var re = new RegExp("(".concat(escapeRegExp(searchWords), ")"), 'i');
48
+ var strArr = textToHighlight.split(re);
49
+ return /*#__PURE__*/_jsx(_Fragment, {
50
+ children: strArr.map(function (item, index) {
51
+ return re.test(item) ? /*#__PURE__*/_jsx("span", {
52
+ className: highlightClassName,
53
+ children: item
54
+ }, index) : /*#__PURE__*/_jsx(React.Fragment, {
55
+ children: item
56
+ }, index);
57
+ })
58
+ });
59
+ }
@@ -21,5 +21,7 @@ export * from './array';
21
21
  export * from './tree';
22
22
  export * from './immer';
23
23
  export * from './warning';
24
+ export * from './highlight';
24
25
  export * as flat from './flat';
26
+ export * from './clean-props';
25
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -21,5 +21,7 @@ export * from "./array";
21
21
  export * from "./tree";
22
22
  export * from "./immer";
23
23
  export * from "./warning";
24
+ export * from "./highlight";
24
25
  import * as _flat from "./flat";
25
- export { _flat as flat };
26
+ export { _flat as flat };
27
+ export * from "./clean-props";
@@ -11,4 +11,5 @@ export declare function substitute<T extends ObjectType = ObjectType>(str: strin
11
11
  * 输出 '//github.com/'
12
12
  */
13
13
  export declare function removeProtocol(url: string): string;
14
+ export declare function escapeRegExp(str?: any): any;
14
15
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAC1D,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,EAClC,GAAG,EAAE,CAAC,UAoBP;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAQzC"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAC1D,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,EAClC,GAAG,EAAE,CAAC,UAoBP;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAQzC;AASD,wBAAgB,YAAY,CAAC,GAAG,GAAE,GAAQ,OAKzC"}
@@ -37,4 +37,16 @@ export function removeProtocol(url) {
37
37
  } catch (error) {
38
38
  return url;
39
39
  }
40
+ }
41
+
42
+ /**
43
+ * Used to match `RegExp`
44
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
45
+ */
46
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
47
+ reHasRegExpChar = RegExp(reRegExpChar.source);
48
+ export function escapeRegExp() {
49
+ var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
50
+ var string = typeof str === 'string' ? str : str.toString();
51
+ return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, '\\$&') : string;
40
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.7.0-beta.8",
3
+ "version": "3.7.0-fix.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",