assui 2.3.8 → 3.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.
Files changed (168) hide show
  1. package/es/a-select/index.js +7 -22
  2. package/es/a-select/style/index.css +195 -743
  3. package/es/area-text/index.js +1 -3
  4. package/es/button-drawer/index.js +12 -30
  5. package/es/button-modal/index.js +12 -33
  6. package/es/color-select/index.js +10 -23
  7. package/es/color-select/style/index.css +195 -743
  8. package/es/condition-input/index.js +8 -26
  9. package/es/condition-input/parse2RegexOption.js +0 -11
  10. package/es/config-provider/index.js +1 -3
  11. package/es/copy-to-clipboard/index.js +11 -27
  12. package/es/copy-to-clipboard/style/index.css +0 -1
  13. package/es/highlight-textarea/HighlighedContents.js +1 -3
  14. package/es/highlight-textarea/extractSpansOfClasses.d.ts +1 -0
  15. package/es/highlight-textarea/extractSpansOfClasses.js +7 -29
  16. package/es/highlight-textarea/getRanges.js +3 -35
  17. package/es/highlight-textarea/getType.js +0 -6
  18. package/es/highlight-textarea/index.js +11 -30
  19. package/es/highlight-textarea/style/index.css +7 -21
  20. package/es/img-crop/EasyCrop.js +18 -34
  21. package/es/img-crop/getCroppedImg.js +15 -50
  22. package/es/img-crop/index.js +56 -145
  23. package/es/img-crop/style/index.css +195 -743
  24. package/es/json-editor/index.js +6 -20
  25. package/es/keep-tab/index.d.ts +7 -2
  26. package/es/keep-tab/index.js +34 -59
  27. package/es/keep-tab/style/index.css +39 -99
  28. package/es/label-auto-complete/index.js +14 -32
  29. package/es/label-auto-complete/style/index.css +195 -743
  30. package/es/label-condition-input/index.js +13 -29
  31. package/es/label-customize-range-picker/defaultRadioList.js +0 -3
  32. package/es/label-customize-range-picker/index.js +36 -78
  33. package/es/label-customize-range-picker/style/index.css +195 -743
  34. package/es/label-customize-range-picker/utils/index.js +5 -14
  35. package/es/label-date-picker/index.js +11 -28
  36. package/es/label-date-picker/style/index.css +195 -743
  37. package/es/label-input/index.js +23 -37
  38. package/es/label-number-input/index.js +13 -28
  39. package/es/label-range-picker/index.js +11 -28
  40. package/es/label-range-picker/style/index.css +195 -743
  41. package/es/label-select/index.js +11 -27
  42. package/es/label-select/style/index.css +195 -743
  43. package/es/label-text-area/index.js +13 -35
  44. package/es/label-tree-select/index.js +15 -32
  45. package/es/label-tree-select/style/index.css +195 -743
  46. package/es/number-format-input/index.js +1 -11
  47. package/es/number-input/index.js +18 -37
  48. package/es/number-input/utils.js +7 -15
  49. package/es/rc-echart/core.js +15 -27
  50. package/es/rc-echart/index.js +0 -6
  51. package/es/rc-qrcode/index.js +2 -12
  52. package/es/rc-qrcode/useQrcode.js +5 -12
  53. package/es/rich-text-editor/index.js +5 -16
  54. package/es/rich-text-editor/plugins/code/index.js +0 -8
  55. package/es/rich-text-editor/style/index.css +195 -743
  56. package/es/single-img-upload/index.js +36 -110
  57. package/es/single-img-upload/style/index.css +195 -743
  58. package/es/split-pane/index.js +0 -4
  59. package/es/step-number-input/index.js +14 -39
  60. package/es/step-number-input/style/index.css +195 -743
  61. package/es/table-col/index.js +2 -4
  62. package/es/text-area/index.js +8 -27
  63. package/es/text-input/index.js +4 -18
  64. package/es/text-input/style/index.css +7 -21
  65. package/lib/a-select/index.js +7 -27
  66. package/lib/a-select/style/index.css +195 -743
  67. package/lib/a-select/style/index.js +0 -2
  68. package/lib/area-text/index.js +1 -6
  69. package/lib/area-text/style/index.js +0 -1
  70. package/lib/beautiful-dnd/index.js +0 -9
  71. package/lib/button-drawer/index.js +12 -42
  72. package/lib/button-drawer/style/index.js +0 -1
  73. package/lib/button-modal/index.js +12 -44
  74. package/lib/button-modal/style/index.js +0 -1
  75. package/lib/color-select/index.js +10 -39
  76. package/lib/color-select/style/index.css +195 -743
  77. package/lib/color-select/style/index.js +0 -2
  78. package/lib/condition-input/index.js +8 -41
  79. package/lib/condition-input/parse2RegexOption.js +0 -16
  80. package/lib/condition-input/style/index.js +0 -1
  81. package/lib/config-provider/context.js +0 -4
  82. package/lib/config-provider/index.js +1 -28
  83. package/lib/copy-to-clipboard/index.js +11 -38
  84. package/lib/copy-to-clipboard/style/index.css +0 -1
  85. package/lib/copy-to-clipboard/style/index.js +0 -1
  86. package/lib/highlight-textarea/HighlighedContents.js +1 -7
  87. package/lib/highlight-textarea/extractSpansOfClasses.d.ts +1 -0
  88. package/lib/highlight-textarea/extractSpansOfClasses.js +7 -31
  89. package/lib/highlight-textarea/getRanges.js +3 -38
  90. package/lib/highlight-textarea/getType.js +0 -8
  91. package/lib/highlight-textarea/index.js +11 -44
  92. package/lib/highlight-textarea/style/index.css +7 -21
  93. package/lib/highlight-textarea/style/index.js +0 -1
  94. package/lib/highlight-words/index.js +0 -3
  95. package/lib/img-crop/EasyCrop.js +18 -44
  96. package/lib/img-crop/getCroppedImg.js +15 -51
  97. package/lib/img-crop/index.js +56 -159
  98. package/lib/img-crop/style/index.css +195 -743
  99. package/lib/img-crop/style/index.js +0 -3
  100. package/lib/index.js +0 -77
  101. package/lib/json-editor/index.js +6 -35
  102. package/lib/json-editor/style/index.js +0 -2
  103. package/lib/keep-tab/index.d.ts +7 -2
  104. package/lib/keep-tab/index.js +34 -76
  105. package/lib/keep-tab/style/index.css +39 -99
  106. package/lib/keep-tab/style/index.js +0 -2
  107. package/lib/label-auto-complete/index.js +14 -39
  108. package/lib/label-auto-complete/style/index.css +195 -743
  109. package/lib/label-auto-complete/style/index.js +0 -2
  110. package/lib/label-condition-input/index.js +13 -36
  111. package/lib/label-condition-input/style/index.js +0 -1
  112. package/lib/label-customize-range-picker/defaultRadioList.js +0 -7
  113. package/lib/label-customize-range-picker/index.js +36 -99
  114. package/lib/label-customize-range-picker/style/index.css +195 -743
  115. package/lib/label-customize-range-picker/style/index.js +0 -5
  116. package/lib/label-customize-range-picker/utils/index.js +5 -19
  117. package/lib/label-date-picker/index.js +11 -34
  118. package/lib/label-date-picker/style/index.css +195 -743
  119. package/lib/label-date-picker/style/index.js +0 -2
  120. package/lib/label-input/index.js +23 -46
  121. package/lib/label-input/style/index.js +0 -1
  122. package/lib/label-number-input/index.js +13 -36
  123. package/lib/label-number-input/style/index.js +0 -1
  124. package/lib/label-range-picker/index.js +11 -36
  125. package/lib/label-range-picker/style/index.css +195 -743
  126. package/lib/label-range-picker/style/index.js +0 -2
  127. package/lib/label-select/index.js +11 -36
  128. package/lib/label-select/style/index.css +195 -743
  129. package/lib/label-select/style/index.js +0 -2
  130. package/lib/label-text-area/index.js +13 -40
  131. package/lib/label-text-area/style/index.js +0 -1
  132. package/lib/label-tree-select/index.js +15 -38
  133. package/lib/label-tree-select/style/index.css +195 -743
  134. package/lib/label-tree-select/style/index.js +0 -2
  135. package/lib/messages/index.js +0 -2
  136. package/lib/number-format-input/index.js +1 -15
  137. package/lib/number-format-input/style/index.js +0 -1
  138. package/lib/number-input/index.js +18 -55
  139. package/lib/number-input/style/index.js +0 -1
  140. package/lib/number-input/utils.js +8 -20
  141. package/lib/rc-echart/core.js +15 -40
  142. package/lib/rc-echart/index.js +0 -17
  143. package/lib/rc-motion/index.js +0 -3
  144. package/lib/rc-qrcode/index.js +2 -25
  145. package/lib/rc-qrcode/useQrcode.js +5 -17
  146. package/lib/rc-transition-group/index.js +0 -9
  147. package/lib/resizable/index.js +0 -2
  148. package/lib/resizable/style/index.js +0 -1
  149. package/lib/rich-text-editor/index.js +5 -53
  150. package/lib/rich-text-editor/plugins/code/index.js +2 -12
  151. package/lib/rich-text-editor/style/index.css +195 -743
  152. package/lib/rich-text-editor/style/index.js +0 -1
  153. package/lib/single-img-upload/index.js +36 -125
  154. package/lib/single-img-upload/style/index.css +195 -743
  155. package/lib/single-img-upload/style/index.js +0 -3
  156. package/lib/sortable-hoc/index.js +0 -9
  157. package/lib/split-pane/index.js +0 -15
  158. package/lib/split-pane/style/index.js +0 -1
  159. package/lib/step-number-input/index.js +14 -55
  160. package/lib/step-number-input/style/index.css +195 -743
  161. package/lib/step-number-input/style/index.js +0 -2
  162. package/lib/table-col/index.js +2 -6
  163. package/lib/text-area/index.js +8 -38
  164. package/lib/text-area/style/index.js +0 -1
  165. package/lib/text-input/index.js +4 -23
  166. package/lib/text-input/style/index.css +7 -21
  167. package/lib/text-input/style/index.js +0 -1
  168. package/package.json +5 -5
