@opengeoweb/shared 4.20.0 → 4.21.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.
package/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { useRef } from 'react';
3
3
  import { Box, Typography, Tooltip, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress, Alert, AlertTitle, useTheme, Drawer, Link, Avatar as Avatar$1, Paper, ClickAwayListener, MenuList, MenuItem, Grid, RadioGroup, FormControlLabel, Radio, List, ListItem, Tabs, Tab, Backdrop, Slider, ToggleButton, Menu, ListSubheader, ListItemIcon, Select, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
4
4
  import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, HamburgerMenu, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, ChevronDown } from '@opengeoweb/theme';
5
- import { throttle } from 'lodash';
5
+ import { throttle, escapeRegExp } from 'lodash';
6
6
  import Draggable from 'react-draggable';
7
7
  import { Resizable } from 're-resizable';
8
8
  import { useStore } from 'react-redux';
@@ -3148,6 +3148,44 @@ var CustomAccordion = function CustomAccordion(_a) {
3148
3148
  }, children));
3149
3149
  };
3150
3150
 
3151
+ var highlightStyle = {
3152
+ background: '#ffeecc'
3153
+ };
3154
+
3155
+ var SearchHighlight = function SearchHighlight(_ref) {
3156
+ var _ref$text = _ref.text,
3157
+ text = _ref$text === void 0 ? '' : _ref$text,
3158
+ search = _ref.search;
3159
+
3160
+ if (search === '') {
3161
+ return /*#__PURE__*/React__default.createElement("span", null, text);
3162
+ }
3163
+
3164
+ var searchWords = search.split(' ').reduce(function (words, word) {
3165
+ return word ? [].concat(_toConsumableArray(words), [word.toLocaleLowerCase()]) : words;
3166
+ }, []);
3167
+ var searchRegex = searchWords.map(function (word) {
3168
+ return escapeRegExp(word);
3169
+ }).join('|');
3170
+ var textParts = text.split(new RegExp("(".concat(searchRegex, ")"), 'gi'));
3171
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, textParts.map(function (part, index) {
3172
+ var key = "".concat(part, "-").concat(index);
3173
+
3174
+ if (searchWords.some(function (search) {
3175
+ return part.toLocaleLowerCase().includes(search);
3176
+ })) {
3177
+ return /*#__PURE__*/React__default.createElement("mark", {
3178
+ key: key,
3179
+ style: highlightStyle
3180
+ }, part);
3181
+ }
3182
+
3183
+ return /*#__PURE__*/React__default.createElement("span", {
3184
+ key: key
3185
+ }, part);
3186
+ }));
3187
+ };
3188
+
3151
3189
  /* *
3152
3190
  * Licensed under the Apache License, Version 2.0 (the "License");
3153
3191
  * you may not use this file except in compliance with the License.
@@ -3497,4 +3535,4 @@ var index = /*#__PURE__*/Object.freeze({
3497
3535
  differenceInHours: differenceInHours
3498
3536
  });
3499
3537
 
3500
- export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, ErrorBoundary, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
3538
+ export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, ErrorBoundary, ResizeComponent as Resizable, SearchHighlight, StatusTag, ToggleMenu, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
package/index.umd.js CHANGED
@@ -3052,6 +3052,60 @@
3052
3052
  }, children));
3053
3053
  };
3054
3054
 
