@chayns-components/core 5.4.12 → 5.4.13

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.
Files changed (35) hide show
  1. package/lib/cjs/components/page-provider/PageProvider.js +1 -1
  2. package/lib/cjs/components/page-provider/PageProvider.js.map +1 -1
  3. package/lib/cjs/components/search-box/SearchBox.js +69 -20
  4. package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
  5. package/lib/cjs/components/search-box/search-box-body/SearchBoxBody.js +3 -1
  6. package/lib/cjs/components/search-box/search-box-body/SearchBoxBody.js.map +1 -1
  7. package/lib/cjs/components/search-box/search-box-body/SearchBoxBody.styles.js +6 -4
  8. package/lib/cjs/components/search-box/search-box-body/SearchBoxBody.styles.js.map +1 -1
  9. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.js +3 -1
  10. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.js.map +1 -1
  11. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.styles.js +6 -1
  12. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.styles.js.map +1 -1
  13. package/lib/cjs/utils/searchBox.js +22 -12
  14. package/lib/cjs/utils/searchBox.js.map +1 -1
  15. package/lib/esm/components/page-provider/PageProvider.js +1 -1
  16. package/lib/esm/components/page-provider/PageProvider.js.map +1 -1
  17. package/lib/esm/components/search-box/SearchBox.js +70 -21
  18. package/lib/esm/components/search-box/SearchBox.js.map +1 -1
  19. package/lib/esm/components/search-box/search-box-body/SearchBoxBody.js +3 -1
  20. package/lib/esm/components/search-box/search-box-body/SearchBoxBody.js.map +1 -1
  21. package/lib/esm/components/search-box/search-box-body/SearchBoxBody.styles.js +6 -4
  22. package/lib/esm/components/search-box/search-box-body/SearchBoxBody.styles.js.map +1 -1
  23. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.js +3 -1
  24. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.js.map +1 -1
  25. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.styles.js +6 -1
  26. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.styles.js.map +1 -1
  27. package/lib/esm/utils/searchBox.js +20 -11
  28. package/lib/esm/utils/searchBox.js.map +1 -1
  29. package/lib/types/components/search-box/SearchBox.d.ts +16 -0
  30. package/lib/types/components/search-box/search-box-body/SearchBoxBody.d.ts +1 -0
  31. package/lib/types/components/search-box/search-box-body/SearchBoxBody.styles.d.ts +4 -2
  32. package/lib/types/components/search-box/search-box-item/SearchBoxItem.d.ts +1 -0
  33. package/lib/types/components/search-box/search-box-item/SearchBoxItem.styles.d.ts +6 -2
  34. package/lib/types/utils/searchBox.d.ts +1 -0
  35. package/package.json +2 -2
@@ -39,11 +39,13 @@ const StyledSearchBoxBodyContent = exports.StyledSearchBoxBodyContent = _styledC
39
39
  cursor: pointer;
40
40
  width: 100%;
41
41
  max-height: ${({
42
- $headHeight
43
- }) => 300 - $headHeight}px;
42
+ $headHeight,
43
+ $maxHeight
44
+ }) => $maxHeight - $headHeight}px;
44
45
  overflow-y: ${({
45
46
  $height,
46
- $headHeight
47
- }) => $height + $headHeight <= 300 ? 'hidden' : 'auto'};
47
+ $headHeight,
48
+ $maxHeight
49
+ }) => $height + $headHeight <= $maxHeight ? 'hidden' : 'auto'};
48
50
  `;
49
51
  //# sourceMappingURL=SearchBoxBody.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SearchBoxBody.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledSearchBoxBody","exports","styled","div","StyledSearchBoxBodyHead","$hasGroupName","css","$hasScrolled","StyledSearchBoxBodyHeadGroupName","theme","text","StyledSearchBoxBodyContent","$headHeight","$height"],"sources":["../../../../../src/components/search-box/search-box-body/SearchBoxBody.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledSearchBoxBody = styled.div`\n display: flex;\n flex-direction: column;\n`;\n\nexport const StyledSearchBoxBodyHead = styled.div<StyledSearchBoxHeadProps>`\n padding: 10px 10px 5px;\n display: flex;\n flex-direction: column;\n\n ${({ $hasGroupName }) =>\n $hasGroupName &&\n css`\n gap: 15px;\n `}\n\n ${({ $hasScrolled }) =>\n $hasScrolled &&\n css`\n box-shadow: 0 1px 4px #0000001a;\n `}\n`;\n\ntype StyledSearchBoxHeadProps = WithTheme<{ $hasScrolled: boolean; $hasGroupName: boolean }>;\n\ntype StyledSearchBoxBodyHeadGroupNameNameProps = WithTheme<unknown>;\n\nexport const StyledSearchBoxBodyHeadGroupName = styled.div<StyledSearchBoxBodyHeadGroupNameNameProps>`\n color: ${({ theme }: StyledSearchBoxBodyHeadGroupNameNameProps) => theme.text};\n font-weight: bold;\n`;\n\ntype StyledSearchBoxBodyContentProps = WithTheme<{\n $height: number;\n $headHeight: number;\n}>;\n\nexport const StyledSearchBoxBodyContent = styled.div<StyledSearchBoxBodyContentProps>`\n display: flex;\n flex-direction: column;\n cursor: pointer;\n width: 100%;\n max-height: ${({ $headHeight }) => 300 - $headHeight}px;\n overflow-y: ${({ $height, $headHeight }) => ($height + $headHeight <= 300 ? 'hidden' : 'auto')};\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CA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ACA,kBAAkB,CAAC;EAAES;AAAY,CAAC,KAAK,GAAG,GAAGA,WAAW;AACxD,kBAAkB,CAAC;EAAEC,OAAO;EAAED;AAAY,CAAC,KAAMC,OAAO,GAAGD,WAAW,IAAI,GAAG,GAAG,QAAQ,GAAG,MAAO;AAClG,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SearchBoxBody.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledSearchBoxBody","exports","styled","div","StyledSearchBoxBodyHead","$hasGroupName","css","$hasScrolled","StyledSearchBoxBodyHeadGroupName","theme","text","StyledSearchBoxBodyContent","$headHeight","$maxHeight","$height"],"sources":["../../../../../src/components/search-box/search-box-body/SearchBoxBody.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledSearchBoxBody = styled.div`\n display: flex;\n flex-direction: column;\n`;\n\nexport const StyledSearchBoxBodyHead = styled.div<StyledSearchBoxHeadProps>`\n padding: 10px 10px 5px;\n display: flex;\n flex-direction: column;\n\n ${({ $hasGroupName }) =>\n $hasGroupName &&\n css`\n gap: 15px;\n `}\n\n ${({ $hasScrolled }) =>\n $hasScrolled &&\n css`\n box-shadow: 0 1px 4px #0000001a;\n `}\n`;\n\ntype StyledSearchBoxHeadProps = WithTheme<{ $hasScrolled: boolean; $hasGroupName: boolean }>;\n\ntype StyledSearchBoxBodyHeadGroupNameNameProps = WithTheme<unknown>;\n\nexport const StyledSearchBoxBodyHeadGroupName = styled.div<StyledSearchBoxBodyHeadGroupNameNameProps>`\n color: ${({ theme }: StyledSearchBoxBodyHeadGroupNameNameProps) => theme.text};\n font-weight: bold;\n`;\n\ntype StyledSearchBoxBodyContentProps = WithTheme<{\n $height: number;\n $headHeight: number;\n $maxHeight: number;\n}>;\n\nexport const StyledSearchBoxBodyContent = styled.div<StyledSearchBoxBodyContentProps>`\n display: flex;\n flex-direction: column;\n cursor: pointer;\n width: 100%;\n max-height: ${({ $headHeight, $maxHeight }) => $maxHeight - $headHeight}px;\n overflow-y: ${({ $height, $headHeight, $maxHeight }) =>\n $height + $headHeight <= $maxHeight ? 'hidden' : 'auto'};\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAGzC,MAAMkB,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGE,yBAAM,CAACC,GAAG;AAC7C;AACA;AACA,CAAC;AAEM,MAAMC,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAGF,yBAAM,CAACC,GAA6B;AAC3E;AACA;AACA;AACA;AACA,MAAM,CAAC;EAAEE;AAAc,CAAC,KAChBA,aAAa,IACb,IAAAC,qBAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEC;AAAa,CAAC,KACfA,YAAY,IACZ,IAAAD,qBAAG;AACX;AACA,SAAS;AACT,CAAC;AAMM,MAAME,gCAAgC,GAAAP,OAAA,CAAAO,gCAAA,GAAGN,yBAAM,CAACC,GAA8C;AACrG,aAAa,CAAC;EAAEM;AAAiD,CAAC,KAAKA,KAAK,CAACC,IAAI;AACjF;AACA,CAAC;AAQM,MAAMC,0BAA0B,GAAAV,OAAA,CAAAU,0BAAA,GAAGT,yBAAM,CAACC,GAAoC;AACrF;AACA;AACA;AACA;AACA,kBAAkB,CAAC;EAAES,WAAW;EAAEC;AAAW,CAAC,KAAKA,UAAU,GAAGD,WAAW;AAC3E,kBAAkB,CAAC;EAAEE,OAAO;EAAEF,WAAW;EAAEC;AAAW,CAAC,KAC/CC,OAAO,GAAGF,WAAW,IAAIC,UAAU,GAAG,QAAQ,GAAG,MAAM;AAC/D,CAAC","ignoreList":[]}