@@ -2,39 +2,31 @@ var __assign = this && this.__assign || function () {
2
2
  __assign = Object.assign || function (t) {
3
3
  for (var s, i = 1, n = arguments.length; i < n; i++) {
4
4
  s = arguments[i];
5
-
6
5
  for (var p in s) {
7
6
  if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
7
  }
9
8
  }
10
-
11
9
  return t;
12
10
  };
13
-
14
11
  return __assign.apply(this, arguments);
15
12
  };
16
-
17
13
  var __rest = this && this.__rest || function (s, e) {
18
14
  var t = {};
19
-
20
15
  for (var p in s) {
21
16
  if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
22
17
  }
23
-
24
18
  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
25
19
  if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
26
20
  }
27
21
  return t;
28
22
  };
29
-
30
23
  var __read = this && this.__read || function (o, n) {
31
24
  var m = typeof Symbol === "function" && o[Symbol.iterator];
32
25
  if (!m) return o;
33
26
  var i = m.call(o),
34
- r,
35
- ar = [],
36
- e;
37
-
27
+ r,
28
+ ar = [],
29
+ e;
38
30
  try {
39
31
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
40
32
  ar.push(r.value);
@@ -50,10 +42,8 @@ var __read = this && this.__read || function (o, n) {
50
42
  if (e) throw e.error;
51
43
  }
52
44
  }
53
-
54
45
  return ar;
55
46
  };
