@chayns-components/core 5.6.11 → 5.6.14

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 (48) hide show
  1. package/AGENTS.md +13 -0
  2. package/lib/cjs/components/popup/Popup.js +52 -38
  3. package/lib/cjs/components/popup/Popup.js.map +1 -1
  4. package/lib/cjs/components/popup/Popup.styles.js +11 -1
  5. package/lib/cjs/components/popup/Popup.styles.js.map +1 -1
  6. package/lib/cjs/components/popup/Popup.test.js +259 -0
  7. package/lib/cjs/components/popup/Popup.test.js.map +1 -0
  8. package/lib/cjs/components/popup/Popup.types.js.map +1 -1
  9. package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +2 -2
  10. package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
  11. package/lib/cjs/components/popup/popupPosition.js +33 -0
  12. package/lib/cjs/components/popup/popupPosition.js.map +1 -0
  13. package/lib/cjs/components/popup/popupPosition.test.js +47 -0
  14. package/lib/cjs/components/popup/popupPosition.test.js.map +1 -0
  15. package/lib/cjs/components/search-box/SearchBox.js +1 -2
  16. package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
  17. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.js +2 -1
  18. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.js.map +1 -1
  19. package/lib/cjs/utils/searchBox.js +3 -1
  20. package/lib/cjs/utils/searchBox.js.map +1 -1
  21. package/lib/cjs/utils/searchBox.test.js +13 -0
  22. package/lib/cjs/utils/searchBox.test.js.map +1 -1
  23. package/lib/esm/components/popup/Popup.js +54 -40
  24. package/lib/esm/components/popup/Popup.js.map +1 -1
  25. package/lib/esm/components/popup/Popup.styles.js +10 -0
  26. package/lib/esm/components/popup/Popup.styles.js.map +1 -1
  27. package/lib/esm/components/popup/Popup.test.js +254 -0
  28. package/lib/esm/components/popup/Popup.test.js.map +1 -0
  29. package/lib/esm/components/popup/Popup.types.js.map +1 -1
  30. package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +2 -2
  31. package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
  32. package/lib/esm/components/popup/popupPosition.js +26 -0
  33. package/lib/esm/components/popup/popupPosition.js.map +1 -0
  34. package/lib/esm/components/popup/popupPosition.test.js +45 -0
  35. package/lib/esm/components/popup/popupPosition.test.js.map +1 -0
  36. package/lib/esm/components/search-box/SearchBox.js +2 -3
  37. package/lib/esm/components/search-box/SearchBox.js.map +1 -1
  38. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.js +2 -1
  39. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.js.map +1 -1
  40. package/lib/esm/utils/searchBox.js +1 -0
  41. package/lib/esm/utils/searchBox.js.map +1 -1
  42. package/lib/esm/utils/searchBox.test.js +14 -1
  43. package/lib/esm/utils/searchBox.test.js.map +1 -1
  44. package/lib/types/components/popup/Popup.styles.d.ts +3 -0
  45. package/lib/types/components/popup/Popup.types.d.ts +16 -0
  46. package/lib/types/components/popup/popupPosition.d.ts +15 -0
  47. package/lib/types/utils/searchBox.d.ts +1 -0
  48. package/package.json +2 -2
@@ -31,6 +31,7 @@ const SearchBoxItem = ({
31
31
  idString = `_${groupName}`;
32
32
  }
33
33
  return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_SearchBoxItem.StyledSearchBoxItem, {
34
+ "data-search-box-item-id": id,
34
35
  id: idString,
35
36
  onClick: handleClick,
36
37
  tabIndex: tabIndex
@@ -42,7 +43,7 @@ const SearchBoxItem = ({
42
43
  dangerouslySetInnerHTML: {
43
44
  __html: text
44
45
  }
45
- })), [handleClick, idString, imageUrl, shouldShowRoundImage, shouldShowSmallItems, text, tabIndex]);
46
+ })), [handleClick, id, idString, imageUrl, shouldShowRoundImage, shouldShowSmallItems, text, tabIndex]);
46
47
  };
47
48
  SearchBoxItem.displayName = 'SearchBoxItem';
48
49
  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","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,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,IAA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5CoB,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":[]}
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\n data-search-box-item-id={id}\n id={idString}\n onClick={handleClick}\n tabIndex={tabIndex}\n >\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 id,\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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;IAC5BA,EAAE,EAAEa,QAAS;IACbI,OAAO,EAAET,WAAY;IACrBD,QAAQ,EAAEA;EAAS,GAElBL,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,EACXR,EAAE,EACFa,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":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.sortSearchBoxItems = exports.searchList = exports.getCurrentGroupName = void 0;
6
+ exports.sortSearchBoxItems = exports.searchList = exports.getSearchBoxItemId = 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,8 @@ const getCurrentGroupName = element => {
44
44
  return currentGroupName;
45
45
  };
46
46
  exports.getCurrentGroupName = getCurrentGroupName;
