mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 17:51:46 +00:00
[react-highlight-words] - update tests and fix default export
This commit is contained in:
+35
-14
@@ -1,34 +1,55 @@
|
||||
// Type definitions for react-highlight-words 0.6
|
||||
// Type definitions for react-highlight-words 0.11
|
||||
// Project: https://github.com/bvaughn/react-highlight-words#readme
|
||||
// Definitions by: Mohamed Hegazy <https://github.com/mhegazy>
|
||||
// Diogo Corrêa <https://github.com/diogodca>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export = Highlighter;
|
||||
|
||||
interface HighlighterProps {
|
||||
/** Escape characters which are meaningful in regular expressions */
|
||||
autoEscape?: boolean;
|
||||
/** Escape characters which are meaningful in regular expressions */
|
||||
/** The class name to be applied to an active match. Use along with activeIndex */
|
||||
activeClassName?: string;
|
||||
/** Specify the match index that should be actively highlighted. Use along with activeClassName */
|
||||
activeIndex?: string;
|
||||
/** The inline style to be applied to an active match. Use along with activeIndex */
|
||||
activeStyle?: React.CSSProperties;
|
||||
/** Escape characters in searchWords which are meaningful in regular expressions */
|
||||
autoEscape?: boolean;
|
||||
/** CSS class name applied to the outer/wrapper <span> */
|
||||
className?: string;
|
||||
/** Search should be case sensitive; defaults to false */
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
* Use a custom function to search for matching chunks. This makes it possible to use arbitrary logic
|
||||
* when looking for matches. See the default findChunks function in highlight-words-core for signature.
|
||||
* Have a look at the custom findChunks example on how to use it.
|
||||
*/
|
||||
findChunks?: () => void;
|
||||
/** CSS class name applied to highlighted text */
|
||||
highlightClassName?: string;
|
||||
/** Inline styles applied to highlighted text */
|
||||
highlightStyle?: any;
|
||||
/** Type of tag to wrap around highlighted matches; defaults to mark */
|
||||
highlightStyle?: React.CSSProperties;
|
||||
/**
|
||||
* Type of tag to wrap around highlighted matches; defaults to mark but can also be a React element
|
||||
* (class or functional)
|
||||
*/
|
||||
highlightTag?: string;
|
||||
/** Process each search word and text to highlight before comparing (eg remove accents); signature (text: string): string */
|
||||
sanitize?(text: string): string;
|
||||
/** Array of search words */
|
||||
/**
|
||||
* Process each search word and text to highlight before comparing (eg remove accents); signature
|
||||
* (text: string): string
|
||||
*/
|
||||
sanitize?: (text: string) => string;
|
||||
/** Array of search words. The search terms are treated as RegExps unless autoEscape is set. */
|
||||
searchWords: string[];
|
||||
/** Text to highlight matches in */
|
||||
textToHighlight: string;
|
||||
/** CSS class name applied to unhighlighted text */
|
||||
unhighlightClassName?: string;
|
||||
/** Inline styles applied to unhighlighted text */
|
||||
unhighlightStyle?: React.CSSProperties;
|
||||
}
|
||||
|
||||
declare class Highlighter extends React.Component<HighlighterProps> {
|
||||
static propTypes: any;
|
||||
}
|
||||
declare class Highlighter extends React.Component<HighlighterProps> {}
|
||||
|
||||
export default Highlighter;
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
import * as React from "react";
|
||||
import Highlighter = require("react-highlight-words");
|
||||
import Highlighter from "react-highlight-words";
|
||||
|
||||
<Highlighter
|
||||
highlightClassName='YourHighlightClass'
|
||||
searchWords={['and', 'or', 'the']}
|
||||
textToHighlight="The dog is chasing the cat. Or perhaps they're just playing?"
|
||||
/>;
|
||||
class HighlighterTest extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Highlighter
|
||||
searchWords={["el", "or"]}
|
||||
textToHighlight="Hello World"
|
||||
/>
|
||||
<Highlighter
|
||||
activeClassName="activeClassName"
|
||||
activeIndex="activeIndex"
|
||||
activeStyle={{ color: "red" }}
|
||||
autoEscape={true}
|
||||
className="className"
|
||||
caseSensitive={true}
|
||||
findChunks={() => {}}
|
||||
highlightClassName="highlightClassName"
|
||||
highlightStyle={{ color: "red" }}
|
||||
highlightTag="span"
|
||||
sanitize={(text: string) => text}
|
||||
searchWords={["el", "or"]}
|
||||
textToHighlight="Hello World"
|
||||
unhighlightClassName="unhighlightClassName"
|
||||
unhighlightStyle={{ color: "red" }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-highlight-words-tests.tsx"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"jsx": "react",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
@@ -14,12 +19,7 @@
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"jsx": "react",
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-highlight-words-tests.tsx"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user