56
-
57
47
  import * as React from 'react';
58
48
  import isArray from 'lodash/isArray';
59
49
  import Input from "antd/es/input";
@@ -62,40 +52,32 @@ import useControllableValue from "ahooks/es/useControllableValue";
62
52
  import parse2RegexOption from './parse2RegexOption';
63
53
  var ConditionInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
64
54
  var _a = __read(useControllableValue(props), 2),
65
- value = _a[0],
66
- setValue = _a[1];
67
-
55
+ value = _a[0],
56
+ setValue = _a[1];
68
57
  var regexp = props.regexp,
69
- formatter = props.formatter,
70
- onChange = props.onChange,
71
- rest = __rest(props, ["regexp", "formatter", "onChange"]);
72
-
58
+ formatter = props.formatter,
59
+ onChange = props.onChange,
60
+ rest = __rest(props, ["regexp", "formatter", "onChange"]);
73
61
  var handleChange = function handleChange(e) {
74
62
  var originalValue = e.target.value;
75
63
  var nextValue = originalValue;
76
-
77
64
  if (regexp) {
78
65
  var resultRegexp = isArray(regexp) ? regexp : [regexp];
79
66
  nextValue = resultRegexp.reduce(function (cur, acc) {
80
67
  var regexOption = parse2RegexOption(acc);
81
-
82
68
  if (regexOption.isValid) {
83
69
  return cur.replace(regexOption.pattern, regexOption.replacement);
84
70
  }
85
-
86
71
  return cur;
87
72
  }, originalValue);
88
73
  }
89
-
90
74
  if (isFunction(formatter)) {
91
75
  nextValue = formatter(nextValue);
92
76
  }
93
-
94
77
  if (value !== nextValue) {
95
78
  setValue(nextValue);
96
79
  }
97
80
  };