3055
+ /* *
3056
+ * Licensed under the Apache License, Version 2.0 (the "License");
3057
+ * you may not use this file except in compliance with the License.
3058
+ * You may obtain a copy of the License at
3059
+ *
3060
+ * http://www.apache.org/licenses/LICENSE-2.0
3061
+ *
3062
+ * Unless required by applicable law or agreed to in writing, software
3063
+ * distributed under the License is distributed on an "AS IS" BASIS,
3064
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3065
+ * See the License for the specific language governing permissions and
3066
+ * limitations under the License.
3067
+ *
3068
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3069
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
3070
+ * */
3071
+ var highlightStyle = {
3072
+ background: '#ffeecc'
3073
+ };
3074
+
3075
+ var SearchHighlight = function SearchHighlight(_a) {
3076
+ var _b = _a.text,
3077
+ text = _b === void 0 ? '' : _b,
3078
+ search = _a.search;
3079
+
3080
+ if (search === '') {
3081
+ return /*#__PURE__*/React__default["default"].createElement("span", null, text);
3082
+ }
3083
+
3084
+ var searchWords = search.split(' ').reduce(function (words, word) {
3085
+ return word ? __spreadArray(__spreadArray([], __read(words)), [word.toLocaleLowerCase()]) : words;
3086
+ }, []);
3087
+ var searchRegex = searchWords.map(function (word) {
3088
+ return lodash.escapeRegExp(word);
3089
+ }).join('|');
3090
+ var textParts = text.split(new RegExp("(" + searchRegex + ")", 'gi'));
3091
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, textParts.map(function (part, index) {
3092
+ var key = part + "-" + index;
3093
+
3094
+ if (searchWords.some(function (search) {
3095
+ return part.toLocaleLowerCase().includes(search);
3096
+ })) {
3097
+ return /*#__PURE__*/React__default["default"].createElement("mark", {
3098
+ key: key,
3099
+ style: highlightStyle
3100
+ }, part);
3101
+ }
3102
+
3103
+ return /*#__PURE__*/React__default["default"].createElement("span", {
3104
+ key: key
3105
+ }, part);
3106
+ }));
3107
+ };
3108
+
3055
3109
  /* *
3056
3110
  * Licensed under the Apache License, Version 2.0 (the "License");
3057
3111
  * you may not use this file except in compliance with the License.
@@ -3442,6 +3496,7 @@
3442
3496
  exports.Draggable = DraggableComponent$1;
3443
3497
  exports.ErrorBoundary = ErrorBoundary;
3444
3498
  exports.Resizable = ResizeComponent;
3499
+ exports.SearchHighlight = SearchHighlight;
3445
3500
  exports.StatusTag = StatusTag;
3446
3501
  exports.ToggleMenu = ToggleMenu;
3447
3502
  exports.ToolContainer = ToolContainer;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface HighlightProps {
3
+ text: string;
4
+ search: string;
5
+ }
6
+ declare const SearchHighlight: React.FC<HighlightProps>;
7
+ export default SearchHighlight;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const SearchHighlightLightTheme: {
7
+ (): React.ReactElement;
8
+ storyName: string;
9
+ };
10
+ export declare const SearchHighlightDarkTheme: {
11
+ (): React.ReactElement;
12
+ storyName: string;
13
+ };
@@ -0,0 +1 @@
1
+ export { default as SearchHighlight } from './SearchHighlight';
@@ -18,3 +18,4 @@ export * from './CustomTooltip';
18
18
  export * from './CustomAccordion';
19
19
  export * from './CustomDialog';
20
20
  export * from './CustomIconButton';
21
+ export * from './SearchHighlight';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/shared",
3
- "version": "4.20.0",
3
+ "version": "4.21.0",
4
4
  "description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,14 +14,14 @@
14
14
  "peerDependencies": {
15
15
  "react": "^18.2.0",
16
16
  "@mui/material": "^5.12.0",
17
- "@opengeoweb/theme": "4.20.0",
17
+ "@opengeoweb/theme": "4.21.0",
18
18
  "@mui/system": "^5.12.0",
19
19
  "@mui/x-date-pickers": "^6.2.1",
20
20
  "react-draggable": "^4.4.5",
21
21
  "re-resizable": "^6.9.0",
22
+ "lodash": "^4.17.20",
22
23
  "@redux-eggs/core": "^2.2.0",
23
24
  "react-redux": "^8.0.4",
24
- "lodash": "^4.17.20",
25
25
  "axios": "^0.25.0",
26
26
  "date-fns": "^2.29.3"
27
27
  }