@vertigis/react-ui 11.25.0 → 11.26.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.
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ export declare const highlightOptionClasses: {
3
+ highlight: string;
4
+ };
5
+ interface HighlightOptionProps extends React.HTMLAttributes<HTMLLIElement> {
6
+ /**
7
+ * The text that has been typed by the user.
8
+ */
9
+ inputText: string;
10
+ /**
11
+ * The label of the option being rendered.
12
+ */
13
+ optionText: string;
14
+ }
15
+ declare const HighlightOption: (props: HighlightOptionProps) => JSX.Element;
16
+ export default HighlightOption;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import match from "autosuggest-highlight/match";
3
+ import parse from "autosuggest-highlight/parse";
4
+ import { styled } from "../styles/index.js";
5
+ const PREFIX = "GcxHighlightOption";
6
+ export const highlightOptionClasses = {
7
+ highlight: `${PREFIX}-highlight`,
8
+ };
9
+ const Part = styled("span")(({ theme }) => ({
10
+ whiteSpace: "pre-wrap",
11
+ [`&.${highlightOptionClasses.highlight}`]: {
12
+ fontWeight: theme.typography.fontWeightBold,
13
+ },
14
+ }));
15
+ const HighlightOption = (props) => {
16
+ const { inputText, optionText, ...other } = props;
17
+ const matches = match(optionText, inputText, { insideWords: true });
18
+ const parts = parse(optionText, matches);
19
+ return (_jsx("li", { ...other, children: parts.map((part, index) => (_jsx(Part, { className: part.highlight ? highlightOptionClasses.highlight : undefined, children: part.text }, index))) }));
20
+ };
21
+ export default HighlightOption;
@@ -1,2 +1,3 @@
1
1
  export { default } from "@mui/material/Autocomplete";
2
2
  export * from "@mui/material/Autocomplete";
3
+ export { default as HighlightOption } from "./HighlightOption.js";
@@ -1,2 +1,3 @@
1
1
  export { default } from "@mui/material/Autocomplete";
2
2
  export * from "@mui/material/Autocomplete";
3
+ export { default as HighlightOption } from "./HighlightOption.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertigis/react-ui",
3
- "version": "11.25.0",
3
+ "version": "11.26.1",
4
4
  "description": "Utilities and React components used in VertiGIS applications.",
5
5
  "keywords": [
6
6
  "vertigis",
@@ -22,6 +22,7 @@
22
22
  "@mui/material": "5.11.12",
23
23
  "@mui/x-data-grid-pro": "5.17.22",
24
24
  "@mui/x-date-pickers-pro": "5.0.17",
25
+ "autosuggest-highlight": "^3.3.4",
25
26
  "clsx": "^1.2.1",
26
27
  "color": "^4.2.3",
27
28
  "lodash.escape": "^4.0.1",
@@ -33,6 +34,7 @@
33
34
  },
34
35
  "devDependencies": {
35
36
  "@esri/arcgis-html-sanitizer": "^3.0.1",
37
+ "@types/autosuggest-highlight": "^3.2.0",
36
38
  "@types/color": "^3.0.1",
37
39
  "@types/lodash.escape": "^4.0.1",
38
40
  "@types/lodash.merge": "^4.6.7",