98
-
99
81
  return /*#__PURE__*/React.createElement(Input, __assign({
100
82
  ref: ref,
101
83
  value: value,
@@ -2,18 +2,14 @@ var __assign = this && this.__assign || function () {
2
2
  __assign = Object.assign || function (t) {
3
3
  for (var s, i = 1, n = arguments.length; i < n; i++) {
4
4
  s = arguments[i];
5
-
6
5
  for (var p in s) {
7
6
  if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
7
  }
9
8
  }
10
-
11
9
  return t;
12
10
  };
13
-
14
11
  return __assign.apply(this, arguments);
15
12
  };
16
-
17
13
  import isRegExp from 'lodash/isRegExp';
18
14
  import isString from 'lodash/isString';
19
15
  import isObject from 'lodash/isObject';
@@ -21,37 +17,30 @@ var defaultOptionValues = {
21
17
  isValid: true,
22
18
  replacement: ''
23
19
  };
24
-
25
20
  var parseRegex2RegexOption = function parseRegex2RegexOption(regex, options) {
26
21
  return __assign(__assign(__assign({}, defaultOptionValues), {
27
22
  pattern: regex
28
23
  }), options);
29
24
  };
30
-
31
25
  var parseString2RegexOption = function parseString2RegexOption(regexString, options) {
32
26
  return parseRegex2RegexOption(new RegExp(regexString), options);
33
27
  };
34
-
35
28
  var parse2RegexOption = function parse2RegexOption(regex) {
36
29
  if (isRegExp(regex)) {
37
30
  return parseRegex2RegexOption(regex);
38
31
  }
39
-
40
32
  if (isString(regex)) {
41
33
  return parseString2RegexOption(regex);
42
34
  }
43
-
44
35
  if (isObject(regex)) {
45
36
  return __assign(__assign(__assign({}, defaultOptionValues), {
46
37
  isValid: !!regex.pattern
47
38
  }), regex);
48
39
  }
49
-
50
40
  return {
51
41
  isValid: false,
52
42
  replacement: '',
53
43
  pattern: /./
54
44
  };
55
45
  };
56
-
57
46
  export default parse2RegexOption;
@@ -22,10 +22,9 @@ import arEG from '../messages/ar_EG';
22
22
  import thTH from '../messages/th_TH';
23
23
  import roRO from '../messages/ro_RO';
24
24
  import viVN from '../messages/vi_VN';
25
-
26
25
  var ConfigProvider = function ConfigProvider(props) {
27
26
  var children = props.children,
28
- locale = props.locale;
27
+ locale = props.locale;
29
28
  var messagesMap = {
30
29
  'en-US': enUS.lang,
31
30
  'zh-CN': zhCN.lang,
@@ -54,5 +53,4 @@ var ConfigProvider = function ConfigProvider(props) {
54
53
  value: messagesMap[locale]
55
54
  }, children);
56
55
  };
57
-
58
56
  export default ConfigProvider;
@@ -2,26 +2,21 @@ var __assign = this && this.__assign || function () {
2
2
  __assign = Object.assign || function (t) {
3
3
  for (var s, i = 1, n = arguments.length; i < n; i++) {
4
4
  s = arguments[i];
5
-
6
5
  for (var p in s) {
7
6
  if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
7
  }
9
8
  }
10
-
11
9
  return t;
12
10
  };
13
-
14
11
  return __assign.apply(this, arguments);
15
12
  };
16
-
17
13
  var __read = this && this.__read || function (o, n) {
18
14
  var m = typeof Symbol === "function" && o[Symbol.iterator];
19
15
  if (!m) return o;
20
16
  var i = m.call(o),
21
- r,
22
- ar = [],
23
- e;
24
-
17
+ r,
18
+ ar = [],
19
+ e;
25
20
  try {
26
21
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
27
22
  ar.push(r.value);
@@ -37,53 +32,43 @@ var __read = this && this.__read || function (o, n) {
37
32
  if (e) throw e.error;
38
33
  }
39
34
  }
40
-
41
35
  return ar;
42
36
  };
43
-
44
37
  import React, { useState } from 'react';
45
38
  import copy from 'copy-to-clipboard';
46
39
  import Tooltip from "antd/es/tooltip";
47
-
48
40
  var CopyToClipboard = function CopyToClipboard(props) {
49
41
  var text = props.text,
50
- onCopy = props.onCopy,
51
- children = props.children,
52
- options = props.options,
53
- tooltipTitle = props.tooltipTitle,
54
- tooltipProps = props.tooltipProps;
55
-
42
+ onCopy = props.onCopy,
43
+ children = props.children,
44
+ options = props.options,
45
+ tooltipTitle = props.tooltipTitle,
46
+ tooltipProps = props.tooltipProps;
56
47
  var _a = __read(useState(false), 2),
57
- tooltipVisible = _a[0],
58
- setTooltipVisible = _a[1];
59
-
48
+ tooltipVisible = _a[0],
49
+ setTooltipVisible = _a[1];
60
50
  var handleCopySuccess = function handleCopySuccess() {
61
51
  setTooltipVisible(true);
62
52
  setTimeout(function () {
63
53
  setTooltipVisible(false);
64
54
  }, 1000);
65
55
  };
66
-
67
56
  var onClick = function onClick(event) {
68
57
  var elem = React.Children.only(children);
69
58
  var result = copy(text, options);
70
-
71
59
  if (onCopy) {
72
60
  onCopy(text, result);
73
61
  }
74
-
75
62
  if (tooltipTitle) {
76
63
  handleCopySuccess();
77
64
  }
78
-
79
65
  if (elem && elem.props && typeof elem.props.onClick === 'function') {
80
66
  elem.props.onClick(event);
81
67
  }
82
68
  };
83
-
84
69
  return tooltipTitle ? /*#__PURE__*/React.createElement(Tooltip, __assign({
85
70
  placement: "topLeft",
86
- visible: tooltipVisible,
71
+ open: tooltipVisible,
87
72
  title: tooltipTitle
88
73
  }, tooltipProps), /*#__PURE__*/React.cloneElement(children, {
89
74
  onClick: onClick
@@ -91,5 +76,4 @@ var CopyToClipboard = function CopyToClipboard(props) {
91
76
  onClick: onClick
92
77
  });
93
78
  };
94
-
95
79
  export default /*#__PURE__*/React.memo(CopyToClipboard);
@@ -15,7 +15,6 @@
15
15
  position: absolute;
16
16
  z-index: 1070;
17
17
  display: block;
18
- width: -webkit-max-content;
19
18
  width: -moz-max-content;
20
19
  width: max-content;
21
20
  width: intrinsic;
@@ -1,15 +1,13 @@
1
1
  import React from 'react';
2
2
  import getRanges from './getRanges';
3
3
  import extractSpansOfClasses from './extractSpansOfClasses';
4
-
5
4
  var HighlighedContents = function HighlighedContents(_a) {
6
5
  var value = _a.value,
7
- highlight = _a.highlight;
6
+ highlight = _a.highlight;
8
7
  var ranges = getRanges(value, highlight);
9
8
  var parts = extractSpansOfClasses(value, ranges);
10
9
  return /*#__PURE__*/React.createElement(React.Fragment, null, parts.map(function (part) {
11
10
  return part.render();
12
11
  }));
13
12
  };
14
-
15
13
  export default HighlighedContents;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { RangesType } from './types';
2
3
  declare class Span {
3
4
  beginIndex: number;
@@ -2,10 +2,9 @@ var __read = this && this.__read || function (o, n) {
2
2
  var m = typeof Symbol === "function" && o[Symbol.iterator];
3
3
  if (!m) return o;
4
4
  var i = m.call(o),
5
- r,
6
- ar = [],
7
- e;
8
-
5
+ r,
6
+ ar = [],
7
+ e;
9
8
  try {
10
9
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
11
10
  ar.push(r.value);
@@ -21,10 +20,8 @@ var __read = this && this.__read || function (o, n) {
21
20
  if (e) throw e.error;
22
21
  }
23
22
  }
24
-
25
23
  return ar;
26
24
  };
27
-
28
25
  var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
29
26
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
27
  if (ar || !(i in from)) {
@@ -35,13 +32,8 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
35
32
  return to.concat(ar || Array.prototype.slice.call(from));
36
33
  };
37
34
  /* eslint-disable no-plusplus */
38
-
39
-
40
35
  import React from 'react';
41
-
42
- var Span =
43
- /** @class */
44
- function () {
36
+ var Span = /** @class */function () {
45
37
  function Span(text, beginIndex) {
46
38
  this.beginIndex = beginIndex;
47
39
  this.endIndex = beginIndex + text.length;
@@ -49,19 +41,15 @@ function () {
49
41
  this.isMark = false;
50
42
  this.markClasses = new Set();
51
43
  }
52
-
53
44
  Span.prototype.setMark = function (className) {
54
45
  var _this = this;
55
-
56
46
  this.isMark = true;
57
-
58
47
  if (className) {
59
48
  className.split(' ').forEach(function (cls) {
60
49
  _this.markClasses.add(cls);
61
50
  });
62
51
  }
63
52
  };
64
-
65
53
  Span.prototype.carve = function (beginIndex2) {
66
54
  var rightText = this.text.slice(beginIndex2 - this.beginIndex);
67
55
  this.text = this.text.slice(0, beginIndex2 - this.beginIndex);
@@ -71,43 +59,35 @@ function () {
71
59
  right.markClasses = new Set(__spreadArray([], __read(this.markClasses), false));
72
60
  return right;
73
61
  };
74
-
75
62
  Object.defineProperty(Span.prototype, "className", {
76
63
  get: function get() {
77
64
  if (this.markClasses && this.markClasses.size > 0) {
78
65
  return __spreadArray([], __read(this.markClasses), false).sort().join(' ');
79
66
  }
80
-
81
67
  return '';
82
68
  },
83
69
  enumerable: false,
84
70
  configurable: true
85
71
  });
86
-
87
72
  Span.prototype.render = function () {
88
73
  if (this.isMark) {
89
74
  var className = this.className;
90
-
91
75
  if (className) {
92
76
  return /*#__PURE__*/React.createElement("mark", {
93
77
  key: this.beginIndex,
94
78
  className: className
95
79
  }, this.text);
96
80
  }
97
-
98
81
  return /*#__PURE__*/React.createElement("mark", {
99
82
  key: this.beginIndex
100
83
  }, this.text);
101
84
  }
102
-
103
85
  return /*#__PURE__*/React.createElement("span", {
104
86
  key: this.beginIndex
105
87
  }, this.text);
106
88
  };
107
-
108
89
  return Span;
109
90
  }();
110
-
111
91
  export default function extractSpansOfClasses(value, ranges) {
112
92
  var spans = [new Span(value, 0)];
113
93
  ranges.forEach(function (range) {
@@ -115,11 +95,10 @@ export default function extractSpansOfClasses(value, ranges) {
115
95
  var endIndex = range[1];
116
96
  var rangeOption = range[2];
117
97
  var _a = (rangeOption || {}).className,
118
- className = _a === void 0 ? '' : _a;
119
-
98
+ className = _a === void 0 ? '' : _a;
120
99
  for (var i = 0; i < spans.length; i++) {
121
- var span = spans[i]; // since spans are sorted, So this is always true: beginIndex >= span.beginIndex.
122
-
100
+ var span = spans[i];
101
+ // since spans are sorted, So this is always true: beginIndex >= span.beginIndex.
123
102
  if (beginIndex < span.endIndex) {
124
103
  if (beginIndex === span.beginIndex) {
125
104
  if (endIndex < span.endIndex) {
@@ -155,7 +134,6 @@ export default function extractSpansOfClasses(value, ranges) {
155
134
  i += 1;
156
135
  }
157
136
  }
158
-
159
137
  if (beginIndex === endIndex) {
160
138
  break;
161
139
  }
@@ -2,10 +2,9 @@ var __read = this && this.__read || function (o, n) {
2
2
  var m = typeof Symbol === "function" && o[Symbol.iterator];
3
3
  if (!m) return o;
4
4
  var i = m.call(o),
5
- r,
6
- ar = [],
7
- e;
8
-
5
+ r,
6
+ ar = [],
7
+ e;
9
8
  try {
10
9
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
11
10
  ar.push(r.value);
@@ -21,10 +20,8 @@ var __read = this && this.__read || function (o, n) {
21
20
  if (e) throw e.error;
22
21
  }
23
22
  }
24
-
25
23
  return ar;
26
24
  };
27
-
28
25
  var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
29
26
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
27
  if (ar || !(i in from)) {
@@ -35,47 +32,33 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
35
32
  return to.concat(ar || Array.prototype.slice.call(from));
36
33
  };
37
34
  /* eslint-disable no-param-reassign */
38
-
39
35
  /* eslint-disable @typescript-eslint/no-use-before-define */
40
-
41
36
  /* eslint-disable no-cond-assign */
42
-
43
-
44
37
  import getType from './getType';
45
38
  export default function getRanges(input, highlight) {
46
39
  var type = getType(highlight);
47
-
48
40
  switch (type) {
49
41
  case 'array':
50
42
  return getArrayRanges(input, highlight);
51
-
52
43
  case 'function':
53
44
  return getFunctionRanges(input, highlight);
54
-
55
45
  case 'regexp':
56
46
  return getRegExpRanges(input, highlight);
57
-
58
47
  case 'string':
59
48
  return getStringRanges(input, highlight);
60
-
61
49
  case 'range':
62
50
  return getRangeRanges(highlight);
63
-
64
51
  case 'custom':
65
52
  return getCustomRanges(input, highlight);
66
-
67
53
  default:
68
54
  if (!highlight) {
69
55
  // do nothing for falsely values
70
56
  return [];
71
57
  }
72
-
73
58
  console.error('unrecognized highlight type');
74
59
  }
75
-
76
60
  return [];
77
61
  }
78
-
79
62
  function getArrayRanges(input, arr) {
80
63
  // const ranges: RangesType = arr.map(getRanges.bind(this, input));
81
64
  var ranges = arr.map(function (highlight) {
@@ -83,64 +66,49 @@ function getArrayRanges(input, arr) {
83
66
  });
84
67
  return Array.prototype.concat.apply([], ranges);
85
68
  }
86
-
87
69
  function getFunctionRanges(input, func) {
88
70
  return getRanges(input, func(input));
89
71
  }
90
-
91
72
  function getRegExpRanges(input, regex) {
92
73
  var ranges = [];
93
74
  var match;
94
-
95
75
  while (match = regex.exec(input), match !== null) {
96
76
  ranges.push([match.index, match.index + match[0].length]);
97
-
98
77
  if (!regex.global) {
99
78
  // non-global regexes do not increase lastIndex, causing an infinite loop,
100
79
  // but we can just break manually after the first match
101
80
  break;
102
81
  }
103
82
  }
104
-
105
83
  return ranges;
106
84
  }
107
-
108
85
  function getStringRanges(input, str) {
109
86
  var ranges = [];
110
87
  var inputLower = input.toLowerCase();
111
88
  var strLower = str.toLowerCase();
112
89
  var index = 0;
113
-
114
90
  while (index = inputLower.indexOf(strLower, index), index !== -1) {
115
91
  ranges.push([index, index + strLower.length]);
116
92
  index += strLower.length;
117
93
  }
118
-
119
94
  return ranges;
120
95
  }
121
-
122
96
  function getRangeRanges(range) {
123
97
  return [range];
124
98
  }
125
-
126
99
  function getCustomRanges(input, custom) {
127
100
  var ranges = getRanges(input, custom.highlight);
128
-
129
101
  var resultRangesData = __spreadArray([], __read(ranges), false);
130
-
131
102
  if (custom.className) {
132
103
  resultRangesData.forEach(function (range) {
133
104
  var rangeOption = range[2] || {};
134
-
135
105
  if (rangeOption.className) {
136
106
  rangeOption.className = "".concat(custom.className, " ").concat(rangeOption.className);
137
107
  } else {
138
108
  rangeOption.className = custom.className;
139
109
  }
140
-
141
110
  range[2] = rangeOption;
142
111
  });
143
112
  }
144
-
145
113
  return ranges;
146
114
  }
@@ -1,29 +1,23 @@
1
1
  export default function getType(instance) {
2
2
  var type = typeof instance;
3
-
4
3
  if (!instance) {
5
4
  return 'falsely';
6
5
  }
7
-
8
6
  if (Array.isArray(instance)) {
9
7
  if (instance.length === 2 && typeof instance[0] === 'number' && typeof instance[1] === 'number') {
10
8
  return 'range';
11
9
  }
12
-
13
10
  return 'array';
14
11
  }
15
-
16
12
  if (type === 'object') {
17
13
  if (instance instanceof RegExp) {
18
14
  return 'regexp';
19
15
  }
20
-
21
16
  if (instance.highlight) {
22
17
  return 'custom';
23
18
  }
24
19
  } else if (type === 'function' || type === 'string') {
25
20
  return type;
26
21
  }
27
-
28
22
  return 'other';
29
23
  }