47
+ const getSearchBoxItemId = element => element.dataset.searchBoxItemId ?? element.id.replace('search-box-item__', '');
48
+ exports.getSearchBoxItemId = getSearchBoxItemId;
47
49
  const sortSearchBoxItems = ({
48
50
  customSortFunction,
49
51
  searchString,
@@ -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","sortSearchBoxItems","customSortFunction","searchString","items","sort","lowercaseSearchString","toLowerCase","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\nexport type SearchBoxSortFunction = (a: ISearchBoxItem, b: ISearchBoxItem) => number;\n\ninterface SearchListOptions {\n customSortFunction?: SearchBoxSortFunction;\n items: ISearchBoxItem[];\n searchString: string;\n}\n\nexport const sortSearchBoxItems = ({\n customSortFunction,\n searchString,\n items,\n}: SearchListOptions) => {\n if (customSortFunction) {\n return [...items].sort(customSortFunction);\n }\n\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 = ({ customSortFunction, 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({ customSortFunction, 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,gBAAgB,GAAG,KAAK;EAC5B,IAAIC,gBAAgB,GAAG,EAAE;EAEzB,MAAM;IAAEC,GAAG,EAAEC;EAAU,CAAC,GAAGJ,OAAO,CAACK,qBAAqB,CAAC,CAAC;EAC1D,MAAM;IAAEC;EAAS,CAAC,GAAGN,OAAO;EAE5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kB,CAAC;IAAEC,kBAAkB;IAAEE,KAAK,EAAEU,aAAa;IAAEX;EAAa,CAAC,CAAC;AACzF,CAAC;AAACH,OAAA,CAAAa,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","getSearchBoxItemId","dataset","searchBoxItemId","replace","sortSearchBoxItems","customSortFunction","searchString","items","sort","lowercaseSearchString","toLowerCase","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\nexport const getSearchBoxItemId = (element: Element) =>\n (element as HTMLElement).dataset.searchBoxItemId ??\n element.id.replace('search-box-item__', '');\n\nexport type SearchBoxSortFunction = (a: ISearchBoxItem, b: ISearchBoxItem) => number;\n\ninterface SearchListOptions {\n customSortFunction?: SearchBoxSortFunction;\n items: ISearchBoxItem[];\n searchString: string;\n}\n\nexport const sortSearchBoxItems = ({\n customSortFunction,\n searchString,\n items,\n}: SearchListOptions) => {\n if (customSortFunction) {\n return [...items].sort(customSortFunction);\n }\n\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 = ({ customSortFunction, 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({ customSortFunction, 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,O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IAAIS,aAAa,CAACC,QAAQ,CAACX,qBAAqB,CAAC,EAAE;MAC/C,IAAIH,YAAY,KAAK,EAAE,EAAE;QACrBW,aAAa,CAACI,IAAI,CAACH,IAAI,CAAC;MAC5B,CAAC,MAAM;QACH,MAAMhD,UAAU,GAAGiD,aAAa,CAACG,OAAO,CAACb,qBAAqB,CAAC;QAC/D,MAAMc,eAAe,GAAGvD,gBAAgB,CACpCkD,IAAI,CAACjD,IAAI,EACTC,UAAU,EACVoC,YAAY,CAACnC,MACjB,CAAC;QACD8C,aAAa,CAACI,IAAI,CAAC;UAAE,GAAGH,IAAI;UAAEjD,IAAI,EAAEsD;QAAgB,CAAC,CAAC;MAC1D;IACJ;EACJ,CAAC,CAAC;EAEF,OAAOnB,kBAAkB,CAAC;IAAEC,kBAAkB;IAAEE,KAAK,EAAEU,aAAa;IAAEX;EAAa,CAAC,CAAC;AACzF,CAAC;AAACP,OAAA,CAAAiB,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -51,4 +51,17 @@ const items = [{
51
51
  (0, _vitest.expect)(values).toEqual(['does-not-match', 'does-not-match']);
52
52
  });
53
53
  });
54
+ (0, _vitest.describe)('getSearchBoxItemId', () => {
55
+ (0, _vitest.it)('uses the item ID instead of the group-specific DOM ID', () => {
56
+ const element = document.createElement('div');
57
+ element.id = '_Food';
58
+ element.dataset.searchBoxItemId = 'pizza';
59
+ (0, _vitest.expect)((0, _searchBox.getSearchBoxItemId)(element)).toBe('pizza');
60
+ });
61
+ (0, _vitest.it)('uses the legacy DOM ID when no item ID is available', () => {
62
+ const element = document.createElement('div');
63
+ element.id = 'search-box-item__pizza';
64
+ (0, _vitest.expect)((0, _searchBox.getSearchBoxItemId)(element)).toBe('pizza');
65
+ });
66
+ });
54
67
  //# sourceMappingURL=searchBox.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"searchBox.test.js","names":["_vitest","require","_SearchBox","_searchBox","items","id","text","describe","it","result","searchList","customSortFunction","a","b","localeCompare","searchString","expect","map","toEqual","values","filterSearchBoxItems","customFilter","value","push","shouldUseCustomFilterOnly"],"sources":["../../../src/utils/searchBox.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport type { ISearchBoxItem } from '../types/searchBox';\nimport { filterSearchBoxItems } from '../components/search-box/SearchBox';\nimport { searchList } from './searchBox';\n\nconst items: ISearchBoxItem[] = [\n { id: '2', text: 'Zweite' },\n { id: '1', text: 'Erste' },\n];\n\ndescribe('searchList', () => {\n it('uses the custom sort function instead of the default sort', () => {\n const result = searchList({\n customSortFunction: (a, b) => b.id.localeCompare(a.id),\n items,\n searchString: '',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['2', '1']);\n });\n\n it('still filters before applying the custom sort function', () => {\n const result = searchList({\n customSortFunction: (a, b) => a.id.localeCompare(b.id),\n items,\n searchString: 'e',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['1', '2']);\n });\n\n it('uses only the custom filter when shouldUseCustomFilterOnly is enabled', () => {\n const values: string[] = [];\n const result = filterSearchBoxItems({\n customFilter: ({ id }, value) => {\n values.push(value);\n return id === '2';\n },\n customSortFunction: (a, b) => a.id.localeCompare(b.id),\n items,\n searchString: 'does-not-match',\n shouldUseCustomFilterOnly: true,\n });\n\n expect(result.map(({ id }) => id)).toEqual(['2']);\n expect(values).toEqual(['does-not-match', 'does-not-match']);\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,MAAMG,KAAuB,GAAG,CAC5B;EAAEC,EAAE,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAS,CAAC,EAC3B;EAAED,EAAE,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAQ,CAAC,CAC7B;AAED,IAAAC,gBAAQ,EAAC,YAAY,EAAE,MAAM;EACzB,IAAAC,UAAE,EAAC,2DAA2D,EAAE,MAAM;IAClE,MAAMC,MAAM,GAAG,IA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C9BS,yBAAyB,EAAE;IAC/B,CAAC,CAAC;IAEF,IAAAR,cAAM,EAACP,MAAM,CAACQ,GAAG,CAAC,CAAC;MAAEZ;IAAG,CAAC,KAAKA,EAAE,CAAC,CAAC,CAACa,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;IACjD,IAAAF,cAAM,EAACG,MAAM,CAAC,CAACD,OAAO,CAAC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;EAChE,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"searchBox.test.js","names":["_vitest","require","_SearchBox","_searchBox","items","id","text","describe","it","result","searchList","customSortFunction","a","b","localeCompare","searchString","expect","map","toEqual","values","filterSearchBoxItems","customFilter","value","push","shouldUseCustomFilterOnly","element","document","createElement","dataset","searchBoxItemId","getSearchBoxItemId","toBe"],"sources":["../../../src/utils/searchBox.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport type { ISearchBoxItem } from '../types/searchBox';\nimport { filterSearchBoxItems } from '../components/search-box/SearchBox';\nimport { getSearchBoxItemId, searchList } from './searchBox';\n\nconst items: ISearchBoxItem[] = [\n { id: '2', text: 'Zweite' },\n { id: '1', text: 'Erste' },\n];\n\ndescribe('searchList', () => {\n it('uses the custom sort function instead of the default sort', () => {\n const result = searchList({\n customSortFunction: (a, b) => b.id.localeCompare(a.id),\n items,\n searchString: '',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['2', '1']);\n });\n\n it('still filters before applying the custom sort function', () => {\n const result = searchList({\n customSortFunction: (a, b) => a.id.localeCompare(b.id),\n items,\n searchString: 'e',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['1', '2']);\n });\n\n it('uses only the custom filter when shouldUseCustomFilterOnly is enabled', () => {\n const values: string[] = [];\n const result = filterSearchBoxItems({\n customFilter: ({ id }, value) => {\n values.push(value);\n return id === '2';\n },\n customSortFunction: (a, b) => a.id.localeCompare(b.id),\n items,\n searchString: 'does-not-match',\n shouldUseCustomFilterOnly: true,\n });\n\n expect(result.map(({ id }) => id)).toEqual(['2']);\n expect(values).toEqual(['does-not-match', 'does-not-match']);\n });\n});\n\ndescribe('getSearchBoxItemId', () => {\n it('uses the item ID instead of the group-specific DOM ID', () => {\n const element = document.createElement('div');\n element.id = '_Food';\n element.dataset.searchBoxItemId = 'pizza';\n\n expect(getSearchBoxItemId(element)).toBe('pizza');\n });\n\n it('uses the legacy DOM ID when no item ID is available', () => {\n const element = document.createElement('div');\n element.id = 'search-box-item__pizza';\n\n expect(getSearchBoxItemId(element)).toBe('pizza');\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,MAAMG,KAAuB,GAAG,CAC5B;EAAEC,EAAE,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAS,CAAC,EAC3B;EAAED,EAAE,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAQ,CAAC,CAC7B;AAED,IAAAC,gBAAQ,EAAC,YAAY,EAAE,MAAM;EACzB,IAAAC,UAAE,EAAC,2DAA2D,EAAE,MAAM;IAClE,MAAMC,MAAM,GAAG,IAAAC,qBAAU,EAAC;MACtBC,kBAAkB,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACR,EAAE,CAACS,aAAa,CAACF,CAAC,CAACP,EAAE,CAAC;MACtDD,KAAK;MACLW,YAAY,EAAE;IAClB,CAAC,CAAC;IAEF,IAAAC,cAAM,EAACP,MAAM,CAACQ,GAAG,CAAC,CAAC;MAAEZ;IAAG,CAAC,KAAKA,EAAE,CAAC,CAAC,CAACa,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;EAC1D,CAAC,CAAC;EAEF,IAAAV,UAAE,EAAC,wDAAwD,EAAE,MAAM;IAC/D,MAAMC,MAAM,GAAG,IAAAC,qBAAU,EAAC;MACtBC,kBAAkB,EAAEA,CAACC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7CF,OAAO,CAACpB,EAAE,GAAG,OAAO;IACpBoB,OAAO,CAACG,OAAO,CAACC,eAAe,GAAG,OAAO;IAEzC,IAAAb,cAAM,EAAC,IAAAc,6BAAkB,EAACL,OAAO,CAAC,CAAC,CAACM,IAAI,CAAC,OAAO,CAAC;EACrD,CAAC,CAAC;EAEF,IAAAvB,UAAE,EAAC,qDAAqD,EAAE,MAAM;IAC5D,MAAMiB,OAAO,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IAC7CF,OAAO,CAACpB,EAAE,GAAG,wBAAwB;IAErC,IAAAW,cAAM,EAAC,IAAAc,6BAAkB,EAACL,OAAO,CAAC,CAAC,CAACM,IAAI,CAAC,OAAO,CAAC;EACrD,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -1,14 +1,16 @@
1
1
  import { AnimatePresence } from 'motion/react';
2
- import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { useUuid } from '../../hooks/uuid';
5
5
  import { PopupAlignment } from '../../types/popup';
6
6
  import AreaContextProvider from '../area-provider/AreaContextProvider';
7
7
  import PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';
8
- import { StyledPopup } from './Popup.styles';
8
+ import { StyledPopup, StyledPopupInsetContent } from './Popup.styles';
9
+ import { getPopupInsetPosition, POPUP_HORIZONTAL_PADDING } from './popupPosition';
9
10
  import { useMeasuredClone } from '../../hooks/element';
10
11
  const Popup = /*#__PURE__*/forwardRef(({
11
12
  alignment,
13
+ boundaryInsets,
12
14
  content,
13
15
  onShow,
14
16
  container,
@@ -33,19 +35,29 @@ const Popup = /*#__PURE__*/forwardRef(({
33
35
  const [portal, setPortal] = useState();
34
36
  const [pseudoSize, setPseudoSize] = useState();
35
37
  const [newContainer, setNewContainer] = useState(container ?? null);
38
+ const [contentMaxWidth, setContentMaxWidth] = useState();
36
39
  const [contentMaxHeight, setContentMaxHeight] = useState(undefined);
37
40
  const timeout = useRef();
38
41
  const previousIsVisibleRef = useRef(false);
39
42
  const uuid = useUuid();
40
43
  const isControlled = typeof isOpen === 'boolean';
41
44
  const isPopupOpen = isControlled ? isOpen : isInternallyOpen;
45
+ const leftInset = Number.isFinite(boundaryInsets?.left) ? Math.max(0, boundaryInsets?.left ?? 0) : 0;
46
+ const rightInset = Number.isFinite(boundaryInsets?.right) ? Math.max(0, boundaryInsets?.right ?? 0) : 0;
47
+ const hasBoundaryInsets = leftInset > 0 || rightInset > 0;
48
+ const shouldWrapContent = boundaryInsets !== undefined;
49
+ const popupContent = useMemo(() => shouldWrapContent ? /*#__PURE__*/React.createElement(StyledPopupInsetContent, {
50
+ style: {
51
+ maxWidth: hasBoundaryInsets ? contentMaxWidth : undefined
52
+ }
53
+ }, content) : content, [content, contentMaxWidth, hasBoundaryInsets, shouldWrapContent]);
42
54
  const {
43
55
  height,
44
56
  width,
45
57
  measuredElement
46
58
  } = useMeasuredClone({
47
- content,
48
- shouldPreventTextWrapping: !shouldUseChildrenWidth
59
+ content: popupContent,
60
+ shouldPreventTextWrapping: !shouldUseChildrenWidth && !hasBoundaryInsets
49
61
  });
50
62
  const popupContentRef = useRef(null);
51
63
  const popupRef = useRef(null);
@@ -72,7 +84,7 @@ const Popup = /*#__PURE__*/forwardRef(({
72
84
  if (!newContainer) {
73
85
  return;
74
86
  }
75
- const HORIZONTAL_PADDING = 23;
87
+ const HORIZONTAL_PADDING = POPUP_HORIZONTAL_PADDING;
76
88
  const {
77
89
  height: pseudoHeight,
78
90
  width: pseudoWidth
@@ -97,44 +109,47 @@ const Popup = /*#__PURE__*/forwardRef(({
97
109
  const y = (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;
98
110
 
99
111
  // Use one coordinate space for all horizontal bounds checks.
100
- const boundaryLeft = element.scrollLeft;
101
- const boundaryWidth = containerWidth / zoomX;
112
+ const boundaryLeft = element.scrollLeft + leftInset;
113
+ const boundaryWidth = Math.max(0, containerWidth / zoomX - leftInset - rightInset);
114
+ setContentMaxWidth(hasBoundaryInsets ? Math.max(0, boundaryWidth - 2 * HORIZONTAL_PADDING) : undefined);
102
115
  const relativeX = x - boundaryLeft;
103
116
  const shouldShowBottom = pseudoHeight > childrenTop - 25 || alignment === PopupAlignment.BottomLeft || alignment === PopupAlignment.BottomRight || alignment === PopupAlignment.BottomCenter;
104
117
  const shouldForceRight = shouldShowBottom ? alignment === PopupAlignment.BottomRight : alignment === PopupAlignment.TopRight;
105
118
  const shouldUseCenterAlignment = shouldShowBottom ? alignment === PopupAlignment.BottomCenter : alignment === PopupAlignment.TopCenter;
106
119
  const hasEnoughSpaceForCenter = pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING && pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;
120
+ let nextAlignment;
121
+ let nextOffset = 0;
107
122
  if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {
108
- setInternalAlignment(shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter);
109
- setOffset(0);
110
- setCoordinates({
111
- x,
112
- y
113
- });
123
+ nextAlignment = shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter;
114
124
  } else {
115
- let isRight = false;
116
- if (pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight) {
117
- setInternalAlignment(shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight);
118
- isRight = true;
119
- } else {
120
- setInternalAlignment(shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft);
121
- }
122
- let newOffset;
125
+ const isRight = pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight;
123
126
  if (isRight) {
124
- newOffset = relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING) : 0;
127
+ nextAlignment = shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight;
128
+ nextOffset = relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING) : 0;
125
129
  } else {
130
+ nextAlignment = shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft;
126
131
  const right = boundaryWidth - relativeX;
127
- newOffset = right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING) : 0;
132
+ nextOffset = right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING) : 0;
128
133
  }
129
- setOffset(newOffset);
130
- const newX = x - newOffset;
131
- setCoordinates({
132
- x: newX,
133
- y
134
- });
135
134
  }
135
+ const position = hasBoundaryInsets ? getPopupInsetPosition({
136
+ alignment: nextAlignment,
137
+ anchorX: x,
138
+ boundaryLeft,
139
+ boundaryWidth,
140
+ width: pseudoWidth
141
+ }) : {
142
+ x: x - nextOffset,
143
+ offset: nextOffset
144
+ };
145
+ setInternalAlignment(nextAlignment);
146
+ setOffset(position.offset);
147
+ setCoordinates({
148
+ x: position.x,
149
+ y
150
+ });
136
151
  }
137
- }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);
152
+ }, [alignment, hasBoundaryInsets, leftInset, newContainer, pseudoSize, rightInset, shouldScrollWithContent, yOffset]);
138
153
  const handleShow = useCallback(() => {
139
154
  updatePopupPosition();
140
155
  if (isControlled) {
@@ -143,16 +158,15 @@ const Popup = /*#__PURE__*/forwardRef(({
143
158
  setIsInternallyOpen(true);
144
159
  }, [isControlled, updatePopupPosition]);
145
160
  useEffect(() => {
146
- if (isControlled) {
147
- if (isOpen) {
148
- updatePopupPosition();
149
- }
150
- return;
151
- }
152
- if (shouldBeOpen) {
161
+ if (!isControlled && shouldBeOpen) {
153
162
  handleShow();
154
163
  }
155
- }, [handleShow, isControlled, isOpen, shouldBeOpen, updatePopupPosition]);
164
+ }, [handleShow, isControlled, shouldBeOpen]);
165
+ useEffect(() => {
166
+ if (isPopupOpen) {
167
+ updatePopupPosition();
168
+ }
169
+ }, [isPopupOpen, updatePopupPosition]);
156
170
  const handleReposition = useCallback(() => {
157
171
  if (isPopupOpen) {
158
172
  updatePopupPosition();
@@ -274,8 +288,8 @@ const Popup = /*#__PURE__*/forwardRef(({
274
288
  onMouseEnter: handleMouseEnter
275
289
  }, /*#__PURE__*/React.createElement(AreaContextProvider, {
276
290
  shouldChangeColor: true
277
- }, content))), newContainer));
278
- }, [contentMaxHeight, internalAlignment, newContainer, content, coordinates, handleMouseEnter, handleMouseLeave, isPopupOpen, offset, pseudoSize?.width, uuid, shouldScrollWithContent]);
291
+ }, popupContent))), newContainer));
292
+ }, [contentMaxHeight, internalAlignment, newContainer, popupContent, coordinates, handleMouseEnter, handleMouseLeave, isPopupOpen, offset, pseudoSize?.width, uuid, shouldScrollWithContent]);
279
293
  return /*#__PURE__*/React.createElement(React.Fragment, null, measuredElement, /*#__PURE__*/React.createElement(StyledPopup, {
280
294
  className: "beta-chayns-popup",
281
295
  ref: popupRef,
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","names":["AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","createPortal","useUuid","PopupAlignment","AreaContextProvider","PopupContentWrapper","StyledPopup","useMeasuredClone","Popup","alignment","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","x","y","internalAlignment","setInternalAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxHeight","setContentMaxHeight","undefined","timeout","previousIsVisibleRef","uuid","isControlled","isPopupOpen","height","width","measuredElement","shouldPreventTextWrapping","popupContentRef","popupRef","current","el","element","closest","Element","updatePopupPosition","HORIZONTAL_PADDING","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","childrenCenterX","scrollLeft","scrollTop","boundaryLeft","boundaryWidth","relativeX","shouldShowBottom","BottomLeft","BottomRight","BottomCenter","shouldForceRight","TopRight","shouldUseCenterAlignment","TopCenter","hasEnoughSpaceForCenter","isRight","newOffset","right","newX","handleShow","handleReposition","window","addEventListener","removeEventListener","viewHeight","clientHeight","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","contains","target","handleDocumentKeyDown","key","hide","show","createElement","initial","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n forwardRef,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup } from './Popup.styles';\nimport { useMeasuredClone } from '../../hooks/element';\nimport type { PopupProps } from './Popup.types';\n\nexport type { PopupProps } from './Popup.types';\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n content,\n onShow,\n container,\n onHide,\n children,\n isOpen,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n shouldBeOpen = false,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isInternallyOpen, setIsInternallyOpen] = useState(shouldBeOpen);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n const previousIsVisibleRef = useRef(false);\n\n const uuid = useUuid();\n const isControlled = typeof isOpen === 'boolean';\n const isPopupOpen = isControlled ? isOpen : isInternallyOpen;\n\n const { height, width, measuredElement } = useMeasuredClone({\n content,\n shouldPreventTextWrapping: !shouldUseChildrenWidth,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const updatePopupPosition = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const HORIZONTAL_PADDING = 23;\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n const childrenCenterX = childrenLeft + childrenWidth / 2;\n const x = (childrenCenterX - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;\n\n // Use one coordinate space for all horizontal bounds checks.\n const boundaryLeft = element.scrollLeft;\n const boundaryWidth = containerWidth / zoomX;\n const relativeX = x - boundaryLeft;\n\n const shouldShowBottom =\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight ||\n alignment === PopupAlignment.BottomCenter;\n\n const shouldForceRight = shouldShowBottom\n ? alignment === PopupAlignment.BottomRight\n : alignment === PopupAlignment.TopRight;\n\n const shouldUseCenterAlignment = shouldShowBottom\n ? alignment === PopupAlignment.BottomCenter\n : alignment === PopupAlignment.TopCenter;\n\n const hasEnoughSpaceForCenter =\n pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING &&\n pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;\n\n if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter,\n );\n setOffset(0);\n setCoordinates({\n x,\n y,\n });\n } else {\n let isRight = false;\n\n if (pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight,\n );\n isRight = true;\n } else {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft,\n );\n }\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING\n ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING)\n : 0;\n } else {\n const right = boundaryWidth - relativeX;\n\n newOffset =\n right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING\n ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING)\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX,\n y,\n });\n }\n }\n }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);\n\n const handleShow = useCallback(() => {\n updatePopupPosition();\n\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(true);\n }, [isControlled, updatePopupPosition]);\n\n useEffect(() => {\n if (isControlled) {\n if (isOpen) {\n updatePopupPosition();\n }\n\n return;\n }\n\n if (shouldBeOpen) {\n handleShow();\n }\n }, [handleShow, isControlled, isOpen, shouldBeOpen, updatePopupPosition]);\n\n const handleReposition = useCallback(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n window.addEventListener('resize', handleReposition);\n window.addEventListener('scroll', handleReposition, true);\n\n return () => {\n window.removeEventListener('resize', handleReposition);\n window.removeEventListener('scroll', handleReposition, true);\n };\n }, [handleReposition, isPopupOpen]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n if (isControlled) {\n return;\n }\n\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(false);\n }, [isControlled]);\n\n const handleMouseEnter = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, isControlled, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, isControlled, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n const handleDocumentKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n if (!isControlled && !shouldBeOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n document.addEventListener('keydown', handleDocumentKeyDown);\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n document.removeEventListener('keydown', handleDocumentKeyDown);\n };\n }, [\n handleDocumentClick,\n handleDocumentKeyDown,\n handleHide,\n isControlled,\n isPopupOpen,\n shouldBeOpen,\n ]);\n\n useEffect(() => {\n if (previousIsVisibleRef.current === isPopupOpen) {\n return;\n }\n\n previousIsVisibleRef.current = isPopupOpen;\n\n if (isPopupOpen) {\n onShow?.();\n\n return;\n }\n\n onHide?.();\n }, [isPopupOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isPopupOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isPopupOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAc;AAC9C,OAAOC,KAAK,IACRC,UAAU,EAEVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,cAAc,QAAoC,mBAAmB;AAC9E,OAAOC,mBAAmB,MAAM,sCAAsC;AACtE,OAAOC,mBAAmB,MAAM,6CAA6C;AAC7E,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,gBAAgB,QAAQ,qBAAqB;AAKtD,MAAMC,KAAK,gBAAGb,UAAU,CACpB,CACI;EACIc,SAAS;EACTC,OAAO;EACPC,MAAM;EACNC,SAAS;EACTC,MAAM;EACNC,QAAQ;EACRC,MAAM;EACNC,yBAAyB;EACzBC,iBAAiB,GAAG,KAAK;EACzBC,sBAAsB,GAAG,IAAI;EAC7BC,uBAAuB,GAAG,IAAI;EAC9BC,kBAAkB,GAAG,KAAK;EAC1BC,OAAO,GAAG,CAAC;EACXC,YAAY,GAAG;AAC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AChBb,iBAAiB,EACjBW,YAAY,EACZ7B,OAAO,EACPc,WAAW,EACXoF,gBAAgB,EAChBE,gBAAgB,EAChB9D,WAAW,EACXjB,MAAM,EACNM,UAAU,EAAEa,KAAK,EACjBJ,IAAI,EACJ3B,uBAAuB,CAC1B,CAAC;EAEF,oBACIzB,KAAA,CAAA8H,aAAA,CAAA9H,KAAA,CAAAoI,QAAA,QACK3E,eAAe,eAChBzD,KAAA,CAAA8H,aAAA,CAAClH,WAAW;IACRyH,SAAS,EAAC,mBAAmB;IAC7BxG,GAAG,EAAE+B,QAAS;IACd0E,OAAO,EAAEtB,mBAAoB;IAC7BiB,YAAY,EAAEb,gBAAiB;IAC/Bc,YAAY,EAAEhB,gBAAiB;IAC/BqB,uBAAuB,EAAE/G,sBAAuB;IAChDgH,mBAAmB,EAAE9G;EAAmB,GAEvCN,QACQ,CAAC,EACbqB,MACH,CAAC;AAEX,CACJ,CAAC;AAED3B,KAAK,CAAC2H,WAAW,GAAG,OAAO;AAE3B,eAAe3H,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Popup.js","names":["AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","createPortal","useUuid","PopupAlignment","AreaContextProvider","PopupContentWrapper","StyledPopup","StyledPopupInsetContent","getPopupInsetPosition","POPUP_HORIZONTAL_PADDING","useMeasuredClone","Popup","alignment","boundaryInsets","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","x","y","internalAlignment","setInternalAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxWidth","setContentMaxWidth","contentMaxHeight","setContentMaxHeight","undefined","timeout","previousIsVisibleRef","uuid","isControlled","isPopupOpen","leftInset","Number","isFinite","left","Math","max","rightInset","right","hasBoundaryInsets","shouldWrapContent","popupContent","createElement","style","maxWidth","height","width","measuredElement","shouldPreventTextWrapping","popupContentRef","popupRef","current","el","element","closest","Element","updatePopupPosition","HORIZONTAL_PADDING","pseudoHeight","pseudoWidth","childrenHeight","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","childrenCenterX","scrollLeft","scrollTop","boundaryLeft","boundaryWidth","relativeX","shouldShowBottom","BottomLeft","BottomRight","BottomCenter","shouldForceRight","TopRight","shouldUseCenterAlignment","TopCenter","hasEnoughSpaceForCenter","nextAlignment","nextOffset","isRight","position","anchorX","handleShow","handleReposition","window","addEventListener","removeEventListener","viewHeight","clientHeight","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","contains","target","handleDocumentKeyDown","key","hide","show","initial","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n forwardRef,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup, StyledPopupInsetContent } from './Popup.styles';\nimport { getPopupInsetPosition, POPUP_HORIZONTAL_PADDING } from './popupPosition';\nimport { useMeasuredClone } from '../../hooks/element';\nimport type { PopupProps } from './Popup.types';\n\nexport type { PopupProps } from './Popup.types';\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n boundaryInsets,\n content,\n onShow,\n container,\n onHide,\n children,\n isOpen,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n shouldBeOpen = false,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isInternallyOpen, setIsInternallyOpen] = useState(shouldBeOpen);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxWidth, setContentMaxWidth] = useState<number | undefined>();\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n const previousIsVisibleRef = useRef(false);\n\n const uuid = useUuid();\n const isControlled = typeof isOpen === 'boolean';\n const isPopupOpen = isControlled ? isOpen : isInternallyOpen;\n\n const leftInset = Number.isFinite(boundaryInsets?.left)\n ? Math.max(0, boundaryInsets?.left ?? 0)\n : 0;\n const rightInset = Number.isFinite(boundaryInsets?.right)\n ? Math.max(0, boundaryInsets?.right ?? 0)\n : 0;\n const hasBoundaryInsets = leftInset > 0 || rightInset > 0;\n const shouldWrapContent = boundaryInsets !== undefined;\n const popupContent = useMemo(\n () =>\n shouldWrapContent ? (\n <StyledPopupInsetContent\n style={{ maxWidth: hasBoundaryInsets ? contentMaxWidth : undefined }}\n >\n {content}\n </StyledPopupInsetContent>\n ) : (\n content\n ),\n [content, contentMaxWidth, hasBoundaryInsets, shouldWrapContent],\n );\n\n const { height, width, measuredElement } = useMeasuredClone({\n content: popupContent,\n shouldPreventTextWrapping: !shouldUseChildrenWidth && !hasBoundaryInsets,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const updatePopupPosition = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const HORIZONTAL_PADDING = POPUP_HORIZONTAL_PADDING;\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n const childrenCenterX = childrenLeft + childrenWidth / 2;\n const x = (childrenCenterX - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;\n\n // Use one coordinate space for all horizontal bounds checks.\n const boundaryLeft = element.scrollLeft + leftInset;\n const boundaryWidth = Math.max(0, containerWidth / zoomX - leftInset - rightInset);\n setContentMaxWidth(\n hasBoundaryInsets\n ? Math.max(0, boundaryWidth - 2 * HORIZONTAL_PADDING)\n : undefined,\n );\n const relativeX = x - boundaryLeft;\n\n const shouldShowBottom =\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight ||\n alignment === PopupAlignment.BottomCenter;\n\n const shouldForceRight = shouldShowBottom\n ? alignment === PopupAlignment.BottomRight\n : alignment === PopupAlignment.TopRight;\n\n const shouldUseCenterAlignment = shouldShowBottom\n ? alignment === PopupAlignment.BottomCenter\n : alignment === PopupAlignment.TopCenter;\n\n const hasEnoughSpaceForCenter =\n pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING &&\n pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;\n\n let nextAlignment: PopupAlignment;\n let nextOffset = 0;\n\n if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {\n nextAlignment = shouldShowBottom\n ? PopupAlignment.BottomCenter\n : PopupAlignment.TopCenter;\n } else {\n const isRight =\n pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight;\n if (isRight) {\n nextAlignment = shouldShowBottom\n ? PopupAlignment.BottomRight\n : PopupAlignment.TopRight;\n nextOffset =\n relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING\n ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING)\n : 0;\n } else {\n nextAlignment = shouldShowBottom\n ? PopupAlignment.BottomLeft\n : PopupAlignment.TopLeft;\n const right = boundaryWidth - relativeX;\n nextOffset =\n right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING\n ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING)\n : 0;\n }\n }\n\n const position = hasBoundaryInsets\n ? getPopupInsetPosition({\n alignment: nextAlignment,\n anchorX: x,\n boundaryLeft,\n boundaryWidth,\n width: pseudoWidth,\n })\n : { x: x - nextOffset, offset: nextOffset };\n\n setInternalAlignment(nextAlignment);\n setOffset(position.offset);\n setCoordinates({ x: position.x, y });\n }\n }, [\n alignment,\n hasBoundaryInsets,\n leftInset,\n newContainer,\n pseudoSize,\n rightInset,\n shouldScrollWithContent,\n yOffset,\n ]);\n\n const handleShow = useCallback(() => {\n updatePopupPosition();\n\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(true);\n }, [isControlled, updatePopupPosition]);\n\n useEffect(() => {\n if (!isControlled && shouldBeOpen) {\n handleShow();\n }\n }, [handleShow, isControlled, shouldBeOpen]);\n\n useEffect(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n const handleReposition = useCallback(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n window.addEventListener('resize', handleReposition);\n window.addEventListener('scroll', handleReposition, true);\n\n return () => {\n window.removeEventListener('resize', handleReposition);\n window.removeEventListener('scroll', handleReposition, true);\n };\n }, [handleReposition, isPopupOpen]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n if (isControlled) {\n return;\n }\n\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(false);\n }, [isControlled]);\n\n const handleMouseEnter = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, isControlled, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, isControlled, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n const handleDocumentKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n if (!isControlled && !shouldBeOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n document.addEventListener('keydown', handleDocumentKeyDown);\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n document.removeEventListener('keydown', handleDocumentKeyDown);\n };\n }, [\n handleDocumentClick,\n handleDocumentKeyDown,\n handleHide,\n isControlled,\n isPopupOpen,\n shouldBeOpen,\n ]);\n\n useEffect(() => {\n if (previousIsVisibleRef.current === isPopupOpen) {\n return;\n }\n\n previousIsVisibleRef.current = isPopupOpen;\n\n if (isPopupOpen) {\n onShow?.();\n\n return;\n }\n\n onHide?.();\n }, [isPopupOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isPopupOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {popupContent}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n popupContent,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isPopupOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAc;AAC9C,OAAOC,KAAK,IACRC,UAAU,EAEVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,cAAc,QAAoC,mBAAmB;AAC9E,OAAOC,mBAAmB,MAAM,sCAAsC;AACtE,OAAOC,mBAAmB,MAAM,6CAA6C;AAC7E,SAASC,WAAW,EAAEC,uBAAuB,QAAQ,gBAAgB;AACrE,SAASC,qBAAqB,EAAEC,wBAAwB,QAAQ,iBAAiB;AACjF,SAASC,gBAAgB,QAAQ,qBAAqB;AAKtD,MAAMC,KAAK,gBAAGjB,UAAU,CACpB,CACI;EACIkB,SAAS;EACTC,cAAc;EACdC,OAAO;EACPC,MAAM;EACNC,SAAS;EACTC,MAAM;EACNC,QAAQ;EACRC,MAAM;EACNC,yBAAyB;EACzBC,iBAAiB,GAAG,KAAK;EACzBC,sBAAsB,GAAG,IAAI;EAC7BC,uBAAuB,GAAG,IAAI;EAC9BC,kBAAkB,GAAG,KAAK;EAC1BC,OAAO,GAAG,CAAC;EACXC,YAAY,GAAG;AACnB,CAAC,EACDC,GAAG,KACF;EACD,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG7B,QAAQ,CAAmB;IAC7D8B,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE;EACP,CAAC,CAAC;EAEF,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGjC,QAAQ,CACtDG,cAAc,CAAC+B,OACn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AAW,EACXnB,MAAM,EACNM,UAAU,EAAE6B,KAAK,EACjBlB,IAAI,EACJ7B,uBAAuB,CAC1B,CAAC;EAEF,oBACI9B,KAAA,CAAAyE,aAAA,CAAAzE,KAAA,CAAAwJ,QAAA,QACK1E,eAAe,eAChB9E,KAAA,CAAAyE,aAAA,CAAC5D,WAAW;IACR4I,SAAS,EAAC,mBAAmB;IAC7BvH,GAAG,EAAE+C,QAAS;IACdyE,OAAO,EAAErB,mBAAoB;IAC7BgB,YAAY,EAAEZ,gBAAiB;IAC/Ba,YAAY,EAAEf,gBAAiB;IAC/BoB,uBAAuB,EAAE9H,sBAAuB;IAChD+H,mBAAmB,EAAE7H;EAAmB,GAEvCN,QACQ,CAAC,EACbqB,MACH,CAAC;AAEX,CACJ,CAAC;AAED5B,KAAK,CAAC2I,WAAW,GAAG,OAAO;AAE3B,eAAe3I,KAAK","ignoreList":[]}
@@ -27,4 +27,14 @@ export const StyledPopupPseudo = styled.div`
27
27
  opacity: 0;
28
28
  position: absolute;
29
29
  `;
30
+
31
+ // Apply the same wrapping constraint to the measured clone and the visible content.
32
+ export const StyledPopupInsetContent = styled.div`
33
+ overflow-wrap: anywhere;
34
+
35
+ > * {
36
+ box-sizing: border-box;
37
+ max-width: 100%;
38
+ }
39
+ `;
30
40
  //# sourceMappingURL=Popup.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.styles.js","names":["styled","css","StyledPopup","span","$shouldUseFullWidth","$shouldUseChildrenWidth","StyledPopupPseudo","div","$menuHeight"],"sources":["../../../../src/components/popup/Popup.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledPopupProps = WithTheme<{\n $shouldUseChildrenWidth: boolean;\n $shouldUseFullWidth: boolean;\n}>;\n\nexport const StyledPopup = styled.span<StyledPopupProps>`\n cursor: pointer;\n position: relative;\n\n ${({ $shouldUseFullWidth }) =>\n $shouldUseFullWidth &&\n css`\n width: 100%;\n `};\n\n ${({ $shouldUseChildrenWidth }) =>\n $shouldUseChildrenWidth &&\n css`\n display: flex;\n width: fit-content;\n height: fit-content;\n `}\n`;\n\nexport const StyledPopupPseudo = styled.div<{\n $menuHeight: number;\n}>`\n top: ${({ $menuHeight }) => `${$menuHeight - 0}px`};\n left: 0;\n margin: 2px;\n pointer-events: none;\n opacity: 0;\n position: absolute;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAQ/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,IAAsB;AACxD;AACA;AACA;AACA,MAAM,CAAC;EAAEC;AAAoB,CAAC,KACtBA,mBAAmB,IACnBH,GAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEI;AAAwB,CAAC,KAC1BA,uBAAuB,IACvBJ,GAAG;AACX;AACA;AACA;AACA,SAAS;AACT,CAAC;AAED,OAAO,MAAMK,iBAAiB,GAAGN,MAAM,CAACO,GAEtC;AACF,WAAW,CAAC;EAAEC;AAAY,CAAC,KAAK,GAAGA,WAAW,GAAG,CAAC,IAAI;AACtD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Popup.styles.js","names":["styled","css","StyledPopup","span","$shouldUseFullWidth","$shouldUseChildrenWidth","StyledPopupPseudo","div","$menuHeight","StyledPopupInsetContent"],"sources":["../../../../src/components/popup/Popup.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledPopupProps = WithTheme<{\n $shouldUseChildrenWidth: boolean;\n $shouldUseFullWidth: boolean;\n}>;\n\nexport const StyledPopup = styled.span<StyledPopupProps>`\n cursor: pointer;\n position: relative;\n\n ${({ $shouldUseFullWidth }) =>\n $shouldUseFullWidth &&\n css`\n width: 100%;\n `};\n\n ${({ $shouldUseChildrenWidth }) =>\n $shouldUseChildrenWidth &&\n css`\n display: flex;\n width: fit-content;\n height: fit-content;\n `}\n`;\n\nexport const StyledPopupPseudo = styled.div<{\n $menuHeight: number;\n}>`\n top: ${({ $menuHeight }) => `${$menuHeight - 0}px`};\n left: 0;\n margin: 2px;\n pointer-events: none;\n opacity: 0;\n position: absolute;\n`;\n\n// Apply the same wrapping constraint to the measured clone and the visible content.\nexport const StyledPopupInsetContent = styled.div`\n overflow-wrap: anywhere;\n\n > * {\n box-sizing: border-box;\n max-width: 100%;\n }\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAQ/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,IAAsB;AACxD;AACA;AACA;AACA,MAAM,CAAC;EAAEC;AAAoB,CAAC,KACtBA,mBAAmB,IACnBH,GAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEI;AAAwB,CAAC,KAC1BA,uBAAuB,IACvBJ,GAAG;AACX;AACA;AACA;AACA,SAAS;AACT,CAAC;AAED,OAAO,MAAMK,iBAAiB,GAAGN,MAAM,CAACO,GAEtC;AACF,WAAW,CAAC;EAAEC;AAAY,CAAC,KAAK,GAAGA,WAAW,GAAG,CAAC,IAAI;AACtD;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA,OAAO,MAAMC,uBAAuB,GAAGT,MAAM,CAACO,GAAG;AACjD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}