@@ -11,6 +11,7 @@ const SearchBoxItem = ({
11
11
  id,
12
12
  text,
13
13
  imageUrl,
14
+ shouldShowSmallItems,
14
15
  shouldShowRoundImage,
15
16
  onSelect,
16
17
  groupName,
@@ -37,10 +38,11 @@ const SearchBoxItem = ({
37
38
  src: imageUrl,
38
39
  $shouldShowRoundImage: shouldShowRoundImage
39
40
  }), /*#__PURE__*/_react.default.createElement(_SearchBoxItem.StyledSearchBoxItemText, {
41
+ $shouldShowSmallItems: shouldShowSmallItems,
40
42
  dangerouslySetInnerHTML: {
41
43
  __html: text
42
44
  }
43
- })), [handleClick, idString, imageUrl, shouldShowRoundImage, text, tabIndex]);
45
+ })), [handleClick, idString, imageUrl, shouldShowRoundImage, shouldShowSmallItems, text, tabIndex]);
44
46
  };
45
47
  SearchBoxItem.displayName = 'SearchBoxItem';
46
48
  var _default = exports.default = SearchBoxItem;
@@ -1 +1 @@
1
- {"version":3,"file":"SearchBoxItem.js","names":["_react","_interopRequireWildcard","require","_SearchBoxItem","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SearchBoxItem","id","text","imageUrl","shouldShowRoundImage","onSelect","groupName","tabIndex","handleClick","useCallback","event","preventDefault","stopPropagation","idString","useMemo","createElement","StyledSearchBoxItem","onClick","StyledSearchBoxItemImage","src","$shouldShowRoundImage","StyledSearchBoxItemText","dangerouslySetInnerHTML","__html","displayName","_default","exports"],"sources":["../../../../../src/components/search-box/search-box-item/SearchBoxItem.tsx"],"sourcesContent":["import React, { FC, MouseEvent, useCallback, useMemo } from 'react';\nimport type { ISearchBoxItem, ISearchBoxItems } from '../../../types/searchBox';\nimport {\n StyledSearchBoxItem,\n StyledSearchBoxItemImage,\n StyledSearchBoxItemText,\n} from './SearchBoxItem.styles';\n\nexport type SearchBoxItemProps = {\n onSelect: (item: ISearchBoxItem, groupName?: ISearchBoxItems['groupName']) => void;\n id: ISearchBoxItem['id'];\n text: ISearchBoxItem['text'];\n imageUrl?: ISearchBoxItem['imageUrl'];\n shouldShowRoundImage?: boolean;\n groupName?: ISearchBoxItems['groupName'];\n tabIndex: number;\n};\n\nconst SearchBoxItem: FC<SearchBoxItemProps> = ({\n id,\n text,\n imageUrl,\n shouldShowRoundImage,\n onSelect,\n groupName,\n tabIndex,\n}) => {\n const handleClick = useCallback(\n (event: MouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n\n onSelect({ id: id === 'input-value' ? text : id, text, imageUrl }, groupName);\n },\n [onSelect, id, text, imageUrl, groupName],\n );\n\n let idString = `search-box-item__${id}`;\n\n if (groupName) {\n idString = `_${groupName}`;\n }\n\n return useMemo(\n () => (\n <StyledSearchBoxItem id={idString} onClick={handleClick} tabIndex={tabIndex}>\n {imageUrl && (\n <StyledSearchBoxItemImage\n src={imageUrl}\n $shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n <StyledSearchBoxItemText dangerouslySetInnerHTML={{ __html: text }} />\n </StyledSearchBoxItem>\n ),\n [handleClick, idString, imageUrl, shouldShowRoundImage, text, tabIndex],\n );\n};\n\nSearchBoxItem.displayName = 'SearchBoxItem';\n\nexport default SearchBoxItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAIgC,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK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AAuB,EAAE;MAAEC,MAAM,EAAErB;IAAK;EAAE,CAAE,CACpD,CACxB,EACD,CAACM,WAAW,EAAEK,QAAQ,EAAEV,QAAQ,EAAEC,oBAAoB,EAAEF,IAAI,EAAEK,QAAQ,CAC1E,CAAC;AACL,CAAC;AAEDP,aAAa,CAACwB,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnC,OAAA,GAE7BS,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"SearchBoxItem.js","names":["_react","_interopRequireWildcard","require","_SearchBoxItem","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SearchBoxItem","id","text","imageUrl","shouldShowSmallItems","shouldShowRoundImage","onSelect","groupName","tabIndex","handleClick","useCallback","event","preventDefault","stopPropagation","idString","useMemo","createElement","StyledSearchBoxItem","onClick","StyledSearchBoxItemImage","src","$shouldShowRoundImage","StyledSearchBoxItemText","$shouldShowSmallItems","dangerouslySetInnerHTML","__html","displayName","_default","exports"],"sources":["../../../../../src/components/search-box/search-box-item/SearchBoxItem.tsx"],"sourcesContent":["import React, { FC, MouseEvent, useCallback, useMemo } from 'react';\nimport type { ISearchBoxItem, ISearchBoxItems } from '../../../types/searchBox';\nimport {\n StyledSearchBoxItem,\n StyledSearchBoxItemImage,\n StyledSearchBoxItemText,\n} from './SearchBoxItem.styles';\n\nexport type SearchBoxItemProps = {\n onSelect: (item: ISearchBoxItem, groupName?: ISearchBoxItems['groupName']) => void;\n id: ISearchBoxItem['id'];\n text: ISearchBoxItem['text'];\n imageUrl?: ISearchBoxItem['imageUrl'];\n shouldShowSmallItems?: boolean;\n shouldShowRoundImage?: boolean;\n groupName?: ISearchBoxItems['groupName'];\n tabIndex: number;\n};\n\nconst SearchBoxItem: FC<SearchBoxItemProps> = ({\n id,\n text,\n imageUrl,\n shouldShowSmallItems,\n shouldShowRoundImage,\n onSelect,\n groupName,\n tabIndex,\n}) => {\n const handleClick = useCallback(\n (event: MouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n\n onSelect({ id: id === 'input-value' ? text : id, text, imageUrl }, groupName);\n },\n [onSelect, id, text, imageUrl, groupName],\n );\n\n let idString = `search-box-item__${id}`;\n\n if (groupName) {\n idString = `_${groupName}`;\n }\n\n return useMemo(\n () => (\n <StyledSearchBoxItem id={idString} onClick={handleClick} tabIndex={tabIndex}>\n {imageUrl && (\n <StyledSearchBoxItemImage\n src={imageUrl}\n $shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n <StyledSearchBoxItemText\n $shouldShowSmallItems={shouldShowSmallItems}\n dangerouslySetInnerHTML={{ __html: text }}\n />\n </StyledSearchBoxItem>\n ),\n [\n handleClick,\n idString,\n imageUrl,\n shouldShowRoundImage,\n shouldShowSmallItems,\n text,\n tabIndex,\n ],\n );\n};\n\nSearchBoxItem.displayName = 'SearchBoxItem';\n\nexport default SearchBoxItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAIgC,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ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S,GACvEL,QAAQ,iBACL1B,MAAA,CAAAc,OAAA,CAAAyB,aAAA,CAACpC,cAAA,CAAAuC,wBAAwB;IACrBC,GAAG,EAAEjB,QAAS;IACdkB,qBAAqB,EAAEhB;EAAqB,CAC/C,CACJ,eACD5B,MAAA,CAAAc,OAAA,CAAAyB,aAAA,CAACpC,cAAA,CAAA0C,uBAAuB;IACpBC,qBAAqB,EAAEnB,oBAAqB;IAC5CoB,uBAAuB,EAAE;MAAEC,MAAM,EAAEvB;IAAK;EAAE,CAC7C,CACgB,CACxB,EACD,CACIO,WAAW,EACXK,QAAQ,EACRX,QAAQ,EACRE,oBAAoB,EACpBD,oBAAoB,EACpBF,IAAI,EACJM,QAAQ,CAEhB,CAAC;AACL,CAAC;AAEDR,aAAa,CAAC0B,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArC,OAAA,GAE7BS,aAAa","ignoreList":[]}
@@ -42,7 +42,12 @@ const StyledSearchBoxItemText = exports.StyledSearchBoxItemText = _styledCompone
42
42
  color: ${({
43
43
  theme
44
44
  }) => theme.text};
45
- margin: 5px 0 !important;
45
+ font-size: ${({
46
+ $shouldShowSmallItems
47
+ }) => $shouldShowSmallItems ? '14px' : undefined};
48
+ margin: ${({
49
+ $shouldShowSmallItems
50
+ }) => $shouldShowSmallItems ? '0 !important' : '5px 0 !important'};
46
51
 
47
52
  b {
48
53
  color: ${({
@@ -1 +1 @@
1
- {"version":3,"file":"SearchBoxItem.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledSearchBoxItem","exports","styled","div","theme","StyledSearchBoxItemImage","img","$shouldShowRoundImage","css","StyledSearchBoxItemText","p","text","headline"],"sources":["../../../../../src/components/search-box/search-box-item/SearchBoxItem.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledSearchBoxItemProps = WithTheme<unknown>;\nexport const StyledSearchBoxItem = styled.div<StyledSearchBoxItemProps>`\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 10px;\n\n &:hover {\n background: ${({ theme }: StyledSearchBoxItemProps) => theme['secondary-102']};\n }\n\n &[tabindex='0'] {\n background: ${({ theme }: StyledSearchBoxItemProps) => theme['secondary-102']};\n }\n`;\n\ntype StyledSearchBoxItemImageProps = WithTheme<{ $shouldShowRoundImage?: boolean }>;\n\nexport const StyledSearchBoxItemImage = styled.img<StyledSearchBoxItemImageProps>`\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledSearchBoxItemImageProps) => theme['009-rgb']}, 0.15);\n height: 22px;\n width: 22px;\n\n ${({ $shouldShowRoundImage }) =>\n $shouldShowRoundImage &&\n css`\n border-radius: 50%;\n `}\n`;\n\ntype StyledSearchBoxItemTextProps = WithTheme<unknown>;\n\nexport const StyledSearchBoxItemText = styled.p<StyledSearchBoxItemTextProps>`\n color: ${({ theme }: StyledSearchBoxItemTextProps) => theme.text};\n margin: 5px 0 !important;\n\n b {\n color: ${({ theme }: StyledSearchBoxItemTextProps) => theme.headline};\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,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O,IAAI;AACpE;AACA;AACA;AACA,iBAAiB,CAAC;EAAEP;AAAoC,CAAC,KAAKA,KAAK,CAACQ,QAAQ;AAC5E;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SearchBoxItem.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledSearchBoxItem","exports","styled","div","theme","StyledSearchBoxItemImage","img","$shouldShowRoundImage","css","StyledSearchBoxItemText","p","text","$shouldShowSmallItems","undefined","headline"],"sources":["../../../../../src/components/search-box/search-box-item/SearchBoxItem.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledSearchBoxItemProps = WithTheme<unknown>;\nexport const StyledSearchBoxItem = styled.div<StyledSearchBoxItemProps>`\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 10px;\n\n &:hover {\n background: ${({ theme }: StyledSearchBoxItemProps) => theme['secondary-102']};\n }\n\n &[tabindex='0'] {\n background: ${({ theme }: StyledSearchBoxItemProps) => theme['secondary-102']};\n }\n`;\n\ntype StyledSearchBoxItemImageProps = WithTheme<{ $shouldShowRoundImage?: boolean }>;\n\nexport const StyledSearchBoxItemImage = styled.img<StyledSearchBoxItemImageProps>`\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledSearchBoxItemImageProps) => theme['009-rgb']}, 0.15);\n height: 22px;\n width: 22px;\n\n ${({ $shouldShowRoundImage }) =>\n $shouldShowRoundImage &&\n css`\n border-radius: 50%;\n `}\n`;\n\ntype StyledSearchBoxItemTextProps = WithTheme<{ $shouldShowSmallItems?: boolean }>;\n\nexport const StyledSearchBoxItemText = styled.p<StyledSearchBoxItemTextProps>`\n color: ${({ theme }: StyledSearchBoxItemTextProps) => theme.text};\n font-size: ${({ $shouldShowSmallItems }) => ($shouldShowSmallItems ? '14px' : undefined)};\n margin: ${({ $shouldShowSmallItems }) =>\n $shouldShowSmallItems ? '0 !important' : '5px 0 !important'};\n\n b {\n color: ${({ theme }: StyledSearchBoxItemTextProps) => theme.headline};\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAIzC,MAAMkB,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGE,yBAAM,CAACC,GAA6B;AACvE;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,CAAC;EAAEC;AAAgC,CAAC,KAAKA,KAAK,CAAC,eAAe,CAAC;AACrF;AACA;AACA;AACA,sBAAsB,CAAC;EAAEA;AAAgC,CAAC,KAAKA,KAAK,CAAC,eAAe,CAAC;AACrF;AACA,CAAC;AAIM,MAAMC,wBAAwB,GAAAJ,OAAA,CAAAI,wBAAA,GAAGH,yBAAM,CAACI,GAAkC;AACjF;AACA,eAAe,CAAC;EAAEF;AAAqC,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AAC7E;AACA;AACA;AACA,MAAM,CAAC;EAAEG;AAAsB,CAAC,KACxBA,qBAAqB,IACrB,IAAAC,qBAAG;AACX;AACA,SAAS;AACT,CAAC;AAIM,MAAMC,uBAAuB,GAAAR,OAAA,CAAAQ,uBAAA,GAAGP,yBAAM,CAACQ,CAA+B;AAC7E,aAAa,CAAC;EAAEN;AAAoC,CAAC,KAAKA,KAAK,CAACO,IAAI;AACpE,iBAAiB,CAAC;EAAEC;AAAsB,CAAC,KAAMA,qBAAqB,GAAG,MAAM,GAAGC,SAAU;AAC5F,cAAc,CAAC;EAAED;AAAsB,CAAC,KAChCA,qBAAqB,GAAG,cAAc,GAAG,kBAAkB;AACnE;AACA;AACA,iBAAiB,CAAC;EAAER;AAAoC,CAAC,KAAKA,KAAK,CAACU,QAAQ;AAC5E;AACA,CAAC","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.searchList = exports.getCurrentGroupName = void 0;
6
+ exports.sortSearchBoxItems = exports.searchList = exports.getCurrentGroupName = void 0;
7
7
  const surroundWithBTag = (text, startIndex, length) => {
8
8
  const before = text.substring(0, startIndex);
9
9
  const highlighted = text.substring(startIndex, startIndex + length);
@@ -44,6 +44,24 @@ const getCurrentGroupName = element => {
44
44
  return currentGroupName;
45
45
  };
46
46
  exports.getCurrentGroupName = getCurrentGroupName;
47
+ const sortSearchBoxItems = ({
48
+ searchString,
49
+ items
50
+ }) => {
51
+ const lowercaseSearchString = searchString.toLowerCase();
52
+ return [...items].sort((a, b) => {
53
+ const aStartsWithSearchString = a.text.toLowerCase().startsWith(lowercaseSearchString);
54
+ const bStartsWithSearchString = b.text.toLowerCase().startsWith(lowercaseSearchString);
55
+ if (aStartsWithSearchString && !bStartsWithSearchString) {
56
+ return -1;
57
+ }
58
+ if (!aStartsWithSearchString && bStartsWithSearchString) {
59
+ return 1;
60
+ }
61
+ return a.text.localeCompare(b.text);
62
+ });
63
+ };
64
+ exports.sortSearchBoxItems = sortSearchBoxItems;
47
65
  const searchList = ({
48
66
  searchString,
49
67
  items
@@ -65,18 +83,10 @@ const searchList = ({
65
83
  }
66
84
  }
67
85
  });
68
- matchingItems.sort((a, b) => {
69
- const aStartsWithSearchString = a.text.toLowerCase().startsWith(lowercaseSearchString);
70
- const bStartsWithSearchString = b.text.toLowerCase().startsWith(lowercaseSearchString);
71
- if (aStartsWithSearchString && !bStartsWithSearchString) {
72
- return -1;
73
- }
74
- if (!aStartsWithSearchString && bStartsWithSearchString) {
75
- return 1;
76
- }
77
- return a.text.localeCompare(b.text);
86
+ return sortSearchBoxItems({
87
+ items: matchingItems,
88
+ searchString
78
89
  });
79
- return matchingItems;
80
90
  };
81
91
  exports.searchList = searchList;
82
92
  //# sourceMappingURL=searchBox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"searchBox.js","names":["surroundWithBTag","text","startIndex","length","before","substring","highlighted","after","getCurrentGroupName","element","hasChildrenFound","currentGroupName","top","parentTop","getBoundingClientRect","children","Array","from","forEach","child","y","childrenY","height","childrenHeight","id","sum","currentGroup","startsWith","nummer","split","pop","exports","searchList","searchString","items","matchingItems","lowercaseSearchString","toLowerCase","item","lowercaseText","includes","push","indexOf","highlightedText","sort","a","b","aStartsWithSearchString","bStartsWithSearchString","localeCompare"],"sources":["../../../src/utils/searchBox.ts"],"sourcesContent":["import type { ISearchBoxItem } from '../types/searchBox';\n\nconst surroundWithBTag = (text: string, startIndex: number, length: number) => {\n const before = text.substring(0, startIndex);\n const highlighted = text.substring(startIndex, startIndex + length);\n const after = text.substring(startIndex + length);\n\n return `${before}<b>${highlighted}</b>${after}`;\n};\n\nexport const getCurrentGroupName = (element: HTMLElement) => {\n let hasChildrenFound = false;\n let currentGroupName = '';\n\n const { top: parentTop } = element.getBoundingClientRect();\n const { children } = element;\n\n Array.from(children).forEach((child) => {\n if (hasChildrenFound) {\n return;\n }\n\n const { y: childrenY, height: childrenHeight } = child.getBoundingClientRect();\n const { id } = child;\n\n const sum = childrenY + childrenHeight - parentTop;\n\n if (sum >= 0) {\n hasChildrenFound = true;\n let currentGroup = id;\n\n if (id.startsWith('search-box-item__')) {\n const nummer = id.split('__')[1];\n currentGroup = nummer?.split('_').pop() ?? '';\n }\n\n currentGroupName = currentGroup;\n }\n });\n\n return currentGroupName;\n};\n\ninterface SearchListOptions {\n items: ISearchBoxItem[];\n searchString: string;\n}\n\nexport const searchList = ({ searchString, items }: SearchListOptions) => {\n const matchingItems: ISearchBoxItem[] = [];\n\n const lowercaseSearchString = searchString.toLowerCase();\n\n items.forEach((item) => {\n const lowercaseText = item.text.toLowerCase();\n\n if (lowercaseText.includes(lowercaseSearchString)) {\n if (searchString === '') {\n matchingItems.push(item);\n } else {\n const startIndex = lowercaseText.indexOf(lowercaseSearchString);\n const highlightedText = surroundWithBTag(\n item.text,\n startIndex,\n searchString.length,\n );\n matchingItems.push({ ...item, text: highlightedText });\n }\n }\n });\n\n matchingItems.sort((a, b) => {\n const aStartsWithSearchString = a.text.toLowerCase().startsWith(lowercaseSearchString);\n const bStartsWithSearchString = b.text.toLowerCase().startsWith(lowercaseSearchString);\n\n if (aStartsWithSearchString && !bStartsWithSearchString) {\n return -1;\n }\n if (!aStartsWithSearchString && bStartsWithSearchString) {\n return 1;\n }\n return a.text.localeCompare(b.text);\n });\n\n return matchingItems;\n};\n"],"mappings":";;;;;;AAEA,MAAMA,gBAA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,CAAC;IAEtF,IAAIW,uBAAuB,IAAI,CAACC,uBAAuB,EAAE;MACrD,OAAO,CAAC,CAAC;IACb;IACA,IAAI,CAACD,uBAAuB,IAAIC,uBAAuB,EAAE;MACrD,OAAO,CAAC;IACZ;IACA,OAAOH,CAAC,CAAC5C,IAAI,CAACgD,aAAa,CAACH,CAAC,CAAC7C,IAAI,CAAC;EACvC,CAAC,CAAC;EAEF,OAAOkC,aAAa;AACxB,CAAC;AAACJ,OAAA,CAAAC,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"file":"searchBox.js","names":["surroundWithBTag","text","startIndex","length","before","substring","highlighted","after","getCurrentGroupName","element","hasChildrenFound","currentGroupName","top","parentTop","getBoundingClientRect","children","Array","from","forEach","child","y","childrenY","height","childrenHeight","id","sum","currentGroup","startsWith","nummer","split","pop","exports","sortSearchBoxItems","searchString","items","lowercaseSearchString","toLowerCase","sort","a","b","aStartsWithSearchString","bStartsWithSearchString","localeCompare","searchList","matchingItems","item","lowercaseText","includes","push","indexOf","highlightedText"],"sources":["../../../src/utils/searchBox.ts"],"sourcesContent":["import type { ISearchBoxItem } from '../types/searchBox';\n\nconst surroundWithBTag = (text: string, startIndex: number, length: number) => {\n const before = text.substring(0, startIndex);\n const highlighted = text.substring(startIndex, startIndex + length);\n const after = text.substring(startIndex + length);\n\n return `${before}<b>${highlighted}</b>${after}`;\n};\n\nexport const getCurrentGroupName = (element: HTMLElement) => {\n let hasChildrenFound = false;\n let currentGroupName = '';\n\n const { top: parentTop } = element.getBoundingClientRect();\n const { children } = element;\n\n Array.from(children).forEach((child) => {\n if (hasChildrenFound) {\n return;\n }\n\n const { y: childrenY, height: childrenHeight } = child.getBoundingClientRect();\n const { id } = child;\n\n const sum = childrenY + childrenHeight - parentTop;\n\n if (sum >= 0) {\n hasChildrenFound = true;\n let currentGroup = id;\n\n if (id.startsWith('search-box-item__')) {\n const nummer = id.split('__')[1];\n currentGroup = nummer?.split('_').pop() ?? '';\n }\n\n currentGroupName = currentGroup;\n }\n });\n\n return currentGroupName;\n};\n\ninterface SearchListOptions {\n items: ISearchBoxItem[];\n searchString: string;\n}\n\nexport const sortSearchBoxItems = ({ searchString, items }: SearchListOptions) => {\n const lowercaseSearchString = searchString.toLowerCase();\n\n return [...items].sort((a, b) => {\n const aStartsWithSearchString = a.text.toLowerCase().startsWith(lowercaseSearchString);\n const bStartsWithSearchString = b.text.toLowerCase().startsWith(lowercaseSearchString);\n\n if (aStartsWithSearchString && !bStartsWithSearchString) {\n return -1;\n }\n if (!aStartsWithSearchString && bStartsWithSearchString) {\n return 1;\n }\n return a.text.localeCompare(b.text);\n });\n};\n\nexport const searchList = ({ searchString, items }: SearchListOptions) => {\n const matchingItems: ISearchBoxItem[] = [];\n\n const lowercaseSearchString = searchString.toLowerCase();\n\n items.forEach((item) => {\n const lowercaseText = item.text.toLowerCase();\n\n if (lowercaseText.includes(lowercaseSearchString)) {\n if (searchString === '') {\n matchingItems.push(item);\n } else {\n const startIndex = lowercaseText.indexOf(lowercaseSearchString);\n const highlightedText = surroundWithBTag(\n item.text,\n startIndex,\n searchString.length,\n );\n matchingItems.push({ ...item, text: highlightedText });\n }\n }\n });\n\n return sortSearchBoxItems({ items: matchingItems, searchString });\n};\n"],"mappings":";;;;;;AAEA,MAAMA,gBAAgB,GAAGA,CAACC,IAAY,EAAEC,UAAkB,EAAEC,MAAc,KAAK;EAC3E,MAAMC,MAAM,GAAGH,IAAI,CAACI,SAAS,CAAC,CAAC,EAAEH,UAAU,CAAC;EAC5C,MAAMI,WAAW,GAAGL,IAAI,CAACI,SAAS,CAACH,UAAU,EAAEA,UAAU,GAAGC,MAAM,CAAC;EACnE,MAAMI,KAAK,GAAGN,IAAI,CAACI,SAAS,CAACH,UAAU,GAAGC,MAAM,CAAC;EAEjD,OAAO,GAAGC,MAAM,MAAME,WAAW,OAAOC,KAAK,EAAE;AACnD,CAAC;AAEM,MAAMC,mBAAmB,GAAIC,OAAoB,IAAK;EACzD,IAAIC,g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AAC,CAAC;MAC1D;IACJ;EACJ,CAAC,CAAC;EAEF,OAAOlB,kBAAkB,CAAC;IAAEE,KAAK,EAAEU,aAAa;IAAEX;EAAa,CAAC,CAAC;AACrE,CAAC;AAACF,OAAA,CAAAY,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -40,7 +40,7 @@ const PageProvider = ({
40
40
  const usableHeight = useUsableHeight({
41
41
  shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight
42
42
  });
43
- const shouldUsePadding = !shouldRemovePadding && ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(runtimeEnvironment);
43
+ const shouldUsePadding = !shouldRemovePadding && ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6, 8].includes(runtimeEnvironment);
44
44
  return /*#__PURE__*/React.createElement(StyledPageProvider, {
45
45
  className: "page-provider",
46
46
  $shouldUsePadding: shouldUsePadding,
@@ -1 +1 @@
1
- {"version":3,"file":"PageProvider.js","names":["RuntimeEnviroment","useEnvironment","React","createGlobalStyle","useUsableHeight","ColorSchemeProvider","StyledPageProvider","GlobalStyle","PageProvider","children","color","colorMode","secondaryColor","siteId","style","shouldReduceUsableHeightByCoverHeight","shouldRemovePadding","shouldUseUsableHeight","iconColor","customVariables","runtimeEnvironment","usableHeight","shouldReduceByCoverHeight","shouldUsePadding","IntercomPlugin","PagemakerPlugin","includes","createElement","className","$shouldUsePadding","$usableHeight","undefined","height","displayName"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { RuntimeEnviroment, useEnvironment } from 'chayns-api';\nimport React, { FC } from 'react';\nimport { createGlobalStyle } from 'styled-components';\nimport { useUsableHeight } from '../../utils/pageProvider';\nimport ColorSchemeProvider, {\n type ColorSchemeProviderProps,\n} from '../color-scheme-provider/ColorSchemeProvider';\nimport { StyledPageProvider } from './PageProvider.styles';\n\n/**\n * Props for the PageProvider component.\n * @description\n * This interface defines the props that can be passed to the PageProvider component\n * for controlling the layout and styling behavior.\n * @example\n * <PageProvider shouldRemovePadding={true}>\n * {children}\n * </PageProvider>\n */\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Controls whether the usable height should be reduced by the cover height\n * @description\n * When true, the usable height will be reduced by the cover image height. This is useful\n * when the page should not be scrollable due to the cover image. The property has no effect\n * when `shouldUseUsableHeight` is false.\n * @default false\n * @optional\n */\n shouldReduceUsableHeightByCoverHeight?: boolean;\n /**\n * Controls whether padding should be removed from the page\n * @description\n * When true, the padding around the page content will be removed. This is useful when the\n * page should not have any padding, for example, when it is embedded in a pagemaker page.\n * @default false\n * @optional\n */\n shouldRemovePadding?: boolean;\n /**\n * Controls whether the component should use the calculated usable height\n * @description\n * When true, the page will cover the entire usable height of the screen. This means that\n * the viewport is not scrollable and the page takes up the full height not required by the\n * title or bottom bar. Optionally, the height of the cover image can be reduced by setting\n * `shouldReduceUsableHeightByCoverHeight` to true.\n * @default false\n * @optional\n */\n shouldUseUsableHeight?: boolean;\n}\n\nconst GlobalStyle = createGlobalStyle`\n *, *::before, *::after {\n box-sizing: border-box;\n }\n`;\n\nconst PageProvider: FC<PageProviderProps> = ({\n children,\n color,\n colorMode,\n secondaryColor,\n siteId,\n style = {},\n shouldReduceUsableHeightByCoverHeight = false,\n shouldRemovePadding = false,\n shouldUseUsableHeight = false,\n iconColor,\n customVariables,\n}) => {\n const { runtimeEnvironment } = useEnvironment();\n\n const usableHeight = useUsableHeight({\n shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight,\n });\n\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(\n runtimeEnvironment as number,\n );\n\n return (\n <StyledPageProvider\n className=\"page-provider\"\n $shouldUsePadding={shouldUsePadding}\n $usableHeight={shouldUseUsableHeight ? usableHeight : undefined}\n >\n <ColorSchemeProvider\n color={color}\n secondaryColor={secondaryColor}\n colorMode={colorMode}\n siteId={siteId}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n customVariables={customVariables}\n iconColor={iconColor}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n </StyledPageProvider>\n );\n};\nPageProvider.displayName = 'PageProvider';\n\nexport default PageProvider;\n"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,YAAY;AAC9D,OAAOC,KAAK,MAAc,OAAO;AACjC,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,OAAOC,mBAAmB,MAEnB,8CAA8C;AACrD,SAASC,kBAAkB,QAAQ,uBAAuB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA,MAAMC,WAAW,GAAGJ,iBAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMK,YAAmC,GAAGA,CAAC;EACzCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,cAAc;EACdC,MAAM;EACNC,KAAK,GAAG,CAAC,CAAC;EACVC,qCAAqC,GAAG,KAAK;EAC7CC,mBAAmB,GAAG,KAAK;EAC3BC,qBAAqB,GAAG,KAAK;EAC7BC,SAAS;EACTC;AACJ,CAAC,KAAK;EACF,MAAM;IAAEC;EAAmB,CAAC,GAAGnB,cAAc,CAAC,CAAC;EAE/C,MAAMoB,YAAY,GAAGjB,eAAe,CAAC;IACjCkB,yBAAyB,EAAEP;EAC/B,CAAC,CAAC;EAEF,MAAMQ,gBAAgB,GAClB,CAACP,mBAAmB,IACpB,CAAC,CAAChB,iBAAiB,CAACwB,cAAc,EAAExB,iBAAiB,CAACyB,eAAe,EAAE,CAAC,CAAC,CAACC,QAAQ,CAC9EN,kBACJ,CAAC;EAEL,oBACIlB,KAAA,CAAAyB,aAAA,CAACrB,kBAAkB;IACfsB,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAEN,gBAAiB;IACpCO,aAAa,EAAEb,qBAAqB,GAAGI,YAAY,GAAGU;EAAU,gBAEhE7B,KAAA,CAAAyB,aAAA,CAACtB,mBAAmB;IAChBK,KAAK,EAAEA,KAAM;IACbE,cAAc,EAAEA,cAAe;IAC/BD,SAAS,EAAEA,SAAU;IACrBE,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEkB,MAAM,EAAE;IAAO,CAAC,GAAGlB,KAAM;IACpEK,eAAe,EAAEA,eAAgB;IACjCD,SAAS,EAAEA;EAAU,GAEpBT,QACgB,CAAC,eACtBP,KAAA,CAAAyB,aAAA,CAACpB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDC,YAAY,CAACyB,WAAW,GAAG,cAAc;AAEzC,eAAezB,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"PageProvider.js","names":["RuntimeEnviroment","useEnvironment","React","createGlobalStyle","useUsableHeight","ColorSchemeProvider","StyledPageProvider","GlobalStyle","PageProvider","children","color","colorMode","secondaryColor","siteId","style","shouldReduceUsableHeightByCoverHeight","shouldRemovePadding","shouldUseUsableHeight","iconColor","customVariables","runtimeEnvironment","usableHeight","shouldReduceByCoverHeight","shouldUsePadding","IntercomPlugin","PagemakerPlugin","includes","createElement","className","$shouldUsePadding","$usableHeight","undefined","height","displayName"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { RuntimeEnviroment, useEnvironment } from 'chayns-api';\nimport React, { FC } from 'react';\nimport { createGlobalStyle } from 'styled-components';\nimport { useUsableHeight } from '../../utils/pageProvider';\nimport ColorSchemeProvider, {\n type ColorSchemeProviderProps,\n} from '../color-scheme-provider/ColorSchemeProvider';\nimport { StyledPageProvider } from './PageProvider.styles';\n\n/**\n * Props for the PageProvider component.\n * @description\n * This interface defines the props that can be passed to the PageProvider component\n * for controlling the layout and styling behavior.\n * @example\n * <PageProvider shouldRemovePadding={true}>\n * {children}\n * </PageProvider>\n */\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Controls whether the usable height should be reduced by the cover height\n * @description\n * When true, the usable height will be reduced by the cover image height. This is useful\n * when the page should not be scrollable due to the cover image. The property has no effect\n * when `shouldUseUsableHeight` is false.\n * @default false\n * @optional\n */\n shouldReduceUsableHeightByCoverHeight?: boolean;\n /**\n * Controls whether padding should be removed from the page\n * @description\n * When true, the padding around the page content will be removed. This is useful when the\n * page should not have any padding, for example, when it is embedded in a pagemaker page.\n * @default false\n * @optional\n */\n shouldRemovePadding?: boolean;\n /**\n * Controls whether the component should use the calculated usable height\n * @description\n * When true, the page will cover the entire usable height of the screen. This means that\n * the viewport is not scrollable and the page takes up the full height not required by the\n * title or bottom bar. Optionally, the height of the cover image can be reduced by setting\n * `shouldReduceUsableHeightByCoverHeight` to true.\n * @default false\n * @optional\n */\n shouldUseUsableHeight?: boolean;\n}\n\nconst GlobalStyle = createGlobalStyle`\n *, *::before, *::after {\n box-sizing: border-box;\n }\n`;\n\nconst PageProvider: FC<PageProviderProps> = ({\n children,\n color,\n colorMode,\n secondaryColor,\n siteId,\n style = {},\n shouldReduceUsableHeightByCoverHeight = false,\n shouldRemovePadding = false,\n shouldUseUsableHeight = false,\n iconColor,\n customVariables,\n}) => {\n const { runtimeEnvironment } = useEnvironment();\n\n const usableHeight = useUsableHeight({\n shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight,\n });\n\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6, 8].includes(\n runtimeEnvironment as number,\n );\n\n return (\n <StyledPageProvider\n className=\"page-provider\"\n $shouldUsePadding={shouldUsePadding}\n $usableHeight={shouldUseUsableHeight ? usableHeight : undefined}\n >\n <ColorSchemeProvider\n color={color}\n secondaryColor={secondaryColor}\n colorMode={colorMode}\n siteId={siteId}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n customVariables={customVariables}\n iconColor={iconColor}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n </StyledPageProvider>\n );\n};\nPageProvider.displayName = 'PageProvider';\n\nexport default PageProvider;\n"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,YAAY;AAC9D,OAAOC,KAAK,MAAc,OAAO;AACjC,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,OAAOC,mBAAmB,MAEnB,8CAA8C;AACrD,SAASC,kBAAkB,QAAQ,uBAAuB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA,MAAMC,WAAW,GAAGJ,iBAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMK,YAAmC,GAAGA,CAAC;EACzCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,cAAc;EACdC,MAAM;EACNC,KAAK,GAAG,CAAC,CAAC;EACVC,qCAAqC,GAAG,KAAK;EAC7CC,mBAAmB,GAAG,KAAK;EAC3BC,qBAAqB,GAAG,KAAK;EAC7BC,SAAS;EACTC;AACJ,CAAC,KAAK;EACF,MAAM;IAAEC;EAAmB,CAAC,GAAGnB,cAAc,CAAC,CAAC;EAE/C,MAAMoB,YAAY,GAAGjB,eAAe,CAAC;IACjCkB,yBAAyB,EAAEP;EAC/B,CAAC,CAAC;EAEF,MAAMQ,gBAAgB,GAClB,CAACP,mBAAmB,IACpB,CAAC,CAAChB,iBAAiB,CAACwB,cAAc,EAAExB,iBAAiB,CAACyB,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC,CAACC,QAAQ,CACjFN,kBACJ,CAAC;EAEL,oBACIlB,KAAA,CAAAyB,aAAA,CAACrB,kBAAkB;IACfsB,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAEN,gBAAiB;IACpCO,aAAa,EAAEb,qBAAqB,GAAGI,YAAY,GAAGU;EAAU,gBAEhE7B,KAAA,CAAAyB,aAAA,CAACtB,mBAAmB;IAChBK,KAAK,EAAEA,KAAM;IACbE,cAAc,EAAEA,cAAe;IAC/BD,SAAS,EAAEA,SAAU;IACrBE,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEkB,MAAM,EAAE;IAAO,CAAC,GAAGlB,KAAM;IACpEK,eAAe,EAAEA,eAAgB;IACjCD,SAAS,EAAEA;EAAU,GAEpBT,QACgB,CAAC,eACtBP,KAAA,CAAAyB,aAAA,CAACpB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDC,YAAY,CAACyB,WAAW,GAAG,cAAc;AAEzC,eAAezB,YAAY","ignoreList":[]}
@@ -2,7 +2,7 @@ import { useDevice } from 'chayns-api';
2
2
  import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
3
  import { useTheme } from 'styled-components';
4
4
  import { calculateContentHeight } from '../../utils/calculate';
5
- import { searchList } from '../../utils/searchBox';
5
+ import { searchList, sortSearchBoxItems } from '../../utils/searchBox';
6
6
  import Icon from '../icon/Icon';
7
7
  import Input from '../input/Input';
8
8
  import GroupName from './group-name/GroupName';
@@ -13,6 +13,35 @@ import { StyledSearchBox, StyledSearchBoxHintText, StyledSearchBoxIcon, StyledSe
13
13
  import { useUuid } from '../../hooks/uuid';
14
14
  import DropdownBodyWrapper from '../dropdown-body-wrapper/DropdownBodyWrapper';
15
15
  import TagInput from '../tag-input/TagInput';
16
+ const filterSearchBoxItems = ({
17
+ customFilter,
18
+ items,
19
+ searchString,
20
+ shouldUseCustomFilterOnly
21
+ }) => {
22
+ if (typeof customFilter !== 'function') {
23
+ return searchList({
24
+ items,
25
+ searchString
26
+ });
27
+ }
28
+ if (shouldUseCustomFilterOnly) {
29
+ const filteredItems = items.filter(customFilter);
30
+ return sortSearchBoxItems({
31
+ items: filteredItems,
32
+ searchString
33
+ });
34
+ }
35
+ return searchList({
36
+ items,
37
+ searchString
38
+ }).filter(customFilter);
39
+ };
40
+ const getDropdownSearchString = ({
41
+ selectedId,
42
+ shouldKeepSelectedItemPosition,
43
+ value
44
+ }) => shouldKeepSelectedItemPosition && selectedId ? '' : value;
16
45
  const SearchBox = /*#__PURE__*/forwardRef(({
17
46
  container,
18
47
  customFilter,
@@ -20,6 +49,7 @@ const SearchBox = /*#__PURE__*/forwardRef(({
20
49
  isInvalid = false,
21
50
  leftIcons,
22
51
  lists,
52
+ maxHeight = 300,
23
53
  onBlur,
24
54
  onChange,
25
55
  onKeyDown,
@@ -29,8 +59,11 @@ const SearchBox = /*#__PURE__*/forwardRef(({
29
59
  hintText,
30
60
  selectedId,
31
61
  shouldAddInputToList = true,
62
+ shouldKeepSelectedItemPosition = false,
63
+ shouldUseCustomFilterOnly = false,
32
64
  shouldHideFilterButtons = false,
33
65
  shouldShowContentOnEmptyInput = true,
66
+ shouldShowSmallItems = false,
34
67
  shouldShowRoundImage,
35
68
  shouldShowToggleIcon = false,
36
69
  tagInputSettings
@@ -54,6 +87,11 @@ const SearchBox = /*#__PURE__*/forwardRef(({
54
87
  const isAnimatingRef = useRef(false);
55
88
  const shouldShowPresetValue = useRef(typeof presetValue === 'string' && presetValue !== '');
56
89
  const theme = useTheme();
90
+ const dropdownSearchString = getDropdownSearchString({
91
+ selectedId,
92
+ shouldKeepSelectedItemPosition,
93
+ value
94
+ });
57
95
  const {
58
96
  isTouch
59
97
  } = useDevice();
@@ -101,9 +139,11 @@ const SearchBox = /*#__PURE__*/forwardRef(({
101
139
  list,
102
140
  groupName
103
141
  }) => {
104
- const newList = searchList({
142
+ const newList = filterSearchBoxItems({
143
+ customFilter,
105
144
  items: list,
106
- searchString: value
145
+ searchString: dropdownSearchString,
146
+ shouldUseCustomFilterOnly
107
147
  });
108
148
  if (newList.length > 0) {
109
149
  newMatchingItems.push({
@@ -124,15 +164,15 @@ const SearchBox = /*#__PURE__*/forwardRef(({
124
164
  }) => ({
125
165
  groupName,
126
166
  list: list.filter(item => {
127
- if (typeof customFilter === 'function') {
128
- return customFilter(item);
167
+ if (typeof customFilter === 'function' && shouldUseCustomFilterOnly) {
168
+ return true;
129
169
  }
130
- return !(newMatchingItems.length === 1 && item.text === value);
170
+ return !(newMatchingItems.length === 1 && item.text === dropdownSearchString);
131
171
  })
132
172
  }));
133
173
  setMatchingListsItems(filteredMatchingListItems);
134
174
  return newLists;
135
- }, [groups, lists, customFilter, shouldAddInputToList, value]);
175
+ }, [groups, lists, customFilter, dropdownSearchString, shouldAddInputToList, shouldUseCustomFilterOnly]);
136
176
  const handleOpen = useCallback(() => {
137
177
  setShouldShowBody(true);
138
178
  }, []);
@@ -216,9 +256,11 @@ const SearchBox = /*#__PURE__*/forwardRef(({
216
256
  list,
217
257
  groupName
218
258
  }) => {
219
- const newList = searchList({
259
+ const newList = filterSearchBoxItems({
260
+ customFilter,
220
261
  items: list,
221
- searchString: value
262
+ searchString: dropdownSearchString,
263
+ shouldUseCustomFilterOnly
222
264
  });
223
265
  if (newList.length > 0) {
224
266
  newMatchingItems.push({
@@ -239,10 +281,10 @@ const SearchBox = /*#__PURE__*/forwardRef(({
239
281
  }) => ({
240
282
  groupName,
241
283
  list: list.filter(item => {
242
- if (typeof customFilter === 'function') {
243
- return customFilter(item);
284
+ if (typeof customFilter === 'function' && shouldUseCustomFilterOnly) {
285
+ return true;
244
286
  }
245
- return !(newMatchingItems.length === 1 && item.text === value);
287
+ return !(newMatchingItems.length === 1 && item.text === dropdownSearchString);
246
288
  })
247
289
  }));
248
290
  setMatchingListsItems(filteredMatchingListItems);
@@ -250,7 +292,7 @@ const SearchBox = /*#__PURE__*/forwardRef(({
250
292
  handleOpen();
251
293
  }
252
294
  }
253
- }, [shouldShowContentOnEmptyInput, activeList, shouldAddInputToList, hintText, value, customFilter, handleOpen]);
295
+ }, [shouldShowContentOnEmptyInput, activeList, shouldAddInputToList, hintText, dropdownSearchString, customFilter, shouldUseCustomFilterOnly, handleOpen]);
254
296
 
255
297
  /**
256
298
  * This function filters the lists by input
@@ -262,9 +304,11 @@ const SearchBox = /*#__PURE__*/forwardRef(({
262
304
  list,
263
305
  groupName
264
306
  }) => {
265
- const newList = searchList({
307
+ const newList = filterSearchBoxItems({
308
+ customFilter,
266
309
  items: list,
267
- searchString: value
310
+ searchString: dropdownSearchString,
311
+ shouldUseCustomFilterOnly
268
312
  });
269
313
  if (newList.length > 0) {
270
314
  newMatchingItems.push({
@@ -292,7 +336,7 @@ const SearchBox = /*#__PURE__*/forwardRef(({
292
336
  });
293
337
  });
294
338
  }
295
- }, [inputToListValue, activeList, shouldAddInputToList, shouldShowContentOnEmptyInput, value]);
339
+ }, [inputToListValue, activeList, shouldAddInputToList, shouldShowContentOnEmptyInput, dropdownSearchString, customFilter, shouldUseCustomFilterOnly]);
296
340
  const handleClick = useCallback(() => {
297
341
  if (shouldShowBody) {
298
342
  handleClose();
@@ -325,9 +369,11 @@ const SearchBox = /*#__PURE__*/forwardRef(({
325
369
  list,
326
370
  groupName
327
371
  }) => {
328
- const newList = searchList({
372
+ const newList = filterSearchBoxItems({
373
+ customFilter,
329
374
  items: list,
330
- searchString: event.target.value
375
+ searchString: event.target.value,
376
+ shouldUseCustomFilterOnly
331
377
  });
332
378
  if (newList.length > 0) {
333
379
  filteredLists.push({
@@ -356,7 +402,7 @@ const SearchBox = /*#__PURE__*/forwardRef(({
356
402
  if (typeof onChange === 'function') {
357
403
  onChange(event);
358
404
  }
359
- }, [activeList, handleOpen, onChange, shouldAddInputToList, shouldShowContentOnEmptyInput]);
405
+ }, [activeList, customFilter, handleOpen, onChange, shouldAddInputToList, shouldShowContentOnEmptyInput, shouldUseCustomFilterOnly]);
360
406
 
361
407
  /**
362
408
  * This function handles the blur event of the input
@@ -427,6 +473,7 @@ const SearchBox = /*#__PURE__*/forwardRef(({
427
473
  id: id,
428
474
  text: text,
429
475
  imageUrl: imageUrl,
476
+ shouldShowSmallItems: shouldShowSmallItems,
430
477
  shouldShowRoundImage: shouldShowRoundImage,
431
478
  onSelect: handleSelect,
432
479
  groupName: groupName,
@@ -438,12 +485,13 @@ const SearchBox = /*#__PURE__*/forwardRef(({
438
485
  items.push(/*#__PURE__*/React.createElement(SearchBoxItem, {
439
486
  id: "input-value",
440
487
  onSelect: handleSelect,
488
+ shouldShowSmallItems: shouldShowSmallItems,
441
489
  text: `<b>${inputToListValue}</b`,
442
490
  tabIndex: items.length === 0 ? 0 : -1
443
491
  }));
444
492
  }
445
493
  return items;
446
- }, [hintText, matchingListsItems, shouldAddInputToList, inputToListValue, value, hasMultipleGroups, shouldShowRoundImage, handleSelect]);
494
+ }, [hintText, matchingListsItems, shouldAddInputToList, inputToListValue, value, hasMultipleGroups, shouldShowSmallItems, shouldShowRoundImage, handleSelect]);
447
495
  useEffect(() => {
448
496
  const handleKeyDown = e => {
449
497
  if (!shouldShowBody || matchingListsItems.length === 0) {
@@ -571,13 +619,14 @@ const SearchBox = /*#__PURE__*/forwardRef(({
571
619
  }, /*#__PURE__*/React.createElement(SearchBoxBody, {
572
620
  filterButtons: filterButtons,
573
621
  height: height,
622
+ maxHeight: maxHeight,
574
623
  shouldShow: shouldShowDropdown,
575
624
  key: `search-box-body-${uuid}`,
576
625
  onGroupSelect: handleFilterButtonsGroupSelect,
577
626
  ref: contentRef,
578
627
  selectedGroups: groups,
579
628
  shouldHideFilterButtons: shouldHideFilterButtons
580
- }, content))), [container, content, dropdownDirection, filterButtons, groups, handleBlur, handleChange, handleClose, handleDropdownOutsideClick, handleFocus, height, isInvalid, leftElement, onKeyDown, placeholder, rightElement, shouldHideFilterButtons, shouldShowDropdown, tagInputSettings, uuid, value]);
629
+ }, content))), [container, content, dropdownDirection, filterButtons, groups, handleBlur, handleChange, handleClose, handleDropdownOutsideClick, handleFocus, height, isInvalid, leftElement, maxHeight, onKeyDown, placeholder, rightElement, shouldHideFilterButtons, shouldShowDropdown, tagInputSettings, uuid, value]);
581
630
  });
582
631
  SearchBox.displayName = 'SearchBox';
583
632
  export default SearchBox;