assui 2.0.2 → 2.0.6
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/es/button-drawer/index.d.ts +10 -0
- package/es/button-drawer/index.js +116 -0
- package/es/button-drawer/style/index.d.ts +1 -0
- package/es/button-drawer/style/index.js +1 -0
- package/es/button-modal/index.d.ts +14 -0
- package/es/button-modal/index.js +131 -0
- package/es/button-modal/style/index.d.ts +1 -0
- package/es/button-modal/style/index.js +1 -0
- package/es/condition-input/index.d.ts +15 -0
- package/es/condition-input/index.js +108 -0
- package/es/condition-input/parse2RegexOption.d.ts +13 -0
- package/es/condition-input/parse2RegexOption.js +57 -0
- package/es/condition-input/style/index.d.ts +1 -0
- package/es/condition-input/style/index.js +1 -0
- package/es/copy-to-clipboard/index.d.ts +22 -0
- package/es/copy-to-clipboard/index.js +95 -0
- package/es/copy-to-clipboard/style/index.css +249 -0
- package/es/copy-to-clipboard/style/index.d.ts +1 -0
- package/es/copy-to-clipboard/style/index.js +1 -0
- package/es/copy-to-clipboard/style/index.less +1 -0
- package/es/highlight-textarea/HighlighedContents.d.ts +7 -0
- package/es/highlight-textarea/HighlighedContents.js +15 -0
- package/es/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
- package/es/highlight-textarea/extractSpansOfClasses.js +159 -0
- package/es/highlight-textarea/getRanges.d.ts +2 -0
- package/es/highlight-textarea/getRanges.js +142 -0
- package/es/highlight-textarea/getType.d.ts +2 -0
- package/es/highlight-textarea/getType.js +29 -0
- package/es/highlight-textarea/index.d.ts +12 -0
- package/es/highlight-textarea/index.js +132 -0
- package/es/highlight-textarea/style/index.css +38 -0
- package/es/highlight-textarea/style/index.d.ts +2 -0
- package/es/highlight-textarea/style/index.js +2 -0
- package/es/highlight-textarea/style/index.less +42 -0
- package/es/highlight-textarea/types.d.ts +16 -0
- package/es/highlight-textarea/types.js +0 -0
- package/es/highlight-words/index.d.ts +3 -0
- package/es/highlight-words/index.js +2 -0
- package/es/highlight-words/style/index.d.ts +1 -0
- package/es/highlight-words/style/index.js +0 -0
- package/es/icon/demo/svg/check-circle-filled.svg +6 -0
- package/es/icon/demo/svg/coin-circle.svg +9 -0
- package/es/icon/index.d.ts +27 -0
- package/es/icon/index.js +95 -0
- package/es/icon/style/index.d.ts +1 -0
- package/es/icon/style/index.js +0 -0
- package/es/icon/utils.d.ts +6 -0
- package/es/icon/utils.js +22 -0
- package/es/img-crop/EasyCrop.d.ts +6 -0
- package/es/img-crop/EasyCrop.js +113 -0
- package/es/img-crop/getCroppedImg.d.ts +6 -0
- package/es/img-crop/getCroppedImg.js +199 -0
- package/es/img-crop/index.d.ts +53 -0
- package/es/img-crop/index.js +531 -0
- package/es/img-crop/style/index.css +52 -0
- package/es/img-crop/style/index.d.ts +3 -0
- package/es/img-crop/style/index.js +3 -0
- package/es/img-crop/style/index.less +54 -0
- package/es/index.d.ts +34 -2
- package/es/index.js +18 -2
- package/es/keep-tab/demo/index.modules.less +66 -0
- package/es/keep-tab/index.d.ts +29 -0
- package/es/keep-tab/index.js +129 -0
- package/es/keep-tab/style/index.css +1129 -0
- package/es/keep-tab/style/index.d.ts +2 -0
- package/es/keep-tab/style/index.js +2 -0
- package/es/keep-tab/style/index.less +2 -0
- package/es/number-input/index.d.ts +22 -7
- package/es/number-input/index.js +22 -11
- package/es/number-input/style/index.d.ts +1 -1
- package/es/number-input/style/index.js +1 -1
- package/es/number-input/utils.d.ts +10 -11
- package/es/number-input/utils.js +7 -7
- package/es/rc-echart/core.d.ts +32 -0
- package/es/rc-echart/core.js +136 -0
- package/es/rc-echart/index.d.ts +21 -0
- package/es/rc-echart/index.js +27 -0
- package/es/rc-echart/style/index.d.ts +1 -0
- package/es/rc-echart/style/index.js +0 -0
- package/es/rc-motion/demo/CSSMotion.less +91 -0
- package/es/rc-motion/index.d.ts +2 -0
- package/es/rc-motion/index.js +2 -0
- package/es/rc-motion/style/index.d.ts +1 -0
- package/es/rc-motion/style/index.js +0 -0
- package/es/rc-qrcode/index.d.ts +20 -0
- package/es/rc-qrcode/index.js +57 -0
- package/es/rc-qrcode/style/index.d.ts +1 -0
- package/es/rc-qrcode/style/index.js +0 -0
- package/es/rc-qrcode/useQrcode.d.ts +4 -0
- package/es/rc-qrcode/useQrcode.js +50 -0
- package/es/rc-transition-group/index.d.ts +2 -0
- package/es/rc-transition-group/index.js +2 -0
- package/es/rc-transition-group/style/index.d.ts +1 -0
- package/es/rc-transition-group/style/index.js +0 -0
- package/es/single-img-upload/index.d.ts +19 -0
- package/es/single-img-upload/index.js +199 -0
- package/es/single-img-upload/style/index.css +74 -0
- package/es/single-img-upload/style/index.d.ts +3 -0
- package/es/single-img-upload/style/index.js +3 -0
- package/es/single-img-upload/style/index.less +85 -0
- package/es/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
- package/es/sortable-hoc/demo/index.modules.less +248 -0
- package/es/sortable-hoc/index.d.ts +2 -0
- package/es/sortable-hoc/index.js +2 -0
- package/es/sortable-hoc/style/index.d.ts +1 -0
- package/es/sortable-hoc/style/index.js +0 -0
- package/es/split-pane/index.d.ts +59 -0
- package/es/split-pane/index.js +21 -0
- package/es/split-pane/style/index.css +41 -0
- package/es/split-pane/style/index.d.ts +1 -0
- package/es/split-pane/style/index.js +1 -0
- package/es/split-pane/style/index.less +49 -0
- package/es/text-area/index.d.ts +12 -0
- package/es/text-area/index.js +96 -0
- package/es/text-area/style/index.d.ts +1 -0
- package/es/text-area/style/index.js +1 -0
- package/es/text-input/index.d.ts +5 -0
- package/es/text-input/index.js +85 -0
- package/es/{number-input → text-input}/style/index.css +0 -3
- package/es/text-input/style/index.d.ts +1 -0
- package/es/text-input/style/index.js +1 -0
- package/es/{number-input → text-input}/style/index.less +0 -4
- package/lib/button-drawer/index.d.ts +10 -0
- package/lib/button-drawer/index.js +164 -0
- package/lib/button-drawer/style/index.d.ts +1 -0
- package/lib/button-drawer/style/index.js +7 -0
- package/lib/button-modal/index.d.ts +14 -0
- package/lib/button-modal/index.js +178 -0
- package/lib/button-modal/style/index.d.ts +1 -0
- package/lib/button-modal/style/index.js +7 -0
- package/lib/condition-input/index.d.ts +15 -0
- package/lib/condition-input/index.js +158 -0
- package/lib/condition-input/parse2RegexOption.d.ts +13 -0
- package/lib/condition-input/parse2RegexOption.js +72 -0
- package/lib/condition-input/style/index.d.ts +1 -0
- package/lib/condition-input/style/index.js +7 -0
- package/lib/copy-to-clipboard/index.d.ts +22 -0
- package/lib/copy-to-clipboard/index.js +143 -0
- package/lib/copy-to-clipboard/style/index.css +249 -0
- package/lib/copy-to-clipboard/style/index.d.ts +1 -0
- package/lib/copy-to-clipboard/style/index.js +7 -0
- package/lib/copy-to-clipboard/style/index.less +1 -0
- package/lib/highlight-textarea/HighlighedContents.d.ts +7 -0
- package/lib/highlight-textarea/HighlighedContents.js +29 -0
- package/lib/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
- package/lib/highlight-textarea/extractSpansOfClasses.js +173 -0
- package/lib/highlight-textarea/getRanges.d.ts +2 -0
- package/lib/highlight-textarea/getRanges.js +156 -0
- package/lib/highlight-textarea/getType.d.ts +2 -0
- package/lib/highlight-textarea/getType.js +37 -0
- package/lib/highlight-textarea/index.d.ts +12 -0
- package/lib/highlight-textarea/index.js +183 -0
- package/lib/highlight-textarea/style/index.css +38 -0
- package/lib/highlight-textarea/style/index.d.ts +2 -0
- package/lib/highlight-textarea/style/index.js +9 -0
- package/lib/highlight-textarea/style/index.less +42 -0
- package/lib/highlight-textarea/types.d.ts +16 -0
- package/lib/highlight-textarea/types.js +5 -0
- package/lib/highlight-words/index.d.ts +3 -0
- package/lib/highlight-words/index.js +15 -0
- package/lib/highlight-words/style/index.d.ts +1 -0
- package/lib/highlight-words/style/index.js +0 -0
- package/lib/icon/demo/svg/check-circle-filled.svg +6 -0
- package/lib/icon/demo/svg/coin-circle.svg +9 -0
- package/lib/icon/index.d.ts +27 -0
- package/lib/icon/index.js +143 -0
- package/lib/icon/style/index.d.ts +1 -0
- package/lib/icon/style/index.js +0 -0
- package/lib/icon/utils.d.ts +6 -0
- package/lib/icon/utils.js +32 -0
- package/lib/img-crop/EasyCrop.d.ts +6 -0
- package/lib/img-crop/EasyCrop.js +160 -0
- package/lib/img-crop/getCroppedImg.d.ts +6 -0
- package/lib/img-crop/getCroppedImg.js +205 -0
- package/lib/img-crop/index.d.ts +53 -0
- package/lib/img-crop/index.js +582 -0
- package/lib/img-crop/style/index.css +52 -0
- package/lib/img-crop/style/index.d.ts +3 -0
- package/lib/img-crop/style/index.js +11 -0
- package/lib/img-crop/style/index.less +54 -0
- package/lib/index.d.ts +34 -2
- package/lib/index.js +160 -9
- package/lib/keep-tab/demo/index.modules.less +66 -0
- package/lib/keep-tab/index.d.ts +29 -0
- package/lib/keep-tab/index.js +181 -0
- package/lib/keep-tab/style/index.css +1129 -0
- package/lib/keep-tab/style/index.d.ts +2 -0
- package/lib/keep-tab/style/index.js +9 -0
- package/lib/keep-tab/style/index.less +2 -0
- package/lib/number-input/index.d.ts +22 -7
- package/lib/number-input/index.js +22 -11
- package/lib/number-input/style/index.d.ts +1 -1
- package/lib/number-input/style/index.js +1 -1
- package/lib/number-input/utils.d.ts +10 -11
- package/lib/number-input/utils.js +8 -8
- package/lib/rc-echart/core.d.ts +32 -0
- package/lib/rc-echart/core.js +185 -0
- package/lib/rc-echart/index.d.ts +21 -0
- package/lib/rc-echart/index.js +75 -0
- package/lib/rc-echart/style/index.d.ts +1 -0
- package/lib/rc-echart/style/index.js +0 -0
- package/lib/rc-motion/demo/CSSMotion.less +91 -0
- package/lib/rc-motion/index.d.ts +2 -0
- package/lib/rc-motion/index.js +43 -0
- package/lib/rc-motion/style/index.d.ts +1 -0
- package/lib/rc-motion/style/index.js +0 -0
- package/lib/rc-qrcode/index.d.ts +20 -0
- package/lib/rc-qrcode/index.js +108 -0
- package/lib/rc-qrcode/style/index.d.ts +1 -0
- package/lib/rc-qrcode/style/index.js +0 -0
- package/lib/rc-qrcode/useQrcode.d.ts +4 -0
- package/lib/rc-qrcode/useQrcode.js +66 -0
- package/lib/rc-transition-group/index.d.ts +2 -0
- package/lib/rc-transition-group/index.js +43 -0
- package/lib/rc-transition-group/style/index.d.ts +1 -0
- package/lib/rc-transition-group/style/index.js +0 -0
- package/lib/single-img-upload/index.d.ts +19 -0
- package/lib/single-img-upload/index.js +250 -0
- package/lib/single-img-upload/style/index.css +74 -0
- package/lib/single-img-upload/style/index.d.ts +3 -0
- package/lib/single-img-upload/style/index.js +11 -0
- package/lib/single-img-upload/style/index.less +85 -0
- package/lib/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
- package/lib/sortable-hoc/demo/index.modules.less +248 -0
- package/lib/sortable-hoc/index.d.ts +2 -0
- package/lib/sortable-hoc/index.js +43 -0
- package/lib/sortable-hoc/style/index.d.ts +1 -0
- package/lib/sortable-hoc/style/index.js +0 -0
- package/lib/split-pane/index.d.ts +59 -0
- package/lib/split-pane/index.js +69 -0
- package/lib/split-pane/style/index.css +41 -0
- package/lib/split-pane/style/index.d.ts +1 -0
- package/lib/split-pane/style/index.js +7 -0
- package/lib/split-pane/style/index.less +49 -0
- package/lib/text-area/index.d.ts +12 -0
- package/lib/text-area/index.js +144 -0
- package/lib/text-area/style/index.d.ts +1 -0
- package/lib/text-area/style/index.js +7 -0
- package/lib/text-input/index.d.ts +5 -0
- package/lib/text-input/index.js +99 -0
- package/lib/{number-input → text-input}/style/index.css +0 -3
- package/lib/text-input/style/index.d.ts +1 -0
- package/lib/text-input/style/index.js +7 -0
- package/lib/{number-input → text-input}/style/index.less +0 -4
- package/package.json +20 -3
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
var __read = this && this.__read || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o),
|
|
5
|
+
r,
|
|
6
|
+
ar = [],
|
|
7
|
+
e;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
11
|
+
ar.push(r.value);
|
|
12
|
+
}
|
|
13
|
+
} catch (error) {
|
|
14
|
+
e = {
|
|
15
|
+
error: error
|
|
16
|
+
};
|
|
17
|
+
} finally {
|
|
18
|
+
try {
|
|
19
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
+
} finally {
|
|
21
|
+
if (e) throw e.error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var __spread = this && this.__spread || function () {
|
|
29
|
+
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
30
|
+
ar = ar.concat(__read(arguments[i]));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
36
|
+
|
|
37
|
+
/* eslint-disable no-cond-assign */
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
import getType from './getType';
|
|
41
|
+
export default function getRanges(input, highlight) {
|
|
42
|
+
var type = getType(highlight);
|
|
43
|
+
|
|
44
|
+
switch (type) {
|
|
45
|
+
case 'array':
|
|
46
|
+
return getArrayRanges(input, highlight);
|
|
47
|
+
|
|
48
|
+
case 'function':
|
|
49
|
+
return getFunctionRanges(input, highlight);
|
|
50
|
+
|
|
51
|
+
case 'regexp':
|
|
52
|
+
return getRegExpRanges(input, highlight);
|
|
53
|
+
|
|
54
|
+
case 'string':
|
|
55
|
+
return getStringRanges(input, highlight);
|
|
56
|
+
|
|
57
|
+
case 'range':
|
|
58
|
+
return getRangeRanges(highlight);
|
|
59
|
+
|
|
60
|
+
case 'custom':
|
|
61
|
+
return getCustomRanges(input, highlight);
|
|
62
|
+
|
|
63
|
+
default:
|
|
64
|
+
if (!highlight) {
|
|
65
|
+
// do nothing for falsely values
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.error('unrecognized highlight type');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getArrayRanges(input, arr) {
|
|
76
|
+
// const ranges: RangesType = arr.map(getRanges.bind(this, input));
|
|
77
|
+
var ranges = arr.map(function (highlight) {
|
|
78
|
+
return getRanges(input, highlight);
|
|
79
|
+
});
|
|
80
|
+
return Array.prototype.concat.apply([], ranges);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getFunctionRanges(input, func) {
|
|
84
|
+
return getRanges(input, func(input));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getRegExpRanges(input, regex) {
|
|
88
|
+
var ranges = [];
|
|
89
|
+
var match;
|
|
90
|
+
|
|
91
|
+
while (match = regex.exec(input), match !== null) {
|
|
92
|
+
ranges.push([match.index, match.index + match[0].length]);
|
|
93
|
+
|
|
94
|
+
if (!regex.global) {
|
|
95
|
+
// non-global regexes do not increase lastIndex, causing an infinite loop,
|
|
96
|
+
// but we can just break manually after the first match
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return ranges;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function getStringRanges(input, str) {
|
|
105
|
+
var ranges = [];
|
|
106
|
+
var inputLower = input.toLowerCase();
|
|
107
|
+
var strLower = str.toLowerCase();
|
|
108
|
+
var index = 0;
|
|
109
|
+
|
|
110
|
+
while (index = inputLower.indexOf(strLower, index), index !== -1) {
|
|
111
|
+
ranges.push([index, index + strLower.length]);
|
|
112
|
+
index += strLower.length;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return ranges;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getRangeRanges(range) {
|
|
119
|
+
return [range];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function getCustomRanges(input, custom) {
|
|
123
|
+
var ranges = getRanges(input, custom.highlight);
|
|
124
|
+
|
|
125
|
+
var resultRangesData = __spread(ranges);
|
|
126
|
+
|
|
127
|
+
if (custom.className) {
|
|
128
|
+
resultRangesData.forEach(function (range) {
|
|
129
|
+
var rangeOption = range[2] || {};
|
|
130
|
+
|
|
131
|
+
if (rangeOption.className) {
|
|
132
|
+
rangeOption.className = custom.className + " " + rangeOption.className;
|
|
133
|
+
} else {
|
|
134
|
+
rangeOption.className = custom.className;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
range[2] = rangeOption;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return ranges;
|
|
142
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default function getType(instance) {
|
|
2
|
+
var type = typeof instance;
|
|
3
|
+
|
|
4
|
+
if (!instance) {
|
|
5
|
+
return 'falsely';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (Array.isArray(instance)) {
|
|
9
|
+
if (instance.length === 2 && typeof instance[0] === 'number' && typeof instance[1] === 'number') {
|
|
10
|
+
return 'range';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return 'array';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (type === 'object') {
|
|
17
|
+
if (instance instanceof RegExp) {
|
|
18
|
+
return 'regexp';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (instance.highlight) {
|
|
22
|
+
return 'custom';
|
|
23
|
+
}
|
|
24
|
+
} else if (type === 'function' || type === 'string') {
|
|
25
|
+
return type;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return 'other';
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { HighlighedContentsProps } from './HighlighedContents';
|
|
3
|
+
import { HighlightType } from './types';
|
|
4
|
+
export interface HighlightWithinTextareaProps extends HighlighedContentsProps {
|
|
5
|
+
prefixCls?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
textAreaClassName?: string;
|
|
8
|
+
onChange?: (value: string, e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
9
|
+
highlight: HighlightType;
|
|
10
|
+
}
|
|
11
|
+
declare const HighlightWithinTextarea: React.ForwardRefExoticComponent<HighlightWithinTextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
12
|
+
export default HighlightWithinTextarea;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
|
|
6
|
+
for (var p in s) {
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
18
|
+
var t = {};
|
|
19
|
+
|
|
20
|
+
for (var p in s) {
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var __read = this && this.__read || function (o, n) {
|
|
31
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
32
|
+
if (!m) return o;
|
|
33
|
+
var i = m.call(o),
|
|
34
|
+
r,
|
|
35
|
+
ar = [],
|
|
36
|
+
e;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
40
|
+
ar.push(r.value);
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
e = {
|
|
44
|
+
error: error
|
|
45
|
+
};
|
|
46
|
+
} finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
} finally {
|
|
50
|
+
if (e) throw e.error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return ar;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
import * as React from 'react';
|
|
58
|
+
import classNames from 'classnames';
|
|
59
|
+
import trimStart from 'lodash/trimStart';
|
|
60
|
+
import useMount from 'ahooks/lib/useMount';
|
|
61
|
+
import HighlighedContents from './HighlighedContents';
|
|
62
|
+
var HighlightWithinTextarea = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
63
|
+
var prefixCls = props.prefixCls,
|
|
64
|
+
value = props.value,
|
|
65
|
+
onChange = props.onChange,
|
|
66
|
+
highlight = props.highlight,
|
|
67
|
+
className = props.className,
|
|
68
|
+
textAreaClassName = props.textAreaClassName,
|
|
69
|
+
textareaProps = __rest(props, ["prefixCls", "value", "onChange", "highlight", "className", "textAreaClassName"]);
|
|
70
|
+
|
|
71
|
+
var _a = __read(React.useState(''), 2),
|
|
72
|
+
textAreaValue = _a[0],
|
|
73
|
+
setTextAreaValue = _a[1];
|
|
74
|
+
|
|
75
|
+
var resultValue = value || textAreaValue;
|
|
76
|
+
var containerRef = React.useRef();
|
|
77
|
+
var backdropRef = React.useRef();
|
|
78
|
+
|
|
79
|
+
var handleScroll = function handleScroll() {
|
|
80
|
+
var _a;
|
|
81
|
+
|
|
82
|
+
var textareaDom = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('textarea');
|
|
83
|
+
|
|
84
|
+
if (backdropRef.current && textareaDom) {
|
|
85
|
+
backdropRef.current.scrollLeft = textareaDom.scrollLeft;
|
|
86
|
+
backdropRef.current.style.height = textareaDom.clientHeight + textareaDom.scrollTop + "px";
|
|
87
|
+
backdropRef.current.style.top = 0 - textareaDom.scrollTop + "px";
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
useMount(function () {
|
|
92
|
+
handleScroll();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
var onTextareaChange = function onTextareaChange(e) {
|
|
96
|
+
var newValue = trimStart(e.target.value);
|
|
97
|
+
|
|
98
|
+
if (onChange) {
|
|
99
|
+
onChange(newValue, e);
|
|
100
|
+
} else {
|
|
101
|
+
setTextAreaValue(newValue);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var textareaCls = classNames(prefixCls + "-input", 'highlight-textarea-input', 'highlight-content', textAreaClassName);
|
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: classNames('highlight-textarea', className),
|
|
108
|
+
ref: function ref(node) {
|
|
109
|
+
containerRef.current = node;
|
|
110
|
+
}
|
|
111
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "highlight-textarea-backdrop highlight-content",
|
|
113
|
+
ref: function ref(node) {
|
|
114
|
+
backdropRef.current = node;
|
|
115
|
+
}
|
|
116
|
+
}, /*#__PURE__*/React.createElement(HighlighedContents, {
|
|
117
|
+
value: resultValue,
|
|
118
|
+
highlight: highlight
|
|
119
|
+
})), /*#__PURE__*/React.createElement("textarea", __assign({
|
|
120
|
+
value: resultValue,
|
|
121
|
+
onChange: onTextareaChange,
|
|
122
|
+
className: textareaCls
|
|
123
|
+
}, textareaProps, {
|
|
124
|
+
onScroll: handleScroll,
|
|
125
|
+
ref: ref
|
|
126
|
+
})));
|
|
127
|
+
});
|
|
128
|
+
HighlightWithinTextarea.defaultProps = {
|
|
129
|
+
highlight: '',
|
|
130
|
+
prefixCls: 'ant'
|
|
131
|
+
};
|
|
132
|
+
export default HighlightWithinTextarea;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.highlight-textarea {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100px;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
-webkit-text-size-adjust: none;
|
|
8
|
+
}
|
|
9
|
+
.highlight-textarea-backdrop {
|
|
10
|
+
overflow-x: hidden;
|
|
11
|
+
overflow-y: scroll;
|
|
12
|
+
color: transparent;
|
|
13
|
+
white-space: pre-wrap;
|
|
14
|
+
word-wrap: break-word;
|
|
15
|
+
border: 1px solid;
|
|
16
|
+
border-color: transparent;
|
|
17
|
+
}
|
|
18
|
+
.highlight-textarea-input.highlight-content {
|
|
19
|
+
z-index: 100;
|
|
20
|
+
overflow-x: hidden;
|
|
21
|
+
overflow-y: scroll;
|
|
22
|
+
font: inherit;
|
|
23
|
+
resize: none;
|
|
24
|
+
}
|
|
25
|
+
.highlight-textarea .highlight-content {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 0;
|
|
28
|
+
right: 0;
|
|
29
|
+
bottom: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
padding: 2px 5px 0 5px;
|
|
32
|
+
background: none transparent !important;
|
|
33
|
+
}
|
|
34
|
+
.highlight-textarea .highlight-content mark {
|
|
35
|
+
padding: 0;
|
|
36
|
+
color: inherit;
|
|
37
|
+
background-color: #a3daff;
|
|
38
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.highlight-textarea {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100px;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
-webkit-text-size-adjust: none;
|
|
8
|
+
|
|
9
|
+
&-backdrop {
|
|
10
|
+
overflow-x: hidden;
|
|
11
|
+
overflow-y: scroll;
|
|
12
|
+
color: transparent;
|
|
13
|
+
white-space: pre-wrap;
|
|
14
|
+
word-wrap: break-word;
|
|
15
|
+
border: 1px solid;
|
|
16
|
+
border-color: transparent;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-input.highlight-content {
|
|
20
|
+
z-index: 100;
|
|
21
|
+
overflow-x: hidden;
|
|
22
|
+
overflow-y: scroll;
|
|
23
|
+
font: inherit;
|
|
24
|
+
resize: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.highlight-content {
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: 0;
|
|
30
|
+
right: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
padding: 2px 5px 0 5px;
|
|
34
|
+
background: none transparent !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.highlight-content mark {
|
|
38
|
+
padding: 0;
|
|
39
|
+
color: inherit;
|
|
40
|
+
background-color: #a3daff;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare type StringType = string;
|
|
2
|
+
export declare type NumberArrayType = number[];
|
|
3
|
+
export declare type RegExpType = RegExp;
|
|
4
|
+
export declare type FuncType = (input: string) => string;
|
|
5
|
+
export declare type HighlightInstanceType = StringType | NumberArrayType | RegExpType | FuncType;
|
|
6
|
+
export declare type AdmixArrayType = HighlightInstanceType[];
|
|
7
|
+
export declare type ObjectType = {
|
|
8
|
+
highlight: HighlightInstanceType;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type CustomArrayArrayType = ObjectType[];
|
|
12
|
+
export declare type RangesType = (number | {
|
|
13
|
+
className?: string;
|
|
14
|
+
})[][];
|
|
15
|
+
export declare type HighlightType = StringType | NumberArrayType | RegExpType | FuncType | HighlightInstanceType | AdmixArrayType | ObjectType | CustomArrayArrayType;
|
|
16
|
+
export declare type TypeList = 'falsely' | 'range' | 'array' | 'regexp' | 'custom' | 'other' | 'function' | 'string';
|
|
File without changes
|