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,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
"default": mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var react_1 = __importDefault(require("react"));
|
|
14
|
+
|
|
15
|
+
var getRanges_1 = __importDefault(require("./getRanges"));
|
|
16
|
+
|
|
17
|
+
var extractSpansOfClasses_1 = __importDefault(require("./extractSpansOfClasses"));
|
|
18
|
+
|
|
19
|
+
var HighlighedContents = function HighlighedContents(_a) {
|
|
20
|
+
var value = _a.value,
|
|
21
|
+
highlight = _a.highlight;
|
|
22
|
+
var ranges = getRanges_1["default"](value, highlight);
|
|
23
|
+
var parts = extractSpansOfClasses_1["default"](value, ranges);
|
|
24
|
+
return react_1["default"].createElement(react_1["default"].Fragment, null, parts.map(function (part) {
|
|
25
|
+
return part.render();
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports["default"] = HighlighedContents;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RangesType } from './types';
|
|
2
|
+
declare class Span {
|
|
3
|
+
beginIndex: number;
|
|
4
|
+
endIndex: number;
|
|
5
|
+
markClasses: Set<string>;
|
|
6
|
+
isMark: boolean;
|
|
7
|
+
text: string;
|
|
8
|
+
constructor(text: string, beginIndex: number);
|
|
9
|
+
setMark(className: string): void;
|
|
10
|
+
carve(beginIndex2: number): Span;
|
|
11
|
+
get className(): string;
|
|
12
|
+
render(): JSX.Element;
|
|
13
|
+
}
|
|
14
|
+
export default function extractSpansOfClasses(value: string, ranges: RangesType): Span[];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
13
|
+
ar.push(r.value);
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
e = {
|
|
17
|
+
error: error
|
|
18
|
+
};
|
|
19
|
+
} finally {
|
|
20
|
+
try {
|
|
21
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
22
|
+
} finally {
|
|
23
|
+
if (e) throw e.error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var __spread = this && this.__spread || function () {
|
|
31
|
+
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
32
|
+
ar = ar.concat(__read(arguments[i]));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
39
|
+
return mod && mod.__esModule ? mod : {
|
|
40
|
+
"default": mod
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Object.defineProperty(exports, "__esModule", {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
var react_1 = __importDefault(require("react"));
|
|
49
|
+
|
|
50
|
+
var Span = function () {
|
|
51
|
+
function Span(text, beginIndex) {
|
|
52
|
+
this.beginIndex = beginIndex;
|
|
53
|
+
this.endIndex = beginIndex + text.length;
|
|
54
|
+
this.text = text;
|
|
55
|
+
this.isMark = false;
|
|
56
|
+
this.markClasses = new Set();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Span.prototype.setMark = function (className) {
|
|
60
|
+
var _this = this;
|
|
61
|
+
|
|
62
|
+
this.isMark = true;
|
|
63
|
+
|
|
64
|
+
if (className) {
|
|
65
|
+
className.split(' ').forEach(function (cls) {
|
|
66
|
+
_this.markClasses.add(cls);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
Span.prototype.carve = function (beginIndex2) {
|
|
72
|
+
var rightText = this.text.slice(beginIndex2 - this.beginIndex);
|
|
73
|
+
this.text = this.text.slice(0, beginIndex2 - this.beginIndex);
|
|
74
|
+
this.endIndex = beginIndex2;
|
|
75
|
+
var right = new Span(rightText, beginIndex2);
|
|
76
|
+
right.isMark = this.isMark;
|
|
77
|
+
right.markClasses = new Set(__spread(this.markClasses));
|
|
78
|
+
return right;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
Object.defineProperty(Span.prototype, "className", {
|
|
82
|
+
get: function get() {
|
|
83
|
+
if (this.markClasses && this.markClasses.size > 0) {
|
|
84
|
+
return __spread(this.markClasses).sort().join(' ');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return '';
|
|
88
|
+
},
|
|
89
|
+
enumerable: false,
|
|
90
|
+
configurable: true
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
Span.prototype.render = function () {
|
|
94
|
+
if (this.isMark) {
|
|
95
|
+
var className = this.className;
|
|
96
|
+
|
|
97
|
+
if (className) {
|
|
98
|
+
return react_1["default"].createElement("mark", {
|
|
99
|
+
key: this.beginIndex,
|
|
100
|
+
className: className
|
|
101
|
+
}, this.text);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return react_1["default"].createElement("mark", {
|
|
105
|
+
key: this.beginIndex
|
|
106
|
+
}, this.text);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return react_1["default"].createElement("span", {
|
|
110
|
+
key: this.beginIndex
|
|
111
|
+
}, this.text);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return Span;
|
|
115
|
+
}();
|
|
116
|
+
|
|
117
|
+
function extractSpansOfClasses(value, ranges) {
|
|
118
|
+
var spans = [new Span(value, 0)];
|
|
119
|
+
ranges.forEach(function (range) {
|
|
120
|
+
var beginIndex = range[0];
|
|
121
|
+
var endIndex = range[1];
|
|
122
|
+
var rangeOption = range[2];
|
|
123
|
+
var _a = (rangeOption || {}).className,
|
|
124
|
+
className = _a === void 0 ? '' : _a;
|
|
125
|
+
|
|
126
|
+
for (var i = 0; i < spans.length; i++) {
|
|
127
|
+
var span = spans[i]; // since spans are sorted, So this is always true: beginIndex >= span.beginIndex.
|
|
128
|
+
|
|
129
|
+
if (beginIndex < span.endIndex) {
|
|
130
|
+
if (beginIndex === span.beginIndex) {
|
|
131
|
+
if (endIndex < span.endIndex) {
|
|
132
|
+
// [range]
|
|
133
|
+
// [s p a n]
|
|
134
|
+
var span2 = span.carve(endIndex);
|
|
135
|
+
span.setMark(className);
|
|
136
|
+
spans.splice(i + 1, 0, span2);
|
|
137
|
+
beginIndex = endIndex;
|
|
138
|
+
i += 1;
|
|
139
|
+
} else {
|
|
140
|
+
// [range] or [r a n g e]
|
|
141
|
+
// [span-] [span]
|
|
142
|
+
span.setMark(className);
|
|
143
|
+
beginIndex = span.endIndex;
|
|
144
|
+
}
|
|
145
|
+
} else if (endIndex < span.endIndex) {
|
|
146
|
+
// [range]
|
|
147
|
+
// [s p a n]
|
|
148
|
+
var span2 = span.carve(beginIndex);
|
|
149
|
+
var span3 = span2.carve(endIndex);
|
|
150
|
+
span2.setMark(className);
|
|
151
|
+
spans.splice(i + 1, 0, span2, span3);
|
|
152
|
+
beginIndex = endIndex;
|
|
153
|
+
i += 2;
|
|
154
|
+
} else {
|
|
155
|
+
// [range] or [range]
|
|
156
|
+
// [s p a n] [span]
|
|
157
|
+
var span2 = span.carve(beginIndex);
|
|
158
|
+
span2.setMark(className);
|
|
159
|
+
spans.splice(i + 1, 0, span2);
|
|
160
|
+
beginIndex = span2.endIndex;
|
|
161
|
+
i += 1;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (beginIndex === endIndex) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
return spans;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
exports["default"] = extractSpansOfClasses;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
13
|
+
ar.push(r.value);
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
e = {
|
|
17
|
+
error: error
|
|
18
|
+
};
|
|
19
|
+
} finally {
|
|
20
|
+
try {
|
|
21
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
22
|
+
} finally {
|
|
23
|
+
if (e) throw e.error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var __spread = this && this.__spread || function () {
|
|
31
|
+
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
32
|
+
ar = ar.concat(__read(arguments[i]));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
39
|
+
return mod && mod.__esModule ? mod : {
|
|
40
|
+
"default": mod
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Object.defineProperty(exports, "__esModule", {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
|
47
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
48
|
+
|
|
49
|
+
/* eslint-disable no-cond-assign */
|
|
50
|
+
|
|
51
|
+
var getType_1 = __importDefault(require("./getType"));
|
|
52
|
+
|
|
53
|
+
function getRanges(input, highlight) {
|
|
54
|
+
var type = getType_1["default"](highlight);
|
|
55
|
+
|
|
56
|
+
switch (type) {
|
|
57
|
+
case 'array':
|
|
58
|
+
return getArrayRanges(input, highlight);
|
|
59
|
+
|
|
60
|
+
case 'function':
|
|
61
|
+
return getFunctionRanges(input, highlight);
|
|
62
|
+
|
|
63
|
+
case 'regexp':
|
|
64
|
+
return getRegExpRanges(input, highlight);
|
|
65
|
+
|
|
66
|
+
case 'string':
|
|
67
|
+
return getStringRanges(input, highlight);
|
|
68
|
+
|
|
69
|
+
case 'range':
|
|
70
|
+
return getRangeRanges(highlight);
|
|
71
|
+
|
|
72
|
+
case 'custom':
|
|
73
|
+
return getCustomRanges(input, highlight);
|
|
74
|
+
|
|
75
|
+
default:
|
|
76
|
+
if (!highlight) {
|
|
77
|
+
// do nothing for falsely values
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.error('unrecognized highlight type');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
exports["default"] = getRanges;
|
|
88
|
+
|
|
89
|
+
function getArrayRanges(input, arr) {
|
|
90
|
+
// const ranges: RangesType = arr.map(getRanges.bind(this, input));
|
|
91
|
+
var ranges = arr.map(function (highlight) {
|
|
92
|
+
return getRanges(input, highlight);
|
|
93
|
+
});
|
|
94
|
+
return Array.prototype.concat.apply([], ranges);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getFunctionRanges(input, func) {
|
|
98
|
+
return getRanges(input, func(input));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function getRegExpRanges(input, regex) {
|
|
102
|
+
var ranges = [];
|
|
103
|
+
var match;
|
|
104
|
+
|
|
105
|
+
while (match = regex.exec(input), match !== null) {
|
|
106
|
+
ranges.push([match.index, match.index + match[0].length]);
|
|
107
|
+
|
|
108
|
+
if (!regex.global) {
|
|
109
|
+
// non-global regexes do not increase lastIndex, causing an infinite loop,
|
|
110
|
+
// but we can just break manually after the first match
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return ranges;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getStringRanges(input, str) {
|
|
119
|
+
var ranges = [];
|
|
120
|
+
var inputLower = input.toLowerCase();
|
|
121
|
+
var strLower = str.toLowerCase();
|
|
122
|
+
var index = 0;
|
|
123
|
+
|
|
124
|
+
while (index = inputLower.indexOf(strLower, index), index !== -1) {
|
|
125
|
+
ranges.push([index, index + strLower.length]);
|
|
126
|
+
index += strLower.length;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return ranges;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function getRangeRanges(range) {
|
|
133
|
+
return [range];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function getCustomRanges(input, custom) {
|
|
137
|
+
var ranges = getRanges(input, custom.highlight);
|
|
138
|
+
|
|
139
|
+
var resultRangesData = __spread(ranges);
|
|
140
|
+
|
|
141
|
+
if (custom.className) {
|
|
142
|
+
resultRangesData.forEach(function (range) {
|
|
143
|
+
var rangeOption = range[2] || {};
|
|
144
|
+
|
|
145
|
+
if (rangeOption.className) {
|
|
146
|
+
rangeOption.className = custom.className + " " + rangeOption.className;
|
|
147
|
+
} else {
|
|
148
|
+
rangeOption.className = custom.className;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
range[2] = rangeOption;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return ranges;
|
|
156
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
function getType(instance) {
|
|
8
|
+
var type = typeof instance;
|
|
9
|
+
|
|
10
|
+
if (!instance) {
|
|
11
|
+
return 'falsely';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (Array.isArray(instance)) {
|
|
15
|
+
if (instance.length === 2 && typeof instance[0] === 'number' && typeof instance[1] === 'number') {
|
|
16
|
+
return 'range';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return 'array';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (type === 'object') {
|
|
23
|
+
if (instance instanceof RegExp) {
|
|
24
|
+
return 'regexp';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (instance.highlight) {
|
|
28
|
+
return 'custom';
|
|
29
|
+
}
|
|
30
|
+
} else if (type === 'function' || type === 'string') {
|
|
31
|
+
return type;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return 'other';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports["default"] = getType;
|
|
@@ -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,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
|
|
8
|
+
for (var p in s) {
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return t;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return __assign.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
Object.defineProperty(o, k2, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return m[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
} : function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
value: v
|
|
36
|
+
});
|
|
37
|
+
} : function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
var __importStar = this && this.__importStar || function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k in mod) {
|
|
45
|
+
if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
54
|
+
var t = {};
|
|
55
|
+
|
|
56
|
+
for (var p in s) {
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
61
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
62
|
+
}
|
|
63
|
+
return t;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var __read = this && this.__read || function (o, n) {
|
|
67
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
68
|
+
if (!m) return o;
|
|
69
|
+
var i = m.call(o),
|
|
70
|
+
r,
|
|
71
|
+
ar = [],
|
|
72
|
+
e;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
76
|
+
ar.push(r.value);
|
|
77
|
+
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
e = {
|
|
80
|
+
error: error
|
|
81
|
+
};
|
|
82
|
+
} finally {
|
|
83
|
+
try {
|
|
84
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
85
|
+
} finally {
|
|
86
|
+
if (e) throw e.error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return ar;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
94
|
+
return mod && mod.__esModule ? mod : {
|
|
95
|
+
"default": mod
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
Object.defineProperty(exports, "__esModule", {
|
|
100
|
+
value: true
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
var React = __importStar(require("react"));
|
|
104
|
+
|
|
105
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
106
|
+
|
|
107
|
+
var trimStart_1 = __importDefault(require("lodash/trimStart"));
|
|
108
|
+
|
|
109
|
+
var useMount_1 = __importDefault(require("ahooks/lib/useMount"));
|
|
110
|
+
|
|
111
|
+
var HighlighedContents_1 = __importDefault(require("./HighlighedContents"));
|
|
112
|
+
|
|
113
|
+
var HighlightWithinTextarea = React.forwardRef(function (props, ref) {
|
|
114
|
+
var prefixCls = props.prefixCls,
|
|
115
|
+
value = props.value,
|
|
116
|
+
onChange = props.onChange,
|
|
117
|
+
highlight = props.highlight,
|
|
118
|
+
className = props.className,
|
|
119
|
+
textAreaClassName = props.textAreaClassName,
|
|
120
|
+
textareaProps = __rest(props, ["prefixCls", "value", "onChange", "highlight", "className", "textAreaClassName"]);
|
|
121
|
+
|
|
122
|
+
var _a = __read(React.useState(''), 2),
|
|
123
|
+
textAreaValue = _a[0],
|
|
124
|
+
setTextAreaValue = _a[1];
|
|
125
|
+
|
|
126
|
+
var resultValue = value || textAreaValue;
|
|
127
|
+
var containerRef = React.useRef();
|
|
128
|
+
var backdropRef = React.useRef();
|
|
129
|
+
|
|
130
|
+
var handleScroll = function handleScroll() {
|
|
131
|
+
var _a;
|
|
132
|
+
|
|
133
|
+
var textareaDom = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('textarea');
|
|
134
|
+
|
|
135
|
+
if (backdropRef.current && textareaDom) {
|
|
136
|
+
backdropRef.current.scrollLeft = textareaDom.scrollLeft;
|
|
137
|
+
backdropRef.current.style.height = textareaDom.clientHeight + textareaDom.scrollTop + "px";
|
|
138
|
+
backdropRef.current.style.top = 0 - textareaDom.scrollTop + "px";
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
useMount_1["default"](function () {
|
|
143
|
+
handleScroll();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
var onTextareaChange = function onTextareaChange(e) {
|
|
147
|
+
var newValue = trimStart_1["default"](e.target.value);
|
|
148
|
+
|
|
149
|
+
if (onChange) {
|
|
150
|
+
onChange(newValue, e);
|
|
151
|
+
} else {
|
|
152
|
+
setTextAreaValue(newValue);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
var textareaCls = classnames_1["default"](prefixCls + "-input", 'highlight-textarea-input', 'highlight-content', textAreaClassName);
|
|
157
|
+
return React.createElement("div", {
|
|
158
|
+
className: classnames_1["default"]('highlight-textarea', className),
|
|
159
|
+
ref: function ref(node) {
|
|
160
|
+
containerRef.current = node;
|
|
161
|
+
}
|
|
162
|
+
}, React.createElement("div", {
|
|
163
|
+
className: "highlight-textarea-backdrop highlight-content",
|
|
164
|
+
ref: function ref(node) {
|
|
165
|
+
backdropRef.current = node;
|
|
166
|
+
}
|
|
167
|
+
}, React.createElement(HighlighedContents_1["default"], {
|
|
168
|
+
value: resultValue,
|
|
169
|
+
highlight: highlight
|
|
170
|
+
})), React.createElement("textarea", __assign({
|
|
171
|
+
value: resultValue,
|
|
172
|
+
onChange: onTextareaChange,
|
|
173
|
+
className: textareaCls
|
|
174
|
+
}, textareaProps, {
|
|
175
|
+
onScroll: handleScroll,
|
|
176
|
+
ref: ref
|
|
177
|
+
})));
|
|
178
|
+
});
|
|
179
|
+
HighlightWithinTextarea.defaultProps = {
|
|
180
|
+
highlight: '',
|
|
181
|
+
prefixCls: 'ant'
|
|
182
|
+
};
|
|
183
|
+
exports["default"] = HighlightWithinTextarea;
|