@tecsinapse/react-web-kit 3.4.7 → 3.4.9

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.
@@ -14,7 +14,7 @@ var useClickAwayListener = require('../../../hooks/useClickAwayListener.js');
14
14
  const Menubar = ({
15
15
  leftComponents,
16
16
  rightComponents,
17
- searchPlaceholder = "O qu\xEA voc\xEA deseja buscar?",
17
+ searchPlaceholder = "O que voc\xEA deseja buscar?",
18
18
  options,
19
19
  mostUsed,
20
20
  mostUsedLabel = "Mais acessados",
@@ -69,29 +69,38 @@ const Menubar = ({
69
69
  onChange: setInput
70
70
  }
71
71
  )
72
- )), rightComponents), /* @__PURE__ */ React.createElement(reactTransitionGroup.Transition, { in: open, timeout: 250, nodeRef: transitionMenuRef }, (state) => /* @__PURE__ */ React.createElement(
73
- styled.StyledContainerOpenMenu,
72
+ )), rightComponents), /* @__PURE__ */ React.createElement(
73
+ reactTransitionGroup.Transition,
74
74
  {
75
- style: animations.getContainerOpenMenuStyles(state),
76
- ref: transitionMenuRef
75
+ in: open,
76
+ timeout: 250,
77
+ nodeRef: transitionMenuRef,
78
+ unmountOnExit: true
77
79
  },
78
- !search ? /* @__PURE__ */ React.createElement(React.Fragment, null, mostUsed && /* @__PURE__ */ React.createElement(
79
- MostUsed,
80
+ (state) => /* @__PURE__ */ React.createElement(
81
+ styled.StyledContainerOpenMenu,
80
82
  {
81
- label: mostUsedLabel,
82
- data: mostUsed,
83
- toggle: toggleOpen
84
- }
85
- ), /* @__PURE__ */ React.createElement(MenuBlock, { options, toggle: toggleOpen })) : /* @__PURE__ */ React.createElement(styled.StyledSearchResultsContainer, null, /* @__PURE__ */ React.createElement(styled.StyledSearchTextContainer, null, /* @__PURE__ */ React.createElement(reactCore.Text, { fontWeight: "bold" }, searchResultsLabel)), results.map((result) => /* @__PURE__ */ React.createElement(
86
- SearchResultItem,
87
- {
88
- key: `${result.title}-${result.category}`,
89
- data: result,
90
- searchTerm: search,
91
- toggle: toggleOpen
92
- }
93
- )))
94
- )));
83
+ style: animations.getContainerOpenMenuStyles(state),
84
+ ref: transitionMenuRef
85
+ },
86
+ !search ? /* @__PURE__ */ React.createElement(React.Fragment, null, mostUsed && /* @__PURE__ */ React.createElement(
87
+ MostUsed,
88
+ {
89
+ label: mostUsedLabel,
90
+ data: mostUsed,
91
+ toggle: toggleOpen
92
+ }
93
+ ), /* @__PURE__ */ React.createElement(MenuBlock, { options, toggle: toggleOpen })) : /* @__PURE__ */ React.createElement(styled.StyledSearchResultsContainer, null, /* @__PURE__ */ React.createElement(styled.StyledSearchTextContainer, null, /* @__PURE__ */ React.createElement(reactCore.Text, { fontWeight: "bold" }, searchResultsLabel)), results.map((result) => /* @__PURE__ */ React.createElement(
94
+ SearchResultItem,
95
+ {
96
+ key: `${result.title}-${result.category}`,
97
+ data: result,
98
+ searchTerm: search,
99
+ toggle: toggleOpen
100
+ }
101
+ )))
102
+ )
103
+ ));
95
104
  };
96
105
 
97
106
  module.exports = Menubar;
@@ -42,4 +42,5 @@ const highlight = (searchTerm, textToReplace, Component, props) => {
42
42
  };
43
43
 
44
44
  exports.highlight = highlight;
45
+ exports.normalize = normalize;
45
46
  exports.stringMatcher = stringMatcher;
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var utils = require('./SearchResultItem/utils.js');
4
+
3
5
  const filterAndTransform = (options, search) => {
4
6
  const normalized = [];
5
7
  options.forEach((option) => {
6
8
  option.items.forEach((item) => {
7
- if (item.title.toLowerCase().startsWith(search)) {
9
+ if (utils.normalize(item.title.toLowerCase()).includes(utils.normalize(search.toLowerCase()))) {
8
10
  normalized.push({
9
11
  title: item.title,
10
12
  Component: item.Component,
@@ -12,7 +12,7 @@ import { useClickAwayListener } from '../../../hooks/useClickAwayListener.js';
12
12
  const Menubar = ({
13
13
  leftComponents,
14
14
  rightComponents,
15
- searchPlaceholder = "O qu\xEA voc\xEA deseja buscar?",
15
+ searchPlaceholder = "O que voc\xEA deseja buscar?",
16
16
  options,
17
17
  mostUsed,
18
18
  mostUsedLabel = "Mais acessados",
@@ -67,29 +67,38 @@ const Menubar = ({
67
67
  onChange: setInput
68
68
  }
69
69
  )
70
- )), rightComponents), /* @__PURE__ */ React__default.createElement(Transition, { in: open, timeout: 250, nodeRef: transitionMenuRef }, (state) => /* @__PURE__ */ React__default.createElement(
71
- StyledContainerOpenMenu,
70
+ )), rightComponents), /* @__PURE__ */ React__default.createElement(
71
+ Transition,
72
72
  {
73
- style: getContainerOpenMenuStyles(state),
74
- ref: transitionMenuRef
73
+ in: open,
74
+ timeout: 250,
75
+ nodeRef: transitionMenuRef,
76
+ unmountOnExit: true
75
77
  },
76
- !search ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, mostUsed && /* @__PURE__ */ React__default.createElement(
77
- MostUsed,
78
+ (state) => /* @__PURE__ */ React__default.createElement(
79
+ StyledContainerOpenMenu,
78
80
  {
79
- label: mostUsedLabel,
80
- data: mostUsed,
81
- toggle: toggleOpen
82
- }
83
- ), /* @__PURE__ */ React__default.createElement(MenuBlock, { options, toggle: toggleOpen })) : /* @__PURE__ */ React__default.createElement(StyledSearchResultsContainer, null, /* @__PURE__ */ React__default.createElement(StyledSearchTextContainer, null, /* @__PURE__ */ React__default.createElement(Text, { fontWeight: "bold" }, searchResultsLabel)), results.map((result) => /* @__PURE__ */ React__default.createElement(
84
- SearchResultItem,
85
- {
86
- key: `${result.title}-${result.category}`,
87
- data: result,
88
- searchTerm: search,
89
- toggle: toggleOpen
90
- }
91
- )))
92
- )));
81
+ style: getContainerOpenMenuStyles(state),
82
+ ref: transitionMenuRef
83
+ },
84
+ !search ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, mostUsed && /* @__PURE__ */ React__default.createElement(
85
+ MostUsed,
86
+ {
87
+ label: mostUsedLabel,
88
+ data: mostUsed,
89
+ toggle: toggleOpen
90
+ }
91
+ ), /* @__PURE__ */ React__default.createElement(MenuBlock, { options, toggle: toggleOpen })) : /* @__PURE__ */ React__default.createElement(StyledSearchResultsContainer, null, /* @__PURE__ */ React__default.createElement(StyledSearchTextContainer, null, /* @__PURE__ */ React__default.createElement(Text, { fontWeight: "bold" }, searchResultsLabel)), results.map((result) => /* @__PURE__ */ React__default.createElement(
92
+ SearchResultItem,
93
+ {
94
+ key: `${result.title}-${result.category}`,
95
+ data: result,
96
+ searchTerm: search,
97
+ toggle: toggleOpen
98
+ }
99
+ )))
100
+ )
101
+ ));
93
102
  };
94
103
 
95
104
  export { Menubar as default };
@@ -39,4 +39,4 @@ const highlight = (searchTerm, textToReplace, Component, props) => {
39
39
  return textToReplace;
40
40
  };
41
41
 
42
- export { highlight, stringMatcher };
42
+ export { highlight, normalize, stringMatcher };
@@ -1,8 +1,10 @@
1
+ import { normalize } from './SearchResultItem/utils.js';
2
+
1
3
  const filterAndTransform = (options, search) => {
2
4
  const normalized = [];
3
5
  options.forEach((option) => {
4
6
  option.items.forEach((item) => {
5
- if (item.title.toLowerCase().startsWith(search)) {
7
+ if (normalize(item.title.toLowerCase()).includes(normalize(search.toLowerCase()))) {
6
8
  normalized.push({
7
9
  title: item.title,
8
10
  Component: item.Component,
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
+ export declare const normalize: (str: string) => string;
2
3
  export declare const stringMatcher: (searchTerm: string, textToReplace: string) => RegExpMatchArray[];
3
4
  export declare const highlight: <T>(searchTerm: string, textToReplace: string, Component: React.ElementType, props: T) => React.ReactNode;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-web-kit",
3
3
  "description": "React components library for web",
4
- "version": "3.4.7",
4
+ "version": "3.4.9",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
7
7
  "module": "dist/esm/index.js",
@@ -40,5 +40,5 @@
40
40
  "react-dom": ">=18.0.0",
41
41
  "react-native-web": ">=0.18.0 <1"
42
42
  },
43
- "gitHead": "dc07c534823149b1a519f15612d409560aa58ab5"
43
+ "gitHead": "8bf8c8e4792cdc8a887668e54ec77ceaf11c1374"
44
44
  }