@ably/ui 15.6.0-dev.274a3001 → 15.6.0-dev.b2d087a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/DropdownMenu.js +1 -1
- package/core/DropdownMenu.js.map +1 -1
- package/core/Flash.js +1 -1
- package/core/Flash.js.map +1 -1
- package/core/Flyout.js +1 -1
- package/core/Flyout.js.map +1 -1
- package/core/Header/HeaderLinks.js +1 -1
- package/core/Header/HeaderLinks.js.map +1 -1
- package/core/Header.js +1 -1
- package/core/Header.js.map +1 -1
- package/core/LegacyMeganav/MeganavBlogPostsList/component.js +2 -0
- package/core/LegacyMeganav/MeganavBlogPostsList/component.js.map +1 -0
- package/core/LegacyMeganav/MeganavControl/component.js +2 -0
- package/core/LegacyMeganav/MeganavControl/component.js.map +1 -0
- package/core/LegacyMeganav/MeganavControlMobileDropdown/component.js +2 -0
- package/core/LegacyMeganav/MeganavControlMobileDropdown/component.js.map +1 -0
- package/core/LegacyMeganav/MeganavControlMobilePanelClose/component.js +2 -0
- package/core/LegacyMeganav/MeganavControlMobilePanelClose/component.js.map +1 -0
- package/core/LegacyMeganav/MeganavControlMobilePanelOpen/component.js +2 -0
- package/core/LegacyMeganav/MeganavControlMobilePanelOpen/component.js.map +1 -0
- package/core/LegacyMeganav/MeganavSearchAutocomplete/component.js +2 -0
- package/core/LegacyMeganav/MeganavSearchAutocomplete/component.js.map +1 -0
- package/core/LegacyMeganav/MeganavSearchSuggestions/component.js +2 -0
- package/core/LegacyMeganav/MeganavSearchSuggestions/component.js.map +1 -0
- package/core/LegacyMeganav/component.js +2 -0
- package/core/{Meganav → LegacyMeganav}/component.js.map +1 -1
- package/core/LegacyMeganav.js +2 -0
- package/core/LegacyMeganav.js.map +1 -0
- package/core/Meganav/.DS_Store +0 -0
- package/core/Meganav/Meganav.js +2 -0
- package/core/Meganav/Meganav.js.map +1 -0
- package/core/Meganav/MeganavMobile.js +2 -0
- package/core/Meganav/MeganavMobile.js.map +1 -0
- package/core/Meganav/MeganavPanel.js +2 -0
- package/core/Meganav/MeganavPanel.js.map +1 -0
- package/core/Meganav/data.js +2 -0
- package/core/Meganav/data.js.map +1 -0
- package/core/Meganav/images/fan-engagement-nav-image.png +0 -0
- package/core/Meganav/images/founders-nav-image.png +0 -0
- package/core/MeganavBlogPostsList.js.map +1 -1
- package/core/MeganavContentCompany.js.map +1 -1
- package/core/MeganavContentDevelopers.js.map +1 -1
- package/core/MeganavContentProducts.js.map +1 -1
- package/core/MeganavContentUseCases.js.map +1 -1
- package/core/MeganavControl.js.map +1 -1
- package/core/MeganavControlMobileDropdown.js.map +1 -1
- package/core/MeganavItemsDesktop.js +1 -1
- package/core/MeganavItemsDesktop.js.map +1 -1
- package/core/MeganavItemsMobile.js +1 -1
- package/core/MeganavItemsMobile.js.map +1 -1
- package/core/MeganavItemsSignedIn.js.map +1 -1
- package/core/MeganavSearch.js.map +1 -1
- package/core/MeganavSearchPanel.js.map +1 -1
- package/core/MeganavSearchSuggestions.js.map +1 -1
- package/core/Notice.js +1 -1
- package/core/Notice.js.map +1 -1
- package/core/SignOutLink.js.map +1 -1
- package/core/images/award/g2-best-meets-requirements-2025.png +0 -0
- package/core/images/award/g2-best-support-2025.png +0 -0
- package/core/images/award/g2-high-performer-2025.png +0 -0
- package/core/images/award/g2-users-most-likely-to-recommend-2025.png +0 -0
- package/index.d.ts +250 -152
- package/package.json +9 -11
- package/core/Meganav/component.js +0 -2
- package/core/Meganav.js +0 -2
- package/core/Meganav.js.map +0 -1
- package/core/MeganavBlogPostsList/component.js +0 -2
- package/core/MeganavBlogPostsList/component.js.map +0 -1
- package/core/MeganavControl/component.js +0 -2
- package/core/MeganavControl/component.js.map +0 -1
- package/core/MeganavControlMobileDropdown/component.js +0 -2
- package/core/MeganavControlMobileDropdown/component.js.map +0 -1
- package/core/MeganavControlMobilePanelClose/component.js +0 -2
- package/core/MeganavControlMobilePanelClose/component.js.map +0 -1
- package/core/MeganavControlMobilePanelOpen/component.js +0 -2
- package/core/MeganavControlMobilePanelOpen/component.js.map +0 -1
- package/core/MeganavSearchAutocomplete/component.js +0 -2
- package/core/MeganavSearchAutocomplete/component.js.map +0 -1
- package/core/MeganavSearchSuggestions/component.js +0 -2
- package/core/MeganavSearchSuggestions/component.js.map +0 -1
- package/core/hooks/use-rails-ujs-hooks.js +0 -2
- package/core/hooks/use-rails-ujs-hooks.js.map +0 -1
- package/core/styles/colors/computed-colors.json +0 -1
- /package/core/{Meganav → LegacyMeganav}/component.css +0 -0
- /package/core/{Meganav → LegacyMeganav}/component.json +0 -0
package/core/DropdownMenu.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React,{createContext,useContext,useState,useEffect,useRef}from"react";import Icon from"./Icon";const DropdownMenuContext=createContext({isOpen:false,setOpen:()=>{}});const DropdownMenu=({children})=>{const[isOpen,setOpen]=useState(false);const ref=useRef(null);useEffect(()=>{const clickHandler=e=>{if(ref.current?.contains(e.target))return;setOpen(false)};document.addEventListener("click",clickHandler);return()=>
|
|
1
|
+
import React,{createContext,useContext,useState,useEffect,useRef}from"react";import Icon from"./Icon";import cn from"./utils/cn";const DropdownMenuContext=createContext({isOpen:false,setOpen:()=>{}});const DropdownMenu=({children})=>{const[isOpen,setOpen]=useState(false);const ref=useRef(null);useEffect(()=>{const clickHandler=e=>{if(ref.current?.contains(e.target))return;setOpen(false)};document.addEventListener("click",clickHandler);return()=>document.removeEventListener("click",clickHandler)},[]);return React.createElement(DropdownMenuContext.Provider,{value:{isOpen,setOpen}},React.createElement("div",{id:"dropdown-menu",className:"relative",ref:ref},children))};const Trigger=({children,triggerClassNames="",description})=>{const{isOpen,setOpen}=useContext(DropdownMenuContext);return React.createElement("button",{id:"menu-trigger","aria-label":description,role:"button",onClick:()=>setOpen(!isOpen),className:cn("flex items-center ui-text-button3 text-neutral-1000 dark:text-neutral-300 focus:outline-none",triggerClassNames)},children,React.createElement(Icon,{name:isOpen?"icon-gui-chevron-up-mini":"icon-gui-chevron-down-mini",size:"1.25rem",additionalCSS:"text-neutral-1300 dark:text-neutral-000"}))};const Content=({children,anchorPosition="right",contentClassNames})=>{const{isOpen}=useContext(DropdownMenuContext);if(!isOpen){return null}return React.createElement("div",{id:"menu-content",role:"menu",className:cn("flex flex-col absolute z-10 border border-neutral-400 dark:border-neutral-900 bg-neutral-000 dark:bg-neutral-1300 rounded-lg ui-shadow-md-soft",anchorPosition==="right"?"right-0":"left-0",contentClassNames)},children)};const Link=({url,title,subtitle,iconName,children})=>{return React.createElement("a",{href:url,className:"menu-link group block p-8 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-1200 active:bg-neutral-200 dark:active:bg-neutral-1100 text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 hover:dark:text-neutral-000"},React.createElement("p",{className:"mb-4"},title,iconName?React.createElement(Icon,{name:iconName,size:"1rem",additionalCSS:"align-middle ml-8 relative -top-1 -left-4 text-neutral-1300 dark:text-neutral-000"}):null),subtitle?React.createElement("p",{className:"ui-text-p3 mb-16"},subtitle):null,children)};DropdownMenu.Trigger=Trigger;DropdownMenu.Content=Content;DropdownMenu.Link=Link;export default DropdownMenu;
|
|
2
2
|
//# sourceMappingURL=DropdownMenu.js.map
|
package/core/DropdownMenu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/DropdownMenu.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useState,\n useEffect,\n useRef,\n ReactNode,\n Dispatch,\n} from \"react\";\nimport Icon from \"./Icon\";\nimport { IconName } from \"./Icon/types\";\n\nconst DropdownMenuContext = createContext<{\n isOpen: boolean;\n setOpen: Dispatch<React.SetStateAction<boolean>>;\n}>({\n isOpen: false,\n setOpen: () => {},\n});\n\ntype DropdownMenuProps = {\n children: ReactNode;\n};\n\ntype TriggerProps = {\n children: ReactNode;\n
|
|
1
|
+
{"version":3,"sources":["../../src/core/DropdownMenu.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useState,\n useEffect,\n useRef,\n ReactNode,\n Dispatch,\n} from \"react\";\nimport Icon from \"./Icon\";\nimport { IconName } from \"./Icon/types\";\nimport cn from \"./utils/cn\";\n\nconst DropdownMenuContext = createContext<{\n isOpen: boolean;\n setOpen: Dispatch<React.SetStateAction<boolean>>;\n}>({\n isOpen: false,\n setOpen: () => {},\n});\n\ntype DropdownMenuProps = {\n /**\n * The content to be displayed within the dropdown menu.\n */\n children: ReactNode;\n};\n\ntype TriggerProps = {\n /**\n * The content to be displayed within the trigger element.\n */\n children: ReactNode;\n /**\n * Additional class names to apply to the trigger element.\n */\n triggerClassNames?: string;\n /**\n * A description for the trigger element, used for accessibility purposes.\n */\n description?: string;\n};\n\ntype ContentProps = {\n /**\n * The content to be displayed within the dropdown menu.\n */\n children: ReactNode;\n /**\n * The position of the dropdown menu relative to the trigger element.\n * Defaults to \"right\".\n */\n anchorPosition?: string;\n /**\n * Additional class names to apply to the content container.\n */\n contentClassNames?: string;\n};\n\ntype LinkProps = {\n url: string;\n title: string;\n subtitle?: string;\n iconName?: IconName;\n children?: ReactNode;\n};\n\nconst DropdownMenu = ({ children }: DropdownMenuProps) => {\n const [isOpen, setOpen] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const clickHandler = (e: MouseEvent) => {\n if (ref.current?.contains(e.target as Node)) return;\n setOpen(false);\n };\n document.addEventListener(\"click\", clickHandler);\n return () => document.removeEventListener(\"click\", clickHandler);\n }, []);\n\n return (\n <DropdownMenuContext.Provider value={{ isOpen, setOpen }}>\n <div id=\"dropdown-menu\" className=\"relative\" ref={ref}>\n {children}\n </div>\n </DropdownMenuContext.Provider>\n );\n};\n\nconst Trigger = ({\n children,\n triggerClassNames = \"\",\n description,\n}: TriggerProps) => {\n const { isOpen, setOpen } = useContext(DropdownMenuContext);\n\n return (\n <button\n id=\"menu-trigger\"\n aria-label={description}\n role=\"button\"\n onClick={() => setOpen(!isOpen)}\n className={cn(\n \"flex items-center ui-text-button3 text-neutral-1000 dark:text-neutral-300 focus:outline-none\",\n triggerClassNames,\n )}\n >\n {children}\n <Icon\n name={\n isOpen ? \"icon-gui-chevron-up-mini\" : \"icon-gui-chevron-down-mini\"\n }\n size=\"1.25rem\"\n additionalCSS=\"text-neutral-1300 dark:text-neutral-000\"\n />\n </button>\n );\n};\n\nconst Content = ({\n children,\n anchorPosition = \"right\",\n contentClassNames,\n}: ContentProps) => {\n const { isOpen } = useContext(DropdownMenuContext);\n\n if (!isOpen) {\n return null;\n }\n\n return (\n <div\n id=\"menu-content\"\n role=\"menu\"\n className={cn(\n \"flex flex-col absolute z-10 border border-neutral-400 dark:border-neutral-900 bg-neutral-000 dark:bg-neutral-1300 rounded-lg ui-shadow-md-soft\",\n anchorPosition === \"right\" ? \"right-0\" : \"left-0\",\n contentClassNames,\n )}\n >\n {children}\n </div>\n );\n};\n\nconst Link = ({ url, title, subtitle, iconName, children }: LinkProps) => {\n return (\n <a\n href={url}\n className=\"menu-link group block p-8 rounded-lg\n hover:bg-neutral-100 dark:hover:bg-neutral-1200 active:bg-neutral-200 dark:active:bg-neutral-1100 text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 hover:dark:text-neutral-000\"\n >\n <p className=\"mb-4\">\n {title}\n {iconName ? (\n <Icon\n name={iconName}\n size=\"1rem\"\n additionalCSS=\"align-middle ml-8 relative -top-1 -left-4 text-neutral-1300 dark:text-neutral-000\"\n />\n ) : null}\n </p>\n {subtitle ? <p className=\"ui-text-p3 mb-16\">{subtitle}</p> : null}\n {children}\n </a>\n );\n};\n\nDropdownMenu.Trigger = Trigger;\nDropdownMenu.Content = Content;\nDropdownMenu.Link = Link;\n\nexport default DropdownMenu;\n"],"names":["React","createContext","useContext","useState","useEffect","useRef","Icon","cn","DropdownMenuContext","isOpen","setOpen","DropdownMenu","children","ref","clickHandler","e","current","contains","target","document","addEventListener","removeEventListener","Provider","value","div","id","className","Trigger","triggerClassNames","description","button","aria-label","role","onClick","name","size","additionalCSS","Content","anchorPosition","contentClassNames","Link","url","title","subtitle","iconName","a","href","p"],"mappings":"AAAA,OAAOA,OACLC,aAAa,CACbC,UAAU,CACVC,QAAQ,CACRC,SAAS,CACTC,MAAM,KAGD,OAAQ,AACf,QAAOC,SAAU,QAAS,AAE1B,QAAOC,OAAQ,YAAa,CAE5B,MAAMC,oBAAsBP,cAGzB,CACDQ,OAAQ,MACRC,QAAS,KAAO,CAClB,GAgDA,MAAMC,aAAe,CAAC,CAAEC,QAAQ,CAAqB,IACnD,KAAM,CAACH,OAAQC,QAAQ,CAAGP,SAAS,OACnC,MAAMU,IAAMR,OAAuB,MAEnCD,UAAU,KACR,MAAMU,aAAe,AAACC,IACpB,GAAIF,IAAIG,OAAO,EAAEC,SAASF,EAAEG,MAAM,EAAW,OAC7CR,QAAQ,MACV,EACAS,SAASC,gBAAgB,CAAC,QAASN,cACnC,MAAO,IAAMK,SAASE,mBAAmB,CAAC,QAASP,aACrD,EAAG,EAAE,EAEL,OACE,oBAACN,oBAAoBc,QAAQ,EAACC,MAAO,CAAEd,OAAQC,OAAQ,GACrD,oBAACc,OAAIC,GAAG,gBAAgBC,UAAU,WAAWb,IAAKA,KAC/CD,UAIT,EAEA,MAAMe,QAAU,CAAC,CACff,QAAQ,CACRgB,kBAAoB,EAAE,CACtBC,WAAW,CACE,IACb,KAAM,CAAEpB,MAAM,CAAEC,OAAO,CAAE,CAAGR,WAAWM,qBAEvC,OACE,oBAACsB,UACCL,GAAG,eACHM,aAAYF,YACZG,KAAK,SACLC,QAAS,IAAMvB,QAAQ,CAACD,QACxBiB,UAAWnB,GACT,+FACAqB,oBAGDhB,SACD,oBAACN,MACC4B,KACEzB,OAAS,2BAA6B,6BAExC0B,KAAK,UACLC,cAAc,4CAItB,EAEA,MAAMC,QAAU,CAAC,CACfzB,QAAQ,CACR0B,eAAiB,OAAO,CACxBC,iBAAiB,CACJ,IACb,KAAM,CAAE9B,MAAM,CAAE,CAAGP,WAAWM,qBAE9B,GAAI,CAACC,OAAQ,CACX,OAAO,IACT,CAEA,OACE,oBAACe,OACCC,GAAG,eACHO,KAAK,OACLN,UAAWnB,GACT,iJACA+B,iBAAmB,QAAU,UAAY,SACzCC,oBAGD3B,SAGP,EAEA,MAAM4B,KAAO,CAAC,CAAEC,GAAG,CAAEC,KAAK,CAAEC,QAAQ,CAAEC,QAAQ,CAAEhC,QAAQ,CAAa,IACnE,OACE,oBAACiC,KACCC,KAAML,IACNf,UAAU,sOAGV,oBAACqB,KAAErB,UAAU,QACVgB,MACAE,SACC,oBAACtC,MACC4B,KAAMU,SACNT,KAAK,OACLC,cAAc,sFAEd,MAELO,SAAW,oBAACI,KAAErB,UAAU,oBAAoBiB,UAAgB,KAC5D/B,SAGP,CAEAD,CAAAA,aAAagB,OAAO,CAAGA,OACvBhB,CAAAA,aAAa0B,OAAO,CAAGA,OACvB1B,CAAAA,aAAa6B,IAAI,CAAGA,IAEpB,gBAAe7B,YAAa"}
|
package/core/Flash.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React,{useEffect,useState,useRef}from"react";import DOMPurify from"dompurify";import{getRemoteDataStore}from"./remote-data-store.js";import ConnectStateWrapper from"./ConnectStateWrapper";import Icon from"./Icon";const REDUCER_KEY="flashes";const FLASH_DATA_ID="ui-flashes";const initialState={items:[]};const reducerFlashes={[REDUCER_KEY]:(state=initialState,action)=>{switch(action.type){case"flash/push":{const flashes=Array.isArray(action.payload)?action.payload:[action.payload];return{items:[...state.items,...flashes]}}default:return state}}};const selectFlashes=store=>store.getState()[REDUCER_KEY];const FLASH_BG_COLOR={error:"bg-gui-error",success:"bg-zingy-green",notice:"bg-electric-cyan",info:"bg-electric-cyan",alert:"bg-active-orange"};const FLASH_TEXT_COLOR={error:"text-white",success:"text-cool-black",notice:"text-cool-black",info:"text-cool-black",alert:"text-white"};const AUTO_HIDE=["success","info","notice"];const AUTO_HIDE_TIME=8e3;const useAutoHide=(type,closeFlash)=>{const timeoutId=useRef(null);useEffect(()=>{if(AUTO_HIDE.includes(type)){timeoutId.current=setTimeout(()=>{closeFlash()},AUTO_HIDE_TIME)}return()=>{if(timeoutId.current){clearTimeout(timeoutId.current)}}},[])};const Flash=({id,type,content,removeFlash})=>{const ref=useRef(null);const[closed,setClosed]=useState(false);const[flashHeight,setFlashHeight]=useState(0);const[triggerEntryAnimation,setTriggerEntryAnimation]=useState(false);const closeFlash=()=>{if(ref.current){setFlashHeight(ref.current.getBoundingClientRect().height)}setClosed(true);setTimeout(()=>{if(id){removeFlash(id)}},100)};useEffect(()=>setTriggerEntryAnimation(true),[]);useAutoHide(type,closeFlash);const animateEntry=triggerEntryAnimation&&!closed;let style;if(flashHeight&&!closed){style={height:`${flashHeight}px`}}else if(closed){style={height:0,marginTop:0,zIndex:-1}}else{style={}}const safeContent=DOMPurify.sanitize(content,{ALLOWED_TAGS:["a"],ALLOWED_ATTR:["href","data-method","rel"]});const withIcons={notice:"icon-gui-ably-badge",success:"icon-gui-check-outline",error:"icon-gui-exclamation-triangle-outline",alert:"icon-gui-exclamation-triangle-outline",info:""};const iconColor={notice:"text-cool-black",success:"text-cool-black",error:"text-white",alert:"text-white",info:""};return React.createElement("div",{className:`ui-flash-message ui-grid-px ${animateEntry?"ui-flash-message-enter":""}`,style:style,ref:ref,"data-id":"ui-flash"},React.createElement("div",{className:`${FLASH_BG_COLOR[type]} p-32 flex align-center rounded shadow-container-subtle`},withIcons[type]&&iconColor[type]&&React.createElement(Icon,{name:withIcons[type],color:iconColor[type],size:"1.5rem",additionalCSS:"mr-16 self-baseline"}),React.createElement("p",{className:`ui-text-p1 mr-16 ${FLASH_TEXT_COLOR[type]}`,dangerouslySetInnerHTML:{__html:safeContent}}),React.createElement("button",{type:"button",className:"p-0 ml-auto self-start focus:outline-none",onClick:closeFlash},iconColor[type]&&React.createElement(Icon,{name:"icon-gui-x-mark-outline",color:iconColor[type],size:"1.5rem",additionalCSS:"transition-colors"}))))};const Flashes=({flashes})=>{const[flashesWithIds,setFlashesWithIds]=useState([]);const removeFlash=flashId=>setFlashesWithIds(items=>items.filter(item=>item.id!==flashId));useEffect(()=>{setFlashesWithIds(state=>{return[...state,...(flashes?.items??[]).map(flash=>({...flash,id:Math.random().toString(36).slice(2),removed:false
|
|
1
|
+
import React,{useEffect,useState,useRef}from"react";import DOMPurify from"dompurify";import{getRemoteDataStore}from"./remote-data-store.js";import ConnectStateWrapper from"./ConnectStateWrapper";import Icon from"./Icon";const REDUCER_KEY="flashes";const FLASH_DATA_ID="ui-flashes";const initialState={items:[]};const reducerFlashes={[REDUCER_KEY]:(state=initialState,action)=>{switch(action.type){case"flash/push":{const flashes=Array.isArray(action.payload)?action.payload:[action.payload];return{items:[...state.items,...flashes]}}default:return state}}};const selectFlashes=store=>store.getState()[REDUCER_KEY];const FLASH_BG_COLOR={error:"bg-gui-error",success:"bg-zingy-green",notice:"bg-electric-cyan",info:"bg-electric-cyan",alert:"bg-active-orange"};const FLASH_TEXT_COLOR={error:"text-white",success:"text-cool-black",notice:"text-cool-black",info:"text-cool-black",alert:"text-white"};const AUTO_HIDE=["success","info","notice"];const AUTO_HIDE_TIME=8e3;const useAutoHide=(type,closeFlash)=>{const timeoutId=useRef(null);useEffect(()=>{if(AUTO_HIDE.includes(type)){timeoutId.current=setTimeout(()=>{closeFlash()},AUTO_HIDE_TIME)}return()=>{if(timeoutId.current){clearTimeout(timeoutId.current)}}},[])};const Flash=({id,type,content,removeFlash})=>{const ref=useRef(null);const[closed,setClosed]=useState(false);const[flashHeight,setFlashHeight]=useState(0);const[triggerEntryAnimation,setTriggerEntryAnimation]=useState(false);const closeFlash=()=>{if(ref.current){setFlashHeight(ref.current.getBoundingClientRect().height)}setClosed(true);setTimeout(()=>{if(id){removeFlash(id)}},100)};useEffect(()=>setTriggerEntryAnimation(true),[]);useAutoHide(type,closeFlash);const animateEntry=triggerEntryAnimation&&!closed;let style;if(flashHeight&&!closed){style={height:`${flashHeight}px`}}else if(closed){style={height:0,marginTop:0,zIndex:-1}}else{style={}}const safeContent=DOMPurify.sanitize(content,{ALLOWED_TAGS:["a"],ALLOWED_ATTR:["href","data-method","rel"]});const withIcons={notice:"icon-gui-ably-badge",success:"icon-gui-check-outline",error:"icon-gui-exclamation-triangle-outline",alert:"icon-gui-exclamation-triangle-outline",info:""};const iconColor={notice:"text-cool-black",success:"text-cool-black",error:"text-white",alert:"text-white",info:""};return React.createElement("div",{className:`ui-flash-message ui-grid-px ${animateEntry?"ui-flash-message-enter":""}`,style:style,ref:ref,"data-id":"ui-flash"},React.createElement("div",{className:`${FLASH_BG_COLOR[type]} p-32 flex align-center rounded shadow-container-subtle`},withIcons[type]&&iconColor[type]&&React.createElement(Icon,{name:withIcons[type],color:iconColor[type],size:"1.5rem",additionalCSS:"mr-16 self-baseline"}),React.createElement("p",{className:`ui-text-p1 mr-16 ${FLASH_TEXT_COLOR[type]}`,dangerouslySetInnerHTML:{__html:safeContent}}),React.createElement("button",{type:"button",className:"p-0 ml-auto self-start focus:outline-none",onClick:closeFlash},iconColor[type]&&React.createElement(Icon,{name:"icon-gui-x-mark-outline",color:iconColor[type],size:"1.5rem",additionalCSS:"transition-colors"}))))};const Flashes=({flashes})=>{const[flashesWithIds,setFlashesWithIds]=useState([]);const removeFlash=flashId=>setFlashesWithIds(items=>items.filter(item=>item.id!==flashId));useEffect(()=>{setFlashesWithIds(state=>{return[...state,...(flashes?.items??[]).map(flash=>({...flash,id:Math.random().toString(36).slice(2),removed:false}))]})},[flashes]);return React.createElement("div",{className:"ui-flash","data-id":FLASH_DATA_ID},flashesWithIds.filter(item=>!item.removed).map(flash=>React.createElement(Flash,{key:flash.id,...flash,removeFlash:removeFlash})))};const BackendFlashes=({flashes})=>{useEffect(()=>{const transformedFlashes=flashes.map(flash=>{const[type,content]=flash;return{type,content}})||[];if(transformedFlashes.length>0){const store=getRemoteDataStore();store.dispatch({type:"flash/push",payload:transformedFlashes})}},[]);const WrappedFlashes=ConnectStateWrapper(Flashes,{flashes:selectFlashes});return React.createElement(WrappedFlashes,null)};export{reducerFlashes,FLASH_DATA_ID,Flashes};export default BackendFlashes;
|
|
2
2
|
//# sourceMappingURL=Flash.js.map
|
package/core/Flash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Flash.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from \"react\";\nimport DOMPurify from \"dompurify\";\nimport { getRemoteDataStore } from \"./remote-data-store.js\";\nimport ConnectStateWrapper from \"./ConnectStateWrapper\";\nimport Icon from \"./Icon\";\nimport { ColorClass } from \"./styles/colors/types\";\nimport { IconName } from \"./Icon/types\";\n\ntype FlashPropsType = \"error\" | \"success\" | \"notice\" | \"info\" | \"alert\";\n\ntype FlashProps = {\n id: string;\n removed: boolean;\n type: FlashPropsType;\n content: string;\n removeFlash: (id: string) => void;\n};\n\ntype FlashesProps = {\n flashes: { items: Pick<FlashProps, \"type\" | \"content\">[] };\n};\n\ntype BackendFlashesProps = {\n flashes: string[][];\n};\n\nconst REDUCER_KEY = \"flashes\";\nconst FLASH_DATA_ID = \"ui-flashes\";\n\nconst initialState = { items: [] };\n\nconst reducerFlashes = {\n [REDUCER_KEY]: (\n state: {\n items: FlashProps[];\n } = initialState,\n action: { type: string; payload: FlashProps | FlashProps[] },\n ) => {\n switch (action.type) {\n case \"flash/push\": {\n const flashes = Array.isArray(action.payload)\n ? action.payload\n : [action.payload];\n return { items: [...state.items, ...flashes] };\n }\n default:\n return state;\n }\n },\n};\n\n// Not cool but redux isn't a long term plan here\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst selectFlashes = (store: any): { items: FlashProps[] } =>\n store.getState()[REDUCER_KEY];\n\nconst FLASH_BG_COLOR = {\n error: \"bg-gui-error\",\n success: \"bg-zingy-green\",\n notice: \"bg-electric-cyan\",\n info: \"bg-electric-cyan\",\n alert: \"bg-active-orange\",\n};\n\nconst FLASH_TEXT_COLOR = {\n error: \"text-white\",\n success: \"text-cool-black\",\n notice: \"text-cool-black\",\n info: \"text-cool-black\",\n alert: \"text-white\",\n};\n\nconst AUTO_HIDE = [\"success\", \"info\", \"notice\"];\nconst AUTO_HIDE_TIME = 8000;\n\nconst useAutoHide = (type: string, closeFlash: () => void) => {\n const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (AUTO_HIDE.includes(type)) {\n timeoutId.current = setTimeout(() => {\n closeFlash();\n }, AUTO_HIDE_TIME);\n }\n\n return () => {\n if (timeoutId.current) {\n clearTimeout(timeoutId.current);\n }\n };\n }, []);\n};\n\nconst Flash = ({ id, type, content, removeFlash }: FlashProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const [closed, setClosed] = useState(false);\n const [flashHeight, setFlashHeight] = useState(0);\n const [triggerEntryAnimation, setTriggerEntryAnimation] = useState(false);\n\n const closeFlash = () => {\n if (ref.current) {\n setFlashHeight(ref.current.getBoundingClientRect().height);\n }\n\n setClosed(true);\n\n setTimeout(() => {\n if (id) {\n removeFlash(id);\n }\n }, 100);\n };\n\n useEffect(() => setTriggerEntryAnimation(true), []);\n useAutoHide(type, closeFlash);\n\n const animateEntry = triggerEntryAnimation && !closed;\n\n let style;\n\n if (flashHeight && !closed) {\n style = { height: `${flashHeight}px` };\n } else if (closed) {\n style = { height: 0, marginTop: 0, zIndex: -1 };\n } else {\n style = {};\n }\n\n const safeContent = DOMPurify.sanitize(content, {\n ALLOWED_TAGS: [\"a\"],\n ALLOWED_ATTR: [\"href\", \"data-method\", \"rel\"],\n });\n\n const withIcons: Record<FlashPropsType, IconName | \"\"> = {\n notice: \"icon-gui-ably-badge\",\n success: \"icon-gui-check-outline\",\n error: \"icon-gui-exclamation-triangle-outline\",\n alert: \"icon-gui-exclamation-triangle-outline\",\n info: \"\",\n };\n\n const iconColor: Record<FlashPropsType, ColorClass | \"\"> = {\n notice: \"text-cool-black\",\n success: \"text-cool-black\",\n error: \"text-white\",\n alert: \"text-white\",\n info: \"\",\n };\n\n return (\n <div\n className={`ui-flash-message ui-grid-px ${\n animateEntry ? \"ui-flash-message-enter\" : \"\"\n }`}\n style={style}\n ref={ref}\n data-id=\"ui-flash\"\n >\n <div\n className={`${FLASH_BG_COLOR[type]} p-32 flex align-center rounded shadow-container-subtle`}\n >\n {withIcons[type] && iconColor[type] && (\n <Icon\n name={withIcons[type]}\n color={iconColor[type]}\n size=\"1.5rem\"\n additionalCSS=\"mr-16 self-baseline\"\n />\n )}\n <p\n className={`ui-text-p1 mr-16 ${FLASH_TEXT_COLOR[type]}`}\n dangerouslySetInnerHTML={{ __html: safeContent }}\n />\n <button\n type=\"button\"\n className=\"p-0 ml-auto self-start focus:outline-none\"\n onClick={closeFlash}\n >\n {iconColor[type] && (\n <Icon\n name=\"icon-gui-x-mark-outline\"\n color={iconColor[type]}\n size=\"1.5rem\"\n additionalCSS=\"transition-colors\"\n />\n )}\n </button>\n </div>\n </div>\n );\n};\n\nconst Flashes = ({ flashes }: FlashesProps) => {\n const [flashesWithIds, setFlashesWithIds] = useState<FlashProps[]>([]);\n\n const removeFlash = (flashId: string) =>\n setFlashesWithIds((items) => items.filter((item) => item.id !== flashId));\n\n useEffect(() => {\n setFlashesWithIds((state) => {\n return [\n ...state,\n ...(flashes?.items ?? []).map((flash) => ({\n ...flash,\n id: Math.random().toString(36).slice(2),\n removed: false,\n removeFlash,\n })),\n ];\n });\n }, [flashes]);\n\n return (\n <div className=\"ui-flash\" data-id={FLASH_DATA_ID}>\n {flashesWithIds\n .filter((item) => !item.removed)\n .map((flash) => (\n <Flash key={flash.id} {...flash} />\n ))}\n </div>\n );\n};\n\nconst BackendFlashes = ({ flashes }: BackendFlashesProps) => {\n useEffect(() => {\n const transformedFlashes =\n flashes.map((flash) => {\n const [type, content] = flash;\n return { type, content };\n }) || [];\n\n if (transformedFlashes.length > 0) {\n const store = getRemoteDataStore();\n\n store.dispatch({\n type: \"flash/push\",\n payload: transformedFlashes,\n });\n }\n }, []);\n\n const WrappedFlashes = ConnectStateWrapper(Flashes, {\n flashes: selectFlashes,\n });\n\n return <WrappedFlashes />;\n};\n\nexport { reducerFlashes, FLASH_DATA_ID, Flashes };\nexport default BackendFlashes;\n"],"names":["React","useEffect","useState","useRef","DOMPurify","getRemoteDataStore","ConnectStateWrapper","Icon","REDUCER_KEY","FLASH_DATA_ID","initialState","items","reducerFlashes","state","action","type","flashes","Array","isArray","payload","selectFlashes","store","getState","FLASH_BG_COLOR","error","success","notice","info","alert","FLASH_TEXT_COLOR","AUTO_HIDE","AUTO_HIDE_TIME","useAutoHide","closeFlash","timeoutId","includes","current","setTimeout","clearTimeout","Flash","id","content","removeFlash","ref","closed","setClosed","flashHeight","setFlashHeight","triggerEntryAnimation","setTriggerEntryAnimation","getBoundingClientRect","height","animateEntry","style","marginTop","zIndex","safeContent","sanitize","ALLOWED_TAGS","ALLOWED_ATTR","withIcons","iconColor","div","className","data-id","name","color","size","additionalCSS","p","dangerouslySetInnerHTML","__html","button","onClick","Flashes","flashesWithIds","setFlashesWithIds","flashId","filter","item","map","flash","Math","random","toString","slice","removed","key","BackendFlashes","transformedFlashes","length","dispatch","WrappedFlashes"],"mappings":"AAAA,OAAOA,OAASC,SAAS,CAAEC,QAAQ,CAAEC,MAAM,KAAQ,OAAQ,AAC3D,QAAOC,cAAe,WAAY,AAClC,QAASC,kBAAkB,KAAQ,wBAAyB,AAC5D,QAAOC,wBAAyB,uBAAwB,AACxD,QAAOC,SAAU,QAAS,CAsB1B,MAAMC,YAAc,UACpB,MAAMC,cAAgB,aAEtB,MAAMC,aAAe,CAAEC,MAAO,EAAE,AAAC,EAEjC,MAAMC,eAAiB,CACrB,CAACJ,YAAY,CAAE,CACbK,MAEIH,YAAY,CAChBI,UAEA,OAAQA,OAAOC,IAAI,EACjB,IAAK,aAAc,CACjB,MAAMC,QAAUC,MAAMC,OAAO,CAACJ,OAAOK,OAAO,EACxCL,OAAOK,OAAO,CACd,CAACL,OAAOK,OAAO,CAAC,CACpB,MAAO,CAAER,MAAO,IAAIE,MAAMF,KAAK,IAAKK,QAAQ,AAAC,CAC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ash.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from \"react\";\nimport DOMPurify from \"dompurify\";\nimport { getRemoteDataStore } from \"./remote-data-store.js\";\nimport ConnectStateWrapper from \"./ConnectStateWrapper\";\nimport Icon from \"./Icon\";\nimport { ColorClass } from \"./styles/colors/types\";\nimport { IconName } from \"./Icon/types\";\n\ntype FlashPropsType = \"error\" | \"success\" | \"notice\" | \"info\" | \"alert\";\n\ntype FlashProps = {\n id: string;\n removed: boolean;\n type: FlashPropsType;\n content: string;\n removeFlash: (id: string) => void;\n};\n\ntype FlashesProps = {\n flashes: { items: FlashProps[] };\n};\n\ntype BackendFlashesProps = {\n flashes: string[][];\n};\n\nconst REDUCER_KEY = \"flashes\";\nconst FLASH_DATA_ID = \"ui-flashes\";\n\nconst initialState = { items: [] };\n\nconst reducerFlashes = {\n [REDUCER_KEY]: (\n state: {\n items: FlashProps[];\n } = initialState,\n action: { type: string; payload: FlashProps | FlashProps[] },\n ) => {\n switch (action.type) {\n case \"flash/push\": {\n const flashes = Array.isArray(action.payload)\n ? action.payload\n : [action.payload];\n return { items: [...state.items, ...flashes] };\n }\n default:\n return state;\n }\n },\n};\n\n// Not cool but redux isn't a long term plan here\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst selectFlashes = (store: any): { items: FlashProps[] } =>\n store.getState()[REDUCER_KEY];\n\nconst FLASH_BG_COLOR = {\n error: \"bg-gui-error\",\n success: \"bg-zingy-green\",\n notice: \"bg-electric-cyan\",\n info: \"bg-electric-cyan\",\n alert: \"bg-active-orange\",\n};\n\nconst FLASH_TEXT_COLOR = {\n error: \"text-white\",\n success: \"text-cool-black\",\n notice: \"text-cool-black\",\n info: \"text-cool-black\",\n alert: \"text-white\",\n};\n\nconst AUTO_HIDE = [\"success\", \"info\", \"notice\"];\nconst AUTO_HIDE_TIME = 8000;\n\nconst useAutoHide = (type: string, closeFlash: () => void) => {\n const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (AUTO_HIDE.includes(type)) {\n timeoutId.current = setTimeout(() => {\n closeFlash();\n }, AUTO_HIDE_TIME);\n }\n\n return () => {\n if (timeoutId.current) {\n clearTimeout(timeoutId.current);\n }\n };\n }, []);\n};\n\nconst Flash = ({ id, type, content, removeFlash }: FlashProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const [closed, setClosed] = useState(false);\n const [flashHeight, setFlashHeight] = useState(0);\n const [triggerEntryAnimation, setTriggerEntryAnimation] = useState(false);\n\n const closeFlash = () => {\n if (ref.current) {\n setFlashHeight(ref.current.getBoundingClientRect().height);\n }\n\n setClosed(true);\n\n setTimeout(() => {\n if (id) {\n removeFlash(id);\n }\n }, 100);\n };\n\n useEffect(() => setTriggerEntryAnimation(true), []);\n useAutoHide(type, closeFlash);\n\n const animateEntry = triggerEntryAnimation && !closed;\n\n let style;\n\n if (flashHeight && !closed) {\n style = { height: `${flashHeight}px` };\n } else if (closed) {\n style = { height: 0, marginTop: 0, zIndex: -1 };\n } else {\n style = {};\n }\n\n const safeContent = DOMPurify.sanitize(content, {\n ALLOWED_TAGS: [\"a\"],\n ALLOWED_ATTR: [\"href\", \"data-method\", \"rel\"],\n });\n\n const withIcons: Record<FlashPropsType, IconName | \"\"> = {\n notice: \"icon-gui-ably-badge\",\n success: \"icon-gui-check-outline\",\n error: \"icon-gui-exclamation-triangle-outline\",\n alert: \"icon-gui-exclamation-triangle-outline\",\n info: \"\",\n };\n\n const iconColor: Record<FlashPropsType, ColorClass | \"\"> = {\n notice: \"text-cool-black\",\n success: \"text-cool-black\",\n error: \"text-white\",\n alert: \"text-white\",\n info: \"\",\n };\n\n return (\n <div\n className={`ui-flash-message ui-grid-px ${\n animateEntry ? \"ui-flash-message-enter\" : \"\"\n }`}\n style={style}\n ref={ref}\n data-id=\"ui-flash\"\n >\n <div\n className={`${FLASH_BG_COLOR[type]} p-32 flex align-center rounded shadow-container-subtle`}\n >\n {withIcons[type] && iconColor[type] && (\n <Icon\n name={withIcons[type]}\n color={iconColor[type]}\n size=\"1.5rem\"\n additionalCSS=\"mr-16 self-baseline\"\n />\n )}\n <p\n className={`ui-text-p1 mr-16 ${FLASH_TEXT_COLOR[type]}`}\n dangerouslySetInnerHTML={{ __html: safeContent }}\n />\n <button\n type=\"button\"\n className=\"p-0 ml-auto self-start focus:outline-none\"\n onClick={closeFlash}\n >\n {iconColor[type] && (\n <Icon\n name=\"icon-gui-x-mark-outline\"\n color={iconColor[type]}\n size=\"1.5rem\"\n additionalCSS=\"transition-colors\"\n />\n )}\n </button>\n </div>\n </div>\n );\n};\n\nconst Flashes = ({ flashes }: FlashesProps) => {\n const [flashesWithIds, setFlashesWithIds] = useState<FlashProps[]>([]);\n\n const removeFlash = (flashId: string) =>\n setFlashesWithIds((items) => items.filter((item) => item.id !== flashId));\n\n useEffect(() => {\n setFlashesWithIds((state) => {\n return [\n ...state,\n ...(flashes?.items ?? []).map((flash) => ({\n ...flash,\n id: Math.random().toString(36).slice(2),\n removed: false,\n })),\n ];\n });\n }, [flashes]);\n\n return (\n <div className=\"ui-flash\" data-id={FLASH_DATA_ID}>\n {flashesWithIds\n .filter((item) => !item.removed)\n .map((flash) => (\n <Flash key={flash.id} {...flash} removeFlash={removeFlash} />\n ))}\n </div>\n );\n};\n\nconst BackendFlashes = ({ flashes }: BackendFlashesProps) => {\n useEffect(() => {\n const transformedFlashes =\n flashes.map((flash) => {\n const [type, content] = flash;\n return { type, content };\n }) || [];\n\n if (transformedFlashes.length > 0) {\n const store = getRemoteDataStore();\n\n store.dispatch({\n type: \"flash/push\",\n payload: transformedFlashes,\n });\n }\n }, []);\n\n const WrappedFlashes = ConnectStateWrapper(Flashes, {\n flashes: selectFlashes,\n });\n\n return <WrappedFlashes />;\n};\n\nexport { reducerFlashes, FLASH_DATA_ID, Flashes };\nexport default BackendFlashes;\n"],"names":["React","useEffect","useState","useRef","DOMPurify","getRemoteDataStore","ConnectStateWrapper","Icon","REDUCER_KEY","FLASH_DATA_ID","initialState","items","reducerFlashes","state","action","type","flashes","Array","isArray","payload","selectFlashes","store","getState","FLASH_BG_COLOR","error","success","notice","info","alert","FLASH_TEXT_COLOR","AUTO_HIDE","AUTO_HIDE_TIME","useAutoHide","closeFlash","timeoutId","includes","current","setTimeout","clearTimeout","Flash","id","content","removeFlash","ref","closed","setClosed","flashHeight","setFlashHeight","triggerEntryAnimation","setTriggerEntryAnimation","getBoundingClientRect","height","animateEntry","style","marginTop","zIndex","safeContent","sanitize","ALLOWED_TAGS","ALLOWED_ATTR","withIcons","iconColor","div","className","data-id","name","color","size","additionalCSS","p","dangerouslySetInnerHTML","__html","button","onClick","Flashes","flashesWithIds","setFlashesWithIds","flashId","filter","item","map","flash","Math","random","toString","slice","removed","key","BackendFlashes","transformedFlashes","length","dispatch","WrappedFlashes"],"mappings":"AAAA,OAAOA,OAASC,SAAS,CAAEC,QAAQ,CAAEC,MAAM,KAAQ,OAAQ,AAC3D,QAAOC,cAAe,WAAY,AAClC,QAASC,kBAAkB,KAAQ,wBAAyB,AAC5D,QAAOC,wBAAyB,uBAAwB,AACxD,QAAOC,SAAU,QAAS,CAsB1B,MAAMC,YAAc,UACpB,MAAMC,cAAgB,aAEtB,MAAMC,aAAe,CAAEC,MAAO,EAAE,AAAC,EAEjC,MAAMC,eAAiB,CACrB,CAACJ,YAAY,CAAE,CACbK,MAEIH,YAAY,CAChBI,UAEA,OAAQA,OAAOC,IAAI,EACjB,IAAK,aAAc,CACjB,MAAMC,QAAUC,MAAMC,OAAO,CAACJ,OAAOK,OAAO,EACxCL,OAAOK,OAAO,CACd,CAACL,OAAOK,OAAO,CAAC,CACpB,MAAO,CAAER,MAAO,IAAIE,MAAMF,KAAK,IAAKK,QAAQ,AAAC,CAC/C,CACA,QACE,OAAOH,KACX,CACF,CACF,EAIA,MAAMO,cAAgB,AAACC,OACrBA,MAAMC,QAAQ,EAAE,CAACd,YAAY,CAE/B,MAAMe,eAAiB,CACrBC,MAAO,eACPC,QAAS,iBACTC,OAAQ,mBACRC,KAA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E,GAAKqC,UAElE5E,UAAU,KACR2E,kBAAkB,AAAC/D,QACjB,MAAO,IACFA,SACA,AAACG,CAAAA,SAASL,OAAS,EAAE,AAAD,EAAGqE,GAAG,CAAC,AAACC,OAAW,CAAA,CACxC,GAAGA,KAAK,CACRzC,GAAI0C,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,KAAK,CAAC,GACrCC,QAAS,KACX,CAAA,GACD,AACH,EACF,EAAG,CAACtE,QAAQ,EAEZ,OACE,oBAAC8C,OAAIC,UAAU,WAAWC,UAASvD,eAChCkE,eACEG,MAAM,CAAC,AAACC,MAAS,CAACA,KAAKO,OAAO,EAC9BN,GAAG,CAAC,AAACC,OACJ,oBAAC1C,OAAMgD,IAAKN,MAAMzC,EAAE,CAAG,GAAGyC,KAAK,CAAEvC,YAAaA,eAIxD,EAEA,MAAM8C,eAAiB,CAAC,CAAExE,OAAO,CAAuB,IACtDf,UAAU,KACR,MAAMwF,mBACJzE,QAAQgE,GAAG,CAAC,AAACC,QACX,KAAM,CAAClE,KAAM0B,QAAQ,CAAGwC,MACxB,MAAO,CAAElE,KAAM0B,OAAQ,CACzB,IAAM,EAAE,CAEV,GAAIgD,mBAAmBC,MAAM,CAAG,EAAG,CACjC,MAAMrE,MAAQhB,qBAEdgB,MAAMsE,QAAQ,CAAC,CACb5E,KAAM,aACNI,QAASsE,kBACX,EACF,CACF,EAAG,EAAE,EAEL,MAAMG,eAAiBtF,oBAAoBoE,QAAS,CAClD1D,QAASI,aACX,GAEA,OAAO,oBAACwE,oBACV,CAEA,QAAShF,cAAc,CAAEH,aAAa,CAAEiE,OAAO,CAAG,AAClD,gBAAec,cAAe"}
|
package/core/Flyout.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React,{useState}from"react";import{NavigationMenu,NavigationMenuItem,NavigationMenuList,NavigationMenuTrigger,NavigationMenuContent,NavigationMenuViewport,NavigationMenuLink}from"@radix-ui/react-navigation-menu";import cn from"./utils/cn";import{componentMaxHeight,HEADER_HEIGHT}from"./utils/heights";const DEFAULT_MENU_LINK_STYLING="ui-text-menu3 font-bold text-neutral-1000 dark:neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-1200 hover:text-neutral-1300 dark:hover:text-neutral-000 px-12 py-8 flex items-center justify-between";const DEFAULT_VIEWPORT_STYLING="relative overflow-hidden w-full h-[var(--radix-navigation-menu-viewport-height)] origin-[top_center] transition-[width,_height] duration-300 data-[state=closed]:animate-scale-out data-[state=open]:animate-scale-in sm:w-[var(--radix-navigation-menu-viewport-width)]";const PANEL_ANIMATION="data-[motion=from-end]:animate-enter-from-right data-[motion=from-start]:animate-enter-from-left data-[motion=to-end]:animate-exit-to-right data-[motion=to-start]:animate-exit-to-left";const FlyOverlay=({className,fadingOut})=>React.createElement("div",{className:cn("absolute left-0 right-0 h-screen w-full opacity-0",{"animate-[fade-in-ten-percent_150ms_ease-in-out_forwards]":!fadingOut,"animate-[fade-out-ten-percent_150ms_ease-in-out_forwards]":fadingOut},className),style:{height:componentMaxHeight(HEADER_HEIGHT)}});const Flyout=({menuItems,className,flyOutClassName,menuLinkClassName,viewPortClassName,hasAnimation})=>{const[isOpen,setIsOpen]=useState(false);const[fadingOut,setFadingOut]=useState(false);const closeMenu=()=>{setFadingOut(true);setTimeout(()=>{setIsOpen(false);setFadingOut(false)},150)};return React.createElement(React.Fragment,null,React.createElement(NavigationMenu,{className:cn(className,"flex w-full"),onValueChange:val=>val?setIsOpen(true):closeMenu(),delayDuration:0},React.createElement(NavigationMenuList,{className:"flex list-none center"},menuItems.map(({
|
|
1
|
+
import React,{useState}from"react";import{NavigationMenu,NavigationMenuItem,NavigationMenuList,NavigationMenuTrigger,NavigationMenuContent,NavigationMenuViewport,NavigationMenuLink}from"@radix-ui/react-navigation-menu";import cn from"./utils/cn";import{componentMaxHeight,HEADER_HEIGHT}from"./utils/heights";const DEFAULT_MENU_LINK_STYLING="ui-text-menu3 font-bold text-neutral-1000 dark:neutral-300 rounded-md hover:bg-neutral-100 dark:hover:bg-neutral-1200 hover:text-neutral-1300 dark:hover:text-neutral-000 px-12 py-8 flex items-center justify-between";const DEFAULT_VIEWPORT_STYLING="relative overflow-hidden w-full h-[var(--radix-navigation-menu-viewport-height)] origin-[top_center] transition-[width,_height] duration-300 data-[state=closed]:animate-scale-out data-[state=open]:animate-scale-in sm:w-[var(--radix-navigation-menu-viewport-width)]";const PANEL_ANIMATION="data-[motion=from-end]:animate-enter-from-right data-[motion=from-start]:animate-enter-from-left data-[motion=to-end]:animate-exit-to-right data-[motion=to-start]:animate-exit-to-left";const FlyOverlay=({className,fadingOut})=>React.createElement("div",{className:cn("absolute left-0 right-0 h-screen w-full opacity-0",{"animate-[fade-in-ten-percent_150ms_ease-in-out_forwards]":!fadingOut,"animate-[fade-out-ten-percent_150ms_ease-in-out_forwards]":fadingOut},className),style:{height:componentMaxHeight(HEADER_HEIGHT),top:HEADER_HEIGHT}});const Flyout=({menuItems,className,flyOutClassName,menuLinkClassName,viewPortClassName,hasAnimation})=>{const[isOpen,setIsOpen]=useState(false);const[fadingOut,setFadingOut]=useState(false);const closeMenu=()=>{setFadingOut(true);setTimeout(()=>{setIsOpen(false);setFadingOut(false)},150)};return React.createElement(React.Fragment,null,React.createElement(NavigationMenu,{className:cn(className,"flex w-full"),onValueChange:val=>val?setIsOpen(true):closeMenu(),delayDuration:0},React.createElement(NavigationMenuList,{className:"flex list-none center"},menuItems.map(({name,content,link,panelClassName})=>content?React.createElement(NavigationMenuItem,{key:name},React.createElement(NavigationMenuTrigger,{className:cn("group outline-none focus:outline-none select-none cursor-pointer relative",DEFAULT_MENU_LINK_STYLING,menuLinkClassName)},name),React.createElement(NavigationMenuContent,{className:cn("absolute right-0 top-0 p-24 z-10",hasAnimation&&PANEL_ANIMATION,panelClassName)},content)):React.createElement(NavigationMenuLink,{key:name},React.createElement("a",{href:link,className:cn(DEFAULT_MENU_LINK_STYLING,menuLinkClassName)},name)))),React.createElement("div",{className:cn("absolute left-0 top-full",flyOutClassName)},React.createElement(NavigationMenuViewport,{className:cn(DEFAULT_VIEWPORT_STYLING,viewPortClassName)}))),isOpen?React.createElement(FlyOverlay,{className:"bg-neutral-1300 dark:bg-neutral-000 opacity-10 z-20 h-screen",fadingOut:fadingOut}):null)};export default Flyout;
|
|
2
2
|
//# sourceMappingURL=Flyout.js.map
|
package/core/Flyout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Flyout.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuList,\n NavigationMenuTrigger,\n NavigationMenuContent,\n NavigationMenuViewport,\n NavigationMenuLink,\n} from \"@radix-ui/react-navigation-menu\";\nimport cn from \"./utils/cn\";\nimport { componentMaxHeight, HEADER_HEIGHT } from \"./utils/heights\";\n\n/**\n * Props for the Flyout component.\n */\ntype FlyoutProps = {\n /**\n * Array of menu items to be displayed in the flyout.\n */\n menuItems: {\n /**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/core/Flyout.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuList,\n NavigationMenuTrigger,\n NavigationMenuContent,\n NavigationMenuViewport,\n NavigationMenuLink,\n} from \"@radix-ui/react-navigation-menu\";\nimport cn from \"./utils/cn\";\nimport { componentMaxHeight, HEADER_HEIGHT } from \"./utils/heights\";\n\n/**\n * Props for the Flyout component.\n */\ntype FlyoutProps = {\n /**\n * Array of menu items to be displayed in the flyout.\n */\n menuItems: {\n /**\n * name for the menu item.\n */\n name: string;\n /**\n * Optional content to be displayed in the flyout panel.\n */\n content?: React.ReactNode;\n /**\n * Optional link for the menu item.\n */\n link?: string;\n /**\n * Optional styling for the flyout panel.\n */\n panelClassName?: string;\n }[];\n /**\n * Optional class name for the flyout container.\n */\n className?: string;\n /**\n * Optional class name for the flyout element.\n */\n flyOutClassName?: string;\n /**\n * Optional class name for the menu link.\n */\n menuLinkClassName?: string;\n /**\n * Optional class name for the viewport.\n */\n viewPortClassName?: string;\n /**\n * Flag to indicate if animation should be applied.\n */\n hasAnimation: boolean;\n};\n\nconst DEFAULT_MENU_LINK_STYLING =\n \"ui-text-menu3 font-bold text-neutral-1000 dark:neutral-300 rounded-md hover:bg-neutral-100 dark:hover:bg-neutral-1200 hover:text-neutral-1300 dark:hover:text-neutral-000 px-12 py-8 flex items-center justify-between\";\nconst DEFAULT_VIEWPORT_STYLING =\n \"relative overflow-hidden w-full h-[var(--radix-navigation-menu-viewport-height)] origin-[top_center] transition-[width,_height] duration-300 data-[state=closed]:animate-scale-out data-[state=open]:animate-scale-in sm:w-[var(--radix-navigation-menu-viewport-width)]\";\nconst PANEL_ANIMATION =\n \"data-[motion=from-end]:animate-enter-from-right data-[motion=from-start]:animate-enter-from-left data-[motion=to-end]:animate-exit-to-right data-[motion=to-start]:animate-exit-to-left\";\n\nconst FlyOverlay = ({\n className,\n fadingOut,\n}: {\n className: string;\n fadingOut: boolean;\n}) => (\n <div\n className={cn(\n \"absolute left-0 right-0 h-screen w-full opacity-0\",\n {\n \"animate-[fade-in-ten-percent_150ms_ease-in-out_forwards]\": !fadingOut,\n \"animate-[fade-out-ten-percent_150ms_ease-in-out_forwards]\": fadingOut,\n },\n className,\n )}\n style={{ height: componentMaxHeight(HEADER_HEIGHT), top: HEADER_HEIGHT }}\n ></div>\n);\n\nconst Flyout = ({\n menuItems,\n className,\n flyOutClassName,\n menuLinkClassName,\n viewPortClassName,\n hasAnimation,\n}: FlyoutProps) => {\n const [isOpen, setIsOpen] = useState(false);\n const [fadingOut, setFadingOut] = useState(false);\n\n const closeMenu = () => {\n setFadingOut(true);\n\n setTimeout(() => {\n setIsOpen(false);\n setFadingOut(false);\n }, 150);\n };\n\n return (\n <>\n <NavigationMenu\n className={cn(className, \"flex w-full\")}\n onValueChange={(val) => (val ? setIsOpen(true) : closeMenu())}\n delayDuration={0}\n >\n <NavigationMenuList className=\"flex list-none center\">\n {menuItems.map(({ name, content, link, panelClassName }) =>\n content ? (\n <NavigationMenuItem key={name}>\n <NavigationMenuTrigger\n className={cn(\n \"group outline-none focus:outline-none select-none cursor-pointer relative\",\n DEFAULT_MENU_LINK_STYLING,\n menuLinkClassName,\n )}\n >\n {name}\n </NavigationMenuTrigger>\n <NavigationMenuContent\n className={cn(\n \"absolute right-0 top-0 p-24 z-10\",\n hasAnimation && PANEL_ANIMATION,\n panelClassName,\n )}\n >\n {content}\n </NavigationMenuContent>\n </NavigationMenuItem>\n ) : (\n <NavigationMenuLink key={name}>\n <a\n href={link}\n className={cn(DEFAULT_MENU_LINK_STYLING, menuLinkClassName)}\n >\n {name}\n </a>\n </NavigationMenuLink>\n ),\n )}\n </NavigationMenuList>\n\n <div className={cn(\"absolute left-0 top-full\", flyOutClassName)}>\n <NavigationMenuViewport\n className={cn(DEFAULT_VIEWPORT_STYLING, viewPortClassName)}\n />\n </div>\n </NavigationMenu>\n {isOpen ? (\n <FlyOverlay\n className=\"bg-neutral-1300 dark:bg-neutral-000 opacity-10 z-20 h-screen\"\n fadingOut={fadingOut}\n />\n ) : null}\n </>\n );\n};\n\nexport default Flyout;\n"],"names":["React","useState","NavigationMenu","NavigationMenuItem","NavigationMenuList","NavigationMenuTrigger","NavigationMenuContent","NavigationMenuViewport","NavigationMenuLink","cn","componentMaxHeight","HEADER_HEIGHT","DEFAULT_MENU_LINK_STYLING","DEFAULT_VIEWPORT_STYLING","PANEL_ANIMATION","FlyOverlay","className","fadingOut","div","style","height","top","Flyout","menuItems","flyOutClassName","menuLinkClassName","viewPortClassName","hasAnimation","isOpen","setIsOpen","setFadingOut","closeMenu","setTimeout","onValueChange","val","delayDuration","map","name","content","link","panelClassName","key","a","href"],"mappings":"AAAA,OAAOA,OAASC,QAAQ,KAAQ,OAAQ,AACxC,QACEC,cAAc,CACdC,kBAAkB,CAClBC,kBAAkB,CAClBC,qBAAqB,CACrBC,qBAAqB,CACrBC,sBAAsB,CACtBC,kBAAkB,KAC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AAGI,yBAA0Ba,uBAI7CE,OACC,oBAACb,YACCC,UAAU,+DACVC,UAAWA,YAEX,KAGV,CAEA,gBAAeK,MAAO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React,{useRef}from"react";import Icon from"../Icon";import LinkButton from"../LinkButton";import cn from"../utils/cn";import DropdownMenu from"../DropdownMenu";const testSessionState={signedIn:false,logOut:{token:"0000",href:"accounts/sign_out"},accountName:"Ably"};export const HeaderLinks=({sessionState=testSessionState,headerLinks,searchButtonVisibility,searchButton,className})=>{const{signedIn,logOut}=sessionState;const formRef=useRef(null);const headerLinkClasses="ui-text-menu2 md:ui-text-menu3 !font-bold py-16 text-neutral-1300 dark:text-neutral-000 md:text-neutral-1000 dark:md:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000 active:text-neutral-1300 dark:active:text-neutral-000 transition-colors";const dropdownMenuLinkClasses="block p-8 ui-text-menu3 font-semibold text-neutral-1000 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-1200 active:bg-neutral-200 dark:active:bg-neutral-1100 rounded-lg";const onClickLogout=e=>{e.preventDefault();formRef.current?.submit()};const DashboardLink=({className})=>React.createElement("a",{href:"/dashboard",className:className},"Dashboard");const LogoutForm=React.createElement("form",{ref:formRef,method:"post",action:logOut.href,className:"hidden"},React.createElement("input",{name:"_method",value:"delete",type:"hidden"}),React.createElement("input",{name:"authenticity_token",value:logOut.token,type:"hidden"}));return React.createElement("nav",{className:cn("flex md:flex-1 md:items-center md:justify-end flex-col md:flex-row border-t-[1px] border-neutral-300 md:border-t-0 md:gap-12 py-12 md:py-0",className)},signedIn&&React.createElement(React.Fragment,null,LogoutForm,React.createElement("div",{className:"block md:hidden"},React.createElement("div",{className:"flex flex-col border-b-[1px] border-neutral-300 px-16 pb-12 mb-12"},React.createElement("span",{className:"py-12 ui-text-sub-header text-[18px] text-neutral-700 dark:text-neutral-600 font-bold"},sessionState.accountName),React.createElement(DashboardLink,{className:headerLinkClasses})))),headerLinks?.map(({href,label,external})=>React.createElement("a",{key:href,className:cn(headerLinkClasses,"flex items-center gap-4 px-16 md:px-0"),href:href,target:external?"_blank":undefined,rel:external?"noreferrer noopener":undefined},label,external&&React.createElement(Icon,{name:"icon-gui-arrow-top-right-on-square-outline"}))),searchButtonVisibility!=="mobile"?searchButton:null,signedIn?React.createElement(React.Fragment,null,React.createElement("div",{className:"hidden md:block relative"},React.createElement(DropdownMenu,null,React.createElement(DropdownMenu.Trigger,{description:`Account menu for ${sessionState.accountName}`},React.createElement("span",{className:"block text-ellipsis overflow-hidden whitespace-nowrap w-full max-w-[150px] leading-normal"},sessionState.accountName)),React.createElement(DropdownMenu.Content,{anchorPosition:"right",contentClassNames:"w-[240px] mt-[12px]"},React.createElement("div",{className:"p-8"},React.createElement(DashboardLink,{className:dropdownMenuLinkClasses}),React.createElement("a",{onClick:onClickLogout,href:"#",className:dropdownMenuLinkClasses},"Logout"))))),React.createElement("div",{className:"block md:hidden p-16"},React.createElement(LinkButton,{onClick:onClickLogout,variant:"secondary",className:"w-full md:ui-button-secondary-xs","aria-label":"Logout",rightIcon:"icon-gui-arrow-right-end-on-rectangle-outline"},"Logout"))):React.createElement("div",{className:"flex gap-12 py-12 md:py-0 px-16 md:px-0"},React.createElement(LinkButton,{href:"/login",variant:"secondary",className:"flex-1 md:flex-none md:ui-button-secondary-xs"},"Login"),React.createElement(LinkButton,{href:"/sign-up",variant:"primary",className:"flex-1 md:flex-none md:ui-button-primary-xs"},"Start free")))};
|
|
2
2
|
//# sourceMappingURL=HeaderLinks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/Header/HeaderLinks.tsx"],"sourcesContent":["import React from \"react\";\nimport { HeaderProps } from \"../Header\";\nimport Icon from \"../Icon\";\nimport LinkButton from \"../LinkButton\";\nimport cn from \"../utils/cn\";\n\nconst testSessionState = {\n signedIn: false,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/core/Header/HeaderLinks.tsx"],"sourcesContent":["import React, { MouseEvent, useRef } from \"react\";\nimport { HeaderProps } from \"../Header\";\nimport Icon from \"../Icon\";\nimport LinkButton from \"../LinkButton\";\nimport cn from \"../utils/cn\";\nimport DropdownMenu from \"../DropdownMenu\";\n\nconst testSessionState = {\n signedIn: false,\n logOut: {\n token: \"0000\",\n href: \"accounts/sign_out\",\n },\n accountName: \"Ably\",\n};\n\nexport const HeaderLinks: React.FC<\n Pick<\n HeaderProps,\n \"sessionState\" | \"headerLinks\" | \"searchButtonVisibility\" | \"searchButton\"\n > & {\n className?: string;\n }\n> = ({\n sessionState = testSessionState,\n headerLinks,\n searchButtonVisibility,\n searchButton,\n className,\n}) => {\n const { signedIn, logOut } = sessionState;\n const formRef = useRef<HTMLFormElement>(null);\n\n const headerLinkClasses =\n \"ui-text-menu2 md:ui-text-menu3 !font-bold py-16 text-neutral-1300 dark:text-neutral-000 md:text-neutral-1000 dark:md:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000 active:text-neutral-1300 dark:active:text-neutral-000 transition-colors\";\n\n const dropdownMenuLinkClasses =\n \"block p-8 ui-text-menu3 font-semibold text-neutral-1000 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-1200 active:bg-neutral-200 dark:active:bg-neutral-1100 rounded-lg\";\n\n const onClickLogout = (e: MouseEvent) => {\n e.preventDefault();\n formRef.current?.submit();\n };\n\n const DashboardLink = ({ className }: { className: string }) => (\n <a href=\"/dashboard\" className={className}>\n Dashboard\n </a>\n );\n\n const LogoutForm = (\n <form ref={formRef} method=\"post\" action={logOut.href} className=\"hidden\">\n <input name=\"_method\" value=\"delete\" type=\"hidden\" />\n <input name=\"authenticity_token\" value={logOut.token} type=\"hidden\" />\n </form>\n );\n\n return (\n <nav\n className={cn(\n \"flex md:flex-1 md:items-center md:justify-end flex-col md:flex-row border-t-[1px] border-neutral-300 md:border-t-0 md:gap-12 py-12 md:py-0\",\n className,\n )}\n >\n {signedIn && (\n <>\n {LogoutForm}\n <div className=\"block md:hidden\">\n <div className=\"flex flex-col border-b-[1px] border-neutral-300 px-16 pb-12 mb-12\">\n <span className=\"py-12 ui-text-sub-header text-[18px] text-neutral-700 dark:text-neutral-600 font-bold\">\n {sessionState.accountName}\n </span>\n {<DashboardLink className={headerLinkClasses} />}\n </div>\n </div>\n </>\n )}\n\n {headerLinks?.map(({ href, label, external }) => (\n <a\n key={href}\n className={cn(\n headerLinkClasses,\n \"flex items-center gap-4 px-16 md:px-0\",\n )}\n href={href}\n target={external ? \"_blank\" : undefined}\n rel={external ? \"noreferrer noopener\" : undefined}\n >\n {label}\n {external && (\n <Icon name=\"icon-gui-arrow-top-right-on-square-outline\" />\n )}\n </a>\n ))}\n\n {searchButtonVisibility !== \"mobile\" ? searchButton : null}\n {signedIn ? (\n <>\n <div className=\"hidden md:block relative\">\n <DropdownMenu>\n <DropdownMenu.Trigger\n description={`Account menu for ${sessionState.accountName}`}\n >\n <span className=\"block text-ellipsis overflow-hidden whitespace-nowrap w-full max-w-[150px] leading-normal\">\n {sessionState.accountName}\n </span>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n anchorPosition=\"right\"\n contentClassNames=\"w-[240px] mt-[12px]\"\n >\n <div className=\"p-8\">\n {<DashboardLink className={dropdownMenuLinkClasses} />}\n <a\n onClick={onClickLogout}\n href=\"#\"\n className={dropdownMenuLinkClasses}\n >\n Logout\n </a>\n </div>\n </DropdownMenu.Content>\n </DropdownMenu>\n </div>\n <div className=\"block md:hidden p-16\">\n <LinkButton\n onClick={onClickLogout}\n variant=\"secondary\"\n className=\"w-full md:ui-button-secondary-xs\"\n aria-label=\"Logout\"\n rightIcon=\"icon-gui-arrow-right-end-on-rectangle-outline\"\n >\n Logout\n </LinkButton>\n </div>\n </>\n ) : (\n <div className=\"flex gap-12 py-12 md:py-0 px-16 md:px-0\">\n <LinkButton\n href=\"/login\"\n variant=\"secondary\"\n className=\"flex-1 md:flex-none md:ui-button-secondary-xs\"\n >\n Login\n </LinkButton>\n <LinkButton\n href=\"/sign-up\"\n variant=\"primary\"\n className=\"flex-1 md:flex-none md:ui-button-primary-xs\"\n >\n Start free\n </LinkButton>\n </div>\n )}\n </nav>\n );\n};\n"],"names":["React","useRef","Icon","LinkButton","cn","DropdownMenu","testSessionState","signedIn","logOut","token","href","accountName","HeaderLinks","sessionState","headerLinks","searchButtonVisibility","searchButton","className","formRef","headerLinkClasses","dropdownMenuLinkClasses","onClickLogout","e","preventDefault","current","submit","DashboardLink","a","LogoutForm","form","ref","method","action","input","name","value","type","nav","div","span","map","label","external","key","target","undefined","rel","Trigger","description","Content","anchorPosition","contentClassNames","onClick","variant","aria-label","rightIcon"],"mappings":"AAAA,OAAOA,OAAqBC,MAAM,KAAQ,OAAQ,AAElD,QAAOC,SAAU,SAAU,AAC3B,QAAOC,eAAgB,eAAgB,AACvC,QAAOC,OAAQ,aAAc,AAC7B,QAAOC,iBAAkB,iBAAkB,CAE3C,MAAMC,iBAAmB,CACvBC,SAAU,MACVC,OAAQ,CACNC,MAAO,OACPC,KAAM,mBACR,EACAC,YAAa,MACf,CAEA,QAAO,MAAMC,YAOT,CAAC,CACHC,aAAeP,gBAAgB,CAC/BQ,WAAW,CACXC,sBAAsB,CACtBC,YAAY,CACZC,SAAS,CACV,IACC,KAAM,CAAEV,QAAQ,CAAEC,MAAM,CAAE,CAAGK,aAC7B,MAAMK,QAAUjB,OAAwB,MAExC,MAAMkB,kBACJ,oQAEF,MAAMC,wBACJ,6LAEF,MAAMC,cAAgB,AAACC,IACrBA,EAAEC,cAAc,EAChBL,CAAAA,QAAQM,OAAO,EAAEC,QACnB,EAEA,MAAMC,cAAgB,CAAC,CAAET,SAAS,CAAyB,GACzD,oBAACU,KAAEjB,KAAK,aAAaO,UAAWA,WAAW,aAK7C,MAAMW,WACJ,oBAACC,QAAKC,IAAKZ,QAASa,OAAO,OAAOC,OAAQxB,OAAOE,IAAI,CAAEO,UAAU,UAC/D,oBAACgB,SAAMC,KAAK,U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AE"}
|
package/core/Header.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React,{useState,useEffect,useRef,useMemo}from"react";import Icon from"./Icon";import cn from"./utils/cn";import Logo from"./Logo";import{componentMaxHeight,HEADER_BOTTOM_MARGIN,HEADER_HEIGHT}from"./utils/heights";import{HeaderLinks}from"./Header/HeaderLinks";import throttle from"lodash.throttle";const FLEXIBLE_DESKTOP_CLASSES="hidden md:flex flex-1 items-center h-full";const MAX_MOBILE_MENU_WIDTH="560px";const Header=({searchBar,searchButton,logoHref,headerLinks,nav,mobileNav,sessionState,themedScrollpoints=[],searchButtonVisibility="all"})=>{const[showMenu,setShowMenu]=useState(false);const[fadingOut,setFadingOut]=useState(false);const[scrollpointClasses,setScrollpointClasses]=useState("");const menuRef=useRef(null);const closeMenu=()=>{setFadingOut(true);setTimeout(()=>{setShowMenu(false);setFadingOut(false)},150)};useEffect(()=>{const handleResize=()=>{if(window.innerWidth>=1040){setShowMenu(false)}};window.addEventListener("resize",handleResize);return()=>window.removeEventListener("resize",handleResize)},[]);useEffect(()=>{if(showMenu){document.body.classList.add("overflow-hidden")}else{document.body.classList.remove("overflow-hidden")}return()=>{document.body.classList.remove("overflow-hidden")}},[showMenu]);useEffect(()=>{const handleScroll=()=>{for(const scrollpoint of themedScrollpoints){const element=document.getElementById(scrollpoint.id);if(element){const rect=element.getBoundingClientRect();if(rect.top<=HEADER_HEIGHT&&rect.bottom>=HEADER_HEIGHT){setScrollpointClasses(scrollpoint.className);return}}}};const throttledHandleScroll=throttle(handleScroll,150);handleScroll();window.addEventListener("scroll",throttledHandleScroll);return()=>window.removeEventListener("scroll",throttledHandleScroll)},[themedScrollpoints]);const wrappedSearchButton=useMemo(()=>searchButton?React.createElement("div",{className:"text-neutral-1300 dark:text-neutral-000 flex items-center p-6"},searchButton):null,[searchButton]);return React.createElement(React.Fragment,null,React.createElement("header",{role:"banner",className:cn("fixed
|
|
1
|
+
import React,{useState,useEffect,useRef,useMemo}from"react";import Icon from"./Icon";import cn from"./utils/cn";import Logo from"./Logo";import{componentMaxHeight,HEADER_BOTTOM_MARGIN,HEADER_HEIGHT}from"./utils/heights";import{HeaderLinks}from"./Header/HeaderLinks";import throttle from"lodash.throttle";const FLEXIBLE_DESKTOP_CLASSES="hidden md:flex flex-1 items-center h-full";const MAX_MOBILE_MENU_WIDTH="560px";const Header=({searchBar,searchButton,logoHref,headerLinks,nav,mobileNav,sessionState,themedScrollpoints=[],searchButtonVisibility="all",notice,noticeRef})=>{const[showMenu,setShowMenu]=useState(false);const[fadingOut,setFadingOut]=useState(false);const[scrollpointClasses,setScrollpointClasses]=useState("");const[bannerVisible,setBannerVisible]=useState(true);const menuRef=useRef(null);const closeMenu=()=>{setFadingOut(true);setTimeout(()=>{setShowMenu(false);setFadingOut(false)},150)};useEffect(()=>{const handleResize=()=>{if(window.innerWidth>=1040){setShowMenu(false)}};window.addEventListener("resize",handleResize);return()=>window.removeEventListener("resize",handleResize)},[]);useEffect(()=>{if(noticeRef.current&&getComputedStyle(noticeRef.current).overflow==="hidden"){setBannerVisible(false)}},[noticeRef]);useEffect(()=>{if(showMenu){document.body.classList.add("overflow-hidden")}else{document.body.classList.remove("overflow-hidden")}return()=>{document.body.classList.remove("overflow-hidden")}},[showMenu]);useEffect(()=>{const handleScroll=()=>{for(const scrollpoint of themedScrollpoints){const element=document.getElementById(scrollpoint.id);if(element){const rect=element.getBoundingClientRect();if(rect.top<=HEADER_HEIGHT&&rect.bottom>=HEADER_HEIGHT){setScrollpointClasses(scrollpoint.className);return}}}if(window.scrollY>20){setBannerVisible(false)}else{if(!noticeRef.current||noticeRef?.current?.style?.overflow!=="hidden")setBannerVisible(true)}};const throttledHandleScroll=throttle(handleScroll,150);handleScroll();window.addEventListener("scroll",throttledHandleScroll);return()=>window.removeEventListener("scroll",throttledHandleScroll)},[themedScrollpoints]);const wrappedSearchButton=useMemo(()=>searchButton?React.createElement("div",{className:"text-neutral-1300 dark:text-neutral-000 flex items-center p-6"},searchButton):null,[searchButton]);return React.createElement(React.Fragment,null,React.createElement("header",{role:"banner",className:cn("fixed left-0 w-full z-10 bg-neutral-000 dark:bg-neutral-1300 border-b border-neutral-300 dark:border-neutral-1000 transition-colors px-24 md:px-64 ",scrollpointClasses,{"md:top-0 transition-all duration-300":!notice&&!bannerVisible,"md:top-[54px] transition-all duration-300":notice&&bannerVisible}),style:{height:HEADER_HEIGHT}},React.createElement("div",{className:"flex items-center h-full"},React.createElement("nav",{className:"flex flex-1 h-full items-center"},["light","dark"].map(theme=>React.createElement(Logo,{key:theme,href:logoHref,theme:theme,additionalLinkAttrs:{className:cn("h-full focus-base rounded mr-32 w-[108px]",{"flex dark:hidden":theme==="light","hidden dark:flex":theme==="dark"})}})),React.createElement("div",{className:FLEXIBLE_DESKTOP_CLASSES},nav)),React.createElement("div",{className:"flex md:hidden flex-1 items-center justify-end gap-24 h-full"},searchButtonVisibility!=="desktop"?wrappedSearchButton:null,React.createElement("button",{className:"cursor-pointer focus-base rounded flex items-center",onClick:()=>setShowMenu(!showMenu),"aria-expanded":showMenu,"aria-controls":"mobile-menu","aria-label":"Toggle menu"},React.createElement(Icon,{name:showMenu?"icon-gui-x-mark-outline":"icon-gui-bars-3-outline",additionalCSS:"text-neutral-1300 dark:text-neutral-000",size:"1.5rem"}))),searchBar?React.createElement("div",{className:cn(FLEXIBLE_DESKTOP_CLASSES,"justify-center")},searchBar):null,React.createElement(HeaderLinks,{className:FLEXIBLE_DESKTOP_CLASSES,headerLinks:headerLinks,sessionState:sessionState,searchButton:wrappedSearchButton,searchButtonVisibility:searchButtonVisibility}))),showMenu?React.createElement(React.Fragment,null,React.createElement("div",{className:cn("fixed inset-0 bg-neutral-1300 dark:bg-neutral-1300",{"animate-[fade-in-ten-percent_150ms_ease-in-out_forwards]":!fadingOut,"animate-[fade-out-ten-percent_150ms_ease-in-out_forwards]":fadingOut}),onClick:closeMenu,onKeyDown:e=>e.key==="Escape"&&closeMenu(),role:"presentation"}),React.createElement("div",{id:"mobile-menu",className:"md:hidden fixed flex flex-col top-[76px] overflow-y-hidden mx-12 right-0 w-[calc(100%-24px)] bg-neutral-000 dark:bg-neutral-1300 rounded-2xl ui-shadow-lg-medium z-20",style:{maxWidth:MAX_MOBILE_MENU_WIDTH,maxHeight:componentMaxHeight(HEADER_HEIGHT,HEADER_BOTTOM_MARGIN)},ref:menuRef,role:"navigation"},mobileNav,React.createElement(HeaderLinks,{headerLinks:headerLinks,sessionState:sessionState}))):null)};export default Header;
|
|
2
2
|
//# sourceMappingURL=Header.js.map
|
package/core/Header.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Header.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, ReactNode, useMemo } from \"react\";\nimport Icon from \"./Icon\";\nimport cn from \"./utils/cn\";\nimport Logo from \"./Logo\";\nimport {\n componentMaxHeight,\n HEADER_BOTTOM_MARGIN,\n HEADER_HEIGHT,\n} from \"./utils/heights\";\nimport { HeaderLinks } from \"./Header/HeaderLinks\";\nimport throttle from \"lodash.throttle\";\nimport { Theme } from \"./styles/colors/types\";\n\nexport type ThemedScrollpoint = {\n id: string;\n className: string;\n};\n\n/**\n * Props for the Header component.\n */\nexport type HeaderProps = {\n /**\n * Optional search bar element.\n */\n searchBar?: ReactNode;\n\n /**\n * Optional search button element.\n */\n searchButton?: ReactNode;\n\n /**\n * URL for the logo link.\n */\n logoHref?: string;\n\n /**\n * Array of header links.\n */\n headerLinks?: {\n /**\n * URL for the link.\n */\n href: string;\n\n /**\n * Label for the link.\n */\n label: string;\n\n /**\n * Indicates if the link should open in a new tab.\n */\n external?: boolean;\n }[];\n\n /**\n * Optional desktop navigation element.\n */\n nav?: ReactNode;\n\n /**\n * Optional mobile navigation element.\n */\n mobileNav?: ReactNode;\n\n /**\n * State of the user session.\n */\n sessionState?: {\n /**\n * Indicates if the user is signed in.\n */\n signedIn: boolean;\n\n /**\n * Account information.\n */\n account: {\n /**\n * Links related to the account.\n */\n links: {\n /**\n * Dashboard link information.\n */\n dashboard: {\n /**\n * URL for the dashboard link.\n */\n href: string;\n };\n };\n };\n };\n\n /**\n * Array of themed scrollpoints. The header will change its appearance based on the scrollpoint in view.\n */\n themedScrollpoints?: ThemedScrollpoint[];\n\n /**\n * Visibility setting for the search button.\n * - \"all\": Visible on all devices.\n * - \"desktop\": Visible only on desktop devices.\n * - \"mobile\": Visible only on mobile devices.\n */\n searchButtonVisibility?: \"all\" | \"desktop\" | \"mobile\";\n};\n\nconst FLEXIBLE_DESKTOP_CLASSES = \"hidden md:flex flex-1 items-center h-full\";\n\n/**\n * Maximum width before the menu expanded into full width\n */\nconst MAX_MOBILE_MENU_WIDTH = \"560px\";\n\nconst Header: React.FC<HeaderProps> = ({\n searchBar,\n searchButton,\n logoHref,\n headerLinks,\n nav,\n mobileNav,\n sessionState,\n themedScrollpoints = [],\n searchButtonVisibility = \"all\",\n}) => {\n const [showMenu, setShowMenu] = useState(false);\n const [fadingOut, setFadingOut] = useState(false);\n const [scrollpointClasses, setScrollpointClasses] = useState<string>(\"\");\n const menuRef = useRef<HTMLDivElement>(null);\n\n const closeMenu = () => {\n setFadingOut(true);\n\n setTimeout(() => {\n setShowMenu(false);\n setFadingOut(false);\n }, 150);\n };\n\n useEffect(() => {\n const handleResize = () => {\n if (window.innerWidth >= 1040) {\n setShowMenu(false);\n }\n };\n\n window.addEventListener(\"resize\", handleResize);\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n useEffect(() => {\n if (showMenu) {\n document.body.classList.add(\"overflow-hidden\");\n } else {\n document.body.classList.remove(\"overflow-hidden\");\n }\n\n // Cleanup on unmount\n return () => {\n document.body.classList.remove(\"overflow-hidden\");\n };\n }, [showMenu]);\n\n useEffect(() => {\n const handleScroll = () => {\n for (const scrollpoint of themedScrollpoints) {\n const element = document.getElementById(scrollpoint.id);\n if (element) {\n const rect = element.getBoundingClientRect();\n if (rect.top <= HEADER_HEIGHT && rect.bottom >= HEADER_HEIGHT) {\n setScrollpointClasses(scrollpoint.className);\n return;\n }\n }\n }\n };\n\n const throttledHandleScroll = throttle(handleScroll, 150);\n\n handleScroll();\n\n window.addEventListener(\"scroll\", throttledHandleScroll);\n return () => window.removeEventListener(\"scroll\", throttledHandleScroll);\n }, [themedScrollpoints]);\n\n const wrappedSearchButton = useMemo(\n () =>\n searchButton ? (\n <div className=\"text-neutral-1300 dark:text-neutral-000 flex items-center p-6\">\n {searchButton}\n </div>\n ) : null,\n [searchButton],\n );\n\n return (\n <>\n <header\n role=\"banner\"\n className={cn(\n \"fixed top-0 left-0 w-full z-10 bg-neutral-000 dark:bg-neutral-1300 border-b border-neutral-300 transition-colors px-24 md:px-64\",\n scrollpointClasses,\n )}\n style={{ height: HEADER_HEIGHT }}\n >\n <div className=\"flex items-center h-full\">\n <nav className=\"flex flex-1 h-full items-center\">\n {([\"light\", \"dark\"] as Theme[]).map((theme) => (\n <Logo\n key={theme}\n href={logoHref}\n theme={theme}\n additionalLinkAttrs={{\n className: cn(\"h-full focus-base rounded mr-32 w-[108px]\", {\n \"flex dark:hidden\": theme === \"light\",\n \"hidden dark:flex\": theme === \"dark\",\n }),\n }}\n />\n ))}\n <div className={FLEXIBLE_DESKTOP_CLASSES}>{nav}</div>\n </nav>\n <div className=\"flex md:hidden flex-1 items-center justify-end gap-24 h-full\">\n {searchButtonVisibility !== \"desktop\" ? wrappedSearchButton : null}\n <button\n className=\"cursor-pointer focus-base rounded flex items-center\"\n onClick={() => setShowMenu(!showMenu)}\n aria-expanded={showMenu}\n aria-controls=\"mobile-menu\"\n aria-label=\"Toggle menu\"\n >\n <Icon\n name={\n showMenu\n ? \"icon-gui-x-mark-outline\"\n : \"icon-gui-bars-3-outline\"\n }\n additionalCSS=\"text-neutral-1300 dark:text-neutral-000\"\n size=\"1.5rem\"\n />\n </button>\n </div>\n {searchBar ? (\n <div className={cn(FLEXIBLE_DESKTOP_CLASSES, \"justify-center\")}>\n {searchBar}\n </div>\n ) : null}\n <HeaderLinks\n className={FLEXIBLE_DESKTOP_CLASSES}\n headerLinks={headerLinks}\n sessionState={sessionState}\n searchButton={wrappedSearchButton}\n searchButtonVisibility={searchButtonVisibility}\n />\n </div>\n </header>\n {showMenu ? (\n <>\n <div\n className={cn(\n \"fixed inset-0 bg-neutral-1300 dark:bg-neutral-1300\",\n {\n \"animate-[fade-in-ten-percent_150ms_ease-in-out_forwards]\":\n !fadingOut,\n \"animate-[fade-out-ten-percent_150ms_ease-in-out_forwards]\":\n fadingOut,\n },\n )}\n onClick={closeMenu}\n onKeyDown={(e) => e.key === \"Escape\" && closeMenu()}\n role=\"presentation\"\n />\n <div\n id=\"mobile-menu\"\n className=\"md:hidden fixed flex flex-col top-[76px] overflow-y-hidden mx-12 right-0 w-[calc(100%-24px)] bg-neutral-000 dark:bg-neutral-1300 rounded-2xl ui-shadow-lg-medium z-20\"\n style={{\n maxWidth: MAX_MOBILE_MENU_WIDTH,\n maxHeight: componentMaxHeight(\n HEADER_HEIGHT,\n HEADER_BOTTOM_MARGIN,\n ),\n }}\n ref={menuRef}\n role=\"navigation\"\n >\n {mobileNav}\n <HeaderLinks\n headerLinks={headerLinks}\n sessionState={sessionState}\n />\n </div>\n </>\n ) : null}\n </>\n );\n};\n\nexport default Header;\n"],"names":["React","useState","useEffect","useRef","useMemo","Icon","cn","Logo","componentMaxHeight","HEADER_BOTTOM_MARGIN","HEADER_HEIGHT","HeaderLinks","throttle","FLEXIBLE_DESKTOP_CLASSES","MAX_MOBILE_MENU_WIDTH","Header","searchBar","searchButton","logoHref","headerLinks","nav","mobileNav","sessionState","themedScrollpoints","searchButtonVisibility","showMenu","setShowMenu","fadingOut","setFadingOut","scrollpointClasses","setScrollpointClasses","menuRef","closeMenu","setTimeout","handleResize","window","innerWidth","addEventListener","removeEventListener","document","body","classList","add","remove","handleScroll","scrollpoint","element","getElementById","id","rect","getBoundingClientRect","top","bottom","className","throttledHandleScroll","wrappedSearchButton","div","header","role","style","height","map","theme","key","href","additionalLinkAttrs","button","onClick","aria-expanded","aria-controls","aria-label","name","additionalCSS","size","onKeyDown","e","maxWidth","maxHeight","ref"],"mappings":"AAAA,OAAOA,OAASC,QAAQ,CAAEC,SAAS,CAAEC,MAAM,CAAaC,OAAO,KAAQ,OAAQ,AAC/E,QAAOC,SAAU,QAAS,AAC1B,QAAOC,OAAQ,YAAa,AAC5B,QAAOC,SAAU,QAAS,AAC1B,QACEC,kBAAkB,CAClBC,oBAAoB,CACpBC,aAAa,KACR,iBAAkB,AACzB,QAASC,WAAW,KAAQ,sBAAuB,AACnD,QAAOC,aAAc,iBAAkB,CAqGvC,MAAMC,yBAA2B,4CAKjC,MAAMC,sBAAwB,QAE9B,MAAMC,OAAgC,CAAC,CACrCC,SAAS,CACTC,YAAY,CACZC,QAAQ,CACRC,WAAW,CACXC,GAAG,CACHC,SAAS,CACTC,YAAY,CACZC,mBAAqB,EAAE,CACvBC,uBAAyB,KAAK,CAC/B,IACC,KAAM,CAACC,SAAUC,YAAY,CAAGzB,SAAS,OACzC,KAAM,CAAC0B,UAAWC,aAAa,CAAG3B,SAAS,OAC3C,KAAM,CAAC4B,mBAAoBC,sBAAsB,CAAG7B,SAAiB,IACrE,MAAM8B,QAAU5B,OAAuB,MAEvC,MAAM6B,UAAY,KAChBJ,aAAa,MAEbK,WAAW,KACTP,YAAY,OACZE,aAAa,MACf,EAAG,IACL,EAEA1B,UAAU,KACR,MAAMgC,aAAe,KACnB,GAAIC,OAAOC,UAAU,EAAI,KAAM,CAC7BV,YAAY,MACd,CACF,EAEAS,OAAOE,gBAAgB,CAAC,SAAUH,cAClC,MAAO,IAAMC,OAAOG,mBAAmB,CAAC,SAAUJ,aACpD,EAAG,EAAE,EAELhC,UAAU,KACR,GAAIuB,SAAU,CACZc,SAASC,IAAI,CAACC,SAAS,CAACC,GAAG,CAAC,kBAC9B,KAAO,CACLH,SAASC,IAAI,CAACC,SAAS,CAACE,MAAM,CAAC,kBACjC,CAGA,MAAO,KACLJ,SAASC,IAAI,CAACC,SAA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,KACE9C,SACI,0BACA,0BAEN+C,cAAc,0CACdC,KAAK,aAIVzD,UACC,oBAACwC,OAAIH,UAAW/C,GAAGO,yBAA0B,mBAC1CG,WAED,KACJ,oBAACL,aACC0C,UAAWxC,yBACXM,YAAaA,YACbG,aAAcA,aACdL,aAAcsC,oBACd/B,uBAAwBA,2BAI7BC,SACC,wCACE,oBAAC+B,OACCH,UAAW/C,GACT,qDACA,CACE,2DACE,CAACqB,UACH,4DACEA,SACJ,GAEFwC,QAASnC,UACT0C,UAAW,AAACC,GAAMA,EAAEZ,GAAG,GAAK,UAAY/B,YACxC0B,KAAK,iBAEP,oBAACF,OACCR,GAAG,cACHK,UAAU,wKACVM,MAAO,CACLiB,SAAU9D,sBACV+D,UAAWrE,mBACTE,cACAD,qBAEJ,EACAqE,IAAK/C,QACL2B,KAAK,cAEJrC,UACD,oBAACV,aACCQ,YAAaA,YACbG,aAAcA,iBAIlB,KAGV,CAEA,gBAAeP,MAAO"}
|
|
1
|
+
{"version":3,"sources":["../../src/core/Header.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, ReactNode, useMemo } from \"react\";\nimport Icon from \"./Icon\";\nimport cn from \"./utils/cn\";\nimport Logo from \"./Logo\";\nimport {\n componentMaxHeight,\n HEADER_BOTTOM_MARGIN,\n HEADER_HEIGHT,\n} from \"./utils/heights\";\nimport { HeaderLinks } from \"./Header/HeaderLinks\";\nimport throttle from \"lodash.throttle\";\nimport { Theme } from \"./styles/colors/types\";\nimport { NoticeProps } from \"./Notice\";\n\nexport type ThemedScrollpoint = {\n id: string;\n className: string;\n};\n\n/**\n * Represents the state of the user session in the header.\n */\nexport type HeaderSessionState = {\n /**\n * Indicates if the user is signed in.\n */\n signedIn: boolean;\n\n /**\n * Information required to log out the user.\n */\n logOut: {\n /**\n * Token used for logging out.\n */\n token: string;\n\n /**\n * URL to log out the user.\n */\n href: string;\n };\n\n /**\n * Name of the user's account.\n */\n accountName: string;\n};\n\n/**\n * Props for the Header component.\n */\nexport type HeaderProps = {\n /**\n * Optional search bar element.\n */\n searchBar?: ReactNode;\n\n /**\n * Optional search button element.\n */\n searchButton?: ReactNode;\n\n /**\n * URL for the logo link.\n */\n logoHref?: string;\n\n /**\n * Array of header links.\n */\n headerLinks?: {\n /**\n * URL for the link.\n */\n href: string;\n\n /**\n * Label for the link.\n */\n label: string;\n\n /**\n * Indicates if the link should open in a new tab.\n */\n external?: boolean;\n }[];\n\n /**\n * Optional desktop navigation element.\n */\n nav?: ReactNode;\n\n /**\n * Optional mobile navigation element.\n */\n mobileNav?: ReactNode;\n\n /**\n * State of the user session.\n */\n sessionState?: HeaderSessionState;\n\n /**\n * Array of themed scrollpoints. The header will change its appearance based on the scrollpoint in view.\n */\n themedScrollpoints?: ThemedScrollpoint[];\n\n /**\n * Visibility setting for the search button.\n * - \"all\": Visible on all devices.\n * - \"desktop\": Visible only on desktop devices.\n * - \"mobile\": Visible only on mobile devices.\n */\n searchButtonVisibility?: \"all\" | \"desktop\" | \"mobile\";\n /**\n Props for the notice component to be displayed in the header.\n */\n notice: NoticeProps;\n /**\n Reference to the notice DOM element for handling visibility and overflow.\n */\n noticeRef: React.RefObject<HTMLDivElement>;\n};\n\nconst FLEXIBLE_DESKTOP_CLASSES = \"hidden md:flex flex-1 items-center h-full\";\n\n/**\n * Maximum width before the menu expanded into full width\n */\nconst MAX_MOBILE_MENU_WIDTH = \"560px\";\n\nconst Header: React.FC<HeaderProps> = ({\n searchBar,\n searchButton,\n logoHref,\n headerLinks,\n nav,\n mobileNav,\n sessionState,\n themedScrollpoints = [],\n searchButtonVisibility = \"all\",\n notice,\n noticeRef,\n}) => {\n const [showMenu, setShowMenu] = useState(false);\n const [fadingOut, setFadingOut] = useState(false);\n const [scrollpointClasses, setScrollpointClasses] = useState<string>(\"\");\n const [bannerVisible, setBannerVisible] = useState(true);\n const menuRef = useRef<HTMLDivElement>(null);\n\n const closeMenu = () => {\n setFadingOut(true);\n\n setTimeout(() => {\n setShowMenu(false);\n setFadingOut(false);\n }, 150);\n };\n\n useEffect(() => {\n const handleResize = () => {\n if (window.innerWidth >= 1040) {\n setShowMenu(false);\n }\n };\n window.addEventListener(\"resize\", handleResize);\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n useEffect(() => {\n if (\n noticeRef.current &&\n getComputedStyle(noticeRef.current).overflow === \"hidden\"\n ) {\n setBannerVisible(false);\n }\n }, [noticeRef]);\n\n useEffect(() => {\n if (showMenu) {\n document.body.classList.add(\"overflow-hidden\");\n } else {\n document.body.classList.remove(\"overflow-hidden\");\n }\n\n // Cleanup on unmount\n return () => {\n document.body.classList.remove(\"overflow-hidden\");\n };\n }, [showMenu]);\n\n useEffect(() => {\n const handleScroll = () => {\n for (const scrollpoint of themedScrollpoints) {\n const element = document.getElementById(scrollpoint.id);\n if (element) {\n const rect = element.getBoundingClientRect();\n if (rect.top <= HEADER_HEIGHT && rect.bottom >= HEADER_HEIGHT) {\n setScrollpointClasses(scrollpoint.className);\n return;\n }\n }\n }\n if (window.scrollY > 20) {\n setBannerVisible(false);\n } else {\n if (\n !noticeRef.current ||\n noticeRef?.current?.style?.overflow !== \"hidden\"\n )\n setBannerVisible(true);\n }\n };\n\n const throttledHandleScroll = throttle(handleScroll, 150);\n\n handleScroll();\n\n window.addEventListener(\"scroll\", throttledHandleScroll);\n return () => window.removeEventListener(\"scroll\", throttledHandleScroll);\n }, [themedScrollpoints]);\n\n const wrappedSearchButton = useMemo(\n () =>\n searchButton ? (\n <div className=\"text-neutral-1300 dark:text-neutral-000 flex items-center p-6\">\n {searchButton}\n </div>\n ) : null,\n [searchButton],\n );\n\n return (\n <>\n <header\n role=\"banner\"\n className={cn(\n \"fixed left-0 w-full z-10 bg-neutral-000 dark:bg-neutral-1300 border-b border-neutral-300 dark:border-neutral-1000 transition-colors px-24 md:px-64 \",\n scrollpointClasses,\n {\n \"md:top-0 transition-all duration-300\": !notice && !bannerVisible,\n \"md:top-[54px] transition-all duration-300\":\n notice && bannerVisible,\n },\n )}\n style={{ height: HEADER_HEIGHT }}\n >\n <div className=\"flex items-center h-full\">\n <nav className=\"flex flex-1 h-full items-center\">\n {([\"light\", \"dark\"] as Theme[]).map((theme) => (\n <Logo\n key={theme}\n href={logoHref}\n theme={theme}\n additionalLinkAttrs={{\n className: cn(\"h-full focus-base rounded mr-32 w-[108px]\", {\n \"flex dark:hidden\": theme === \"light\",\n \"hidden dark:flex\": theme === \"dark\",\n }),\n }}\n />\n ))}\n <div className={FLEXIBLE_DESKTOP_CLASSES}>{nav}</div>\n </nav>\n <div className=\"flex md:hidden flex-1 items-center justify-end gap-24 h-full\">\n {searchButtonVisibility !== \"desktop\" ? wrappedSearchButton : null}\n <button\n className=\"cursor-pointer focus-base rounded flex items-center\"\n onClick={() => setShowMenu(!showMenu)}\n aria-expanded={showMenu}\n aria-controls=\"mobile-menu\"\n aria-label=\"Toggle menu\"\n >\n <Icon\n name={\n showMenu\n ? \"icon-gui-x-mark-outline\"\n : \"icon-gui-bars-3-outline\"\n }\n additionalCSS=\"text-neutral-1300 dark:text-neutral-000\"\n size=\"1.5rem\"\n />\n </button>\n </div>\n {searchBar ? (\n <div className={cn(FLEXIBLE_DESKTOP_CLASSES, \"justify-center\")}>\n {searchBar}\n </div>\n ) : null}\n <HeaderLinks\n className={FLEXIBLE_DESKTOP_CLASSES}\n headerLinks={headerLinks}\n sessionState={sessionState}\n searchButton={wrappedSearchButton}\n searchButtonVisibility={searchButtonVisibility}\n />\n </div>\n </header>\n {showMenu ? (\n <>\n <div\n className={cn(\n \"fixed inset-0 bg-neutral-1300 dark:bg-neutral-1300\",\n {\n \"animate-[fade-in-ten-percent_150ms_ease-in-out_forwards]\":\n !fadingOut,\n \"animate-[fade-out-ten-percent_150ms_ease-in-out_forwards]\":\n fadingOut,\n },\n )}\n onClick={closeMenu}\n onKeyDown={(e) => e.key === \"Escape\" && closeMenu()}\n role=\"presentation\"\n />\n <div\n id=\"mobile-menu\"\n className=\"md:hidden fixed flex flex-col top-[76px] overflow-y-hidden mx-12 right-0 w-[calc(100%-24px)] bg-neutral-000 dark:bg-neutral-1300 rounded-2xl ui-shadow-lg-medium z-20\"\n style={{\n maxWidth: MAX_MOBILE_MENU_WIDTH,\n maxHeight: componentMaxHeight(\n HEADER_HEIGHT,\n HEADER_BOTTOM_MARGIN,\n ),\n }}\n ref={menuRef}\n role=\"navigation\"\n >\n {mobileNav}\n <HeaderLinks\n headerLinks={headerLinks}\n sessionState={sessionState}\n />\n </div>\n </>\n ) : null}\n </>\n );\n};\n\nexport default Header;\n"],"names":["React","useState","useEffect","useRef","useMemo","Icon","cn","Logo","componentMaxHeight","HEADER_BOTTOM_MARGIN","HEADER_HEIGHT","HeaderLinks","throttle","FLEXIBLE_DESKTOP_CLASSES","MAX_MOBILE_MENU_WIDTH","Header","searchBar","searchButton","logoHref","headerLinks","nav","mobileNav","sessionState","themedScrollpoints","searchButtonVisibility","notice","noticeRef","showMenu","setShowMenu","fadingOut","setFadingOut","scrollpointClasses","setScrollpointClasses","bannerVisible","setBannerVisible","menuRef","closeMenu","setTimeout","handleResize","window","innerWidth","addEventListener","removeEventListener","current","getComputedStyle","overflow","document","body","classList","add","remove","handleScroll","scrollpoint","element","getElementById","id","rect","getBoundingClientRect","top","bottom","className","scrollY","style","throttledHandleScroll","wrappedSearchButton","div","header","role","height","map","theme","key","href","additionalLinkAttrs","button","onClick","aria-expanded","aria-controls","aria-label","name","additionalCSS","size","onKeyDown","e","maxWidth","maxHeight","ref"],"mappings":"AAAA,OAAOA,OAASC,QAAQ,CAAEC,SAAS,CAAEC,MAAM,CAAaC,OAAO,KAAQ,OAAQ,AAC/E,QAAOC,SAAU,QAAS,AAC1B,QAAOC,OAAQ,YAAa,AAC5B,QAAOC,SAAU,QAAS,AAC1B,QACEC,kBAAkB,CAClBC,oBAAoB,CACpBC,aAAa,KACR,iBAAkB,AACzB,QAASC,WAAW,KAAQ,sBAAuB,AACnD,QAAOC,aAAc,iBAAkB,CAmHvC,MAAMC,yBAA2B,4CAKjC,MA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kD,gBAAc,cACdC,aAAW,eAEX,oBAACzE,MACC0E,KACEpD,SACI,0BACA,0BAENqD,cAAc,0CACdC,KAAK,aAIVjE,UACC,oBAACiD,OAAIL,UAAWtD,GAAGO,yBAA0B,mBAC1CG,WAED,KACJ,oBAACL,aACCiD,UAAW/C,yBACXM,YAAaA,YACbG,aAAcA,aACdL,aAAc+C,oBACdxC,uBAAwBA,2BAI7BG,SACC,wCACE,oBAACsC,OACCL,UAAWtD,GACT,qDACA,CACE,2DACE,CAACuB,UACH,4DACEA,SACJ,GAEF8C,QAASvC,UACT8C,UAAW,AAACC,GAAMA,EAAEZ,GAAG,GAAK,UAAYnC,YACxC+B,KAAK,iBAEP,oBAACF,OACCV,GAAG,cACHK,UAAU,wKACVE,MAAO,CACLsB,SAAUtE,sBACVuE,UAAW7E,mBACTE,cACAD,qBAEJ,EACA6E,IAAKnD,QACLgC,KAAK,cAEJ9C,UACD,oBAACV,aACCQ,YAAaA,YACbG,aAAcA,iBAIlB,KAGV,CAEA,gBAAeP,MAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{queryIdAll}from"../../dom-query";import{selectRecentBlogPosts}from"../../remote-blogs-posts";import{connectState}from"../../remote-data-store";const template=({link,title,pubDate})=>{const[li,a,heading,copy]=["li","a","p","p"].map(el=>document.createElement(el));a.href=link;a.classList.add("ui-meganav-media","group");heading.textContent=title;heading.classList.add("ui-meganav-media-heading");copy.textContent=pubDate;copy.classList.add("ui-meganav-media-copy");a.appendChild(heading);a.appendChild(copy);li.appendChild(a);return li};export default(()=>{connectState(selectRecentBlogPosts,recentBlogPosts=>{if(Array.isArray(recentBlogPosts)&&recentBlogPosts.length>0){const sections=queryIdAll("meganav-company-panel-blog-section");const containers=queryIdAll("meganav-company-panel-recent-blog-posts");Array.from(containers).forEach(container=>{const fragment=document.createDocumentFragment();recentBlogPosts.forEach(post=>fragment.appendChild(template(post)));container.appendChild(fragment)});Array.from(sections).forEach(section=>section.classList.remove("hidden"))}})});
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/LegacyMeganav/MeganavBlogPostsList/component.js"],"sourcesContent":["import { queryIdAll } from \"../../dom-query\";\nimport { selectRecentBlogPosts } from \"../../remote-blogs-posts\";\nimport { connectState } from \"../../remote-data-store\";\n\nconst template = ({ link, title, pubDate }) => {\n const [li, a, heading, copy] = [\"li\", \"a\", \"p\", \"p\"].map((el) =>\n document.createElement(el),\n );\n\n a.href = link;\n a.classList.add(\"ui-meganav-media\", \"group\");\n\n heading.textContent = title;\n heading.classList.add(\"ui-meganav-media-heading\");\n\n copy.textContent = pubDate;\n copy.classList.add(\"ui-meganav-media-copy\");\n\n a.appendChild(heading);\n a.appendChild(copy);\n li.appendChild(a);\n\n return li;\n};\n\nexport default () => {\n connectState(selectRecentBlogPosts, (recentBlogPosts) => {\n if (Array.isArray(recentBlogPosts) && recentBlogPosts.length > 0) {\n const sections = queryIdAll(\"meganav-company-panel-blog-section\");\n const containers = queryIdAll(\"meganav-company-panel-recent-blog-posts\");\n\n Array.from(containers).forEach((container) => {\n const fragment = document.createDocumentFragment();\n recentBlogPosts.forEach((post) => fragment.appendChild(template(post)));\n container.appendChild(fragment);\n });\n\n Array.from(sections).forEach((section) =>\n section.classList.remove(\"hidden\"),\n );\n }\n });\n};\n"],"names":["queryIdAll","selectRecentBlogPosts","connectState","template","link","title","pubDate","li","a","heading","copy","map","el","document","createElement","href","classList","add","textContent","appendChild","recentBlogPosts","Array","isArray","length","sections","containers","from","forEach","container","fragment","createDocumentFragment","post","section","remove"],"mappings":"AAAA,OAASA,UAAU,KAAQ,iBAAkB,AAC7C,QAASC,qBAAqB,KAAQ,0BAA2B,AACjE,QAASC,YAAY,KAAQ,yBAA0B,CAEvD,MAAMC,SAAW,CAAC,CAAEC,IAAI,CAAEC,KAAK,CAAEC,OAAO,CAAE,IACxC,KAAM,CAACC,GAAIC,EAAGC,QAASC,KAAK,CAAG,CAAC,KAAM,IAAK,IAAK,IAAI,CAACC,GAAG,CAAC,AAACC,IACxDC,SAASC,aAAa,CAACF,IAGzBJ,CAAAA,EAAEO,IAAI,CAAGX,KACTI,EAAEQ,SAAS,CAACC,GAAG,CAAC,mBAAoB,QAEpCR,CAAAA,QAAQS,WAAW,CAAGb,MACtBI,QAAQO,SAAS,CAACC,GAAG,CAAC,2BAEtBP,CAAAA,KAAKQ,WAAW,CAAGZ,QACnBI,KAAKM,SAAS,CAACC,GAAG,CAAC,yBAEnBT,EAAEW,WAAW,CAACV,SACdD,EAAEW,WAAW,CAACT,MACdH,GAAGY,WAAW,CAACX,GAEf,OAAOD,EACT,CAEA,eAAe,CAAA,KACbL,aAAaD,sBAAuB,AAACmB,kBACnC,GAAIC,MAAMC,OAAO,CAACF,kBAAoBA,gBAAgBG,MAAM,CAAG,EAAG,CAChE,MAAMC,SAAWxB,WAAW,sCAC5B,MAAMyB,WAAazB,WAAW,2CAE9BqB,MAAMK,IAAI,CAACD,YAAYE,OAAO,CAAC,AAACC,YAC9B,MAAMC,SAAWhB,SAASiB,sBAAsB,GAChDV,gBAAgBO,OAAO,CAAC,AAACI,MAASF,SAASV,WAAW,CAAChB,SAAS4B,QAChEH,UAAUT,WAAW,CAACU,SACxB,GAEAR,MAAMK,IAAI,CAACF,UAAUG,OAAO,CAAC,AAACK,SAC5BA,QAAQhB,SAAS,CAACiB,MAAM,CAAC,UAE7B,CACF,EACF,CAAA,CAAE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{queryId,queryIdAll}from"../../dom-query";const MeganavControl=()=>{const controls=Array.from(queryIdAll("meganav-control"));const panels=Array.from(queryIdAll("meganav-panel"));const mdBreakpoint=getComputedStyle(document.documentElement).getPropertyValue("--bp-md");const hoverEnabled=()=>window.matchMedia(`(hover: hover) and (pointer: fine) and (min-width: ${mdBreakpoint})`).matches;const isSearchControl=node=>node.dataset.control==="search";const isSearchPanelOpen=()=>{const searchPanel=document.querySelector('[data-id="meganav-panel"]#panel-search');if(!searchPanel)return;return!searchPanel.classList.contains("invisible")};const controlsHaveFocus=()=>controls.some(control=>control===document.activeElement);const hover=(control,panel,open)=>{if(hoverEnabled()&&!controlsHaveFocus()&&!isSearchPanelOpen()){const classes=["invisible","visible"];panel.classList.replace(...open?classes:classes.reverse());control.setAttribute("aria-expanded",open);control.dataset.hover=open}};const mouseenterHandler=(control,panel)=>()=>hover(control,panel,true);const mouseleaveHandler=(control,panel)=>()=>hover(control,panel,false);const clickHandler=(control,panel)=>()=>{controls.forEach(node=>node!==control&&node.setAttribute("aria-expanded",false));panels.forEach(node=>node!==panel&&node.classList.replace("visible","invisible"));const ariaExpanded=control.getAttribute("aria-expanded");const openedByHover=control.dataset.hover==="true";if(ariaExpanded==="true"&&!openedByHover){control.setAttribute("aria-expanded",false);panel.classList.replace("visible","invisible")}else{control.setAttribute("aria-expanded",true);panel.classList.replace("invisible","visible")}if(openedByHover){control.dataset.hover=false}if(isSearchControl(control)){const searchInput=queryId("meganav-search-input",panel);if(!searchInput)return;searchInput.focus()}else{control.focus()}};return controls.map(control=>{const item=control.parentNode;const panel=document.querySelector(`#${control.getAttribute("aria-controls")}`);const click=clickHandler(control,panel);control.addEventListener("click",click);let mouseenter,mouseleave;if(!isSearchControl(control)){mouseenter=mouseenterHandler(control,panel);mouseleave=mouseleaveHandler(control,panel);item.addEventListener("mouseenter",mouseenter);item.addEventListener("mouseleave",mouseleave)}return[{teardown:()=>{if(mouseenter&&mouseleave){item.removeEventListener("mouseenter",mouseenter);item.removeEventListener("mouseleave",mouseleave)}control.removeEventListener("click",click)},clear:()=>{control.setAttribute("aria-expanded",false);panel.classList.replace("visible","invisible")}}]}).flat()};export default MeganavControl;
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/LegacyMeganav/MeganavControl/component.js"],"sourcesContent":["import { queryId, queryIdAll } from \"../../dom-query\";\n\nconst MeganavControl = () => {\n const controls = Array.from(queryIdAll(\"meganav-control\"));\n const panels = Array.from(queryIdAll(\"meganav-panel\"));\n const mdBreakpoint = getComputedStyle(\n document.documentElement,\n ).getPropertyValue(\"--bp-md\");\n\n const hoverEnabled = () =>\n window.matchMedia(\n `(hover: hover) and (pointer: fine) and (min-width: ${mdBreakpoint})`,\n ).matches;\n\n const isSearchControl = (node) => node.dataset.control === \"search\";\n\n const isSearchPanelOpen = () => {\n const searchPanel = document.querySelector(\n '[data-id=\"meganav-panel\"]#panel-search',\n );\n if (!searchPanel) return;\n return !searchPanel.classList.contains(\"invisible\");\n };\n\n const controlsHaveFocus = () =>\n controls.some((control) => control === document.activeElement);\n\n const hover = (control, panel, open) => {\n if (hoverEnabled() && !controlsHaveFocus() && !isSearchPanelOpen()) {\n const classes = [\"invisible\", \"visible\"];\n panel.classList.replace(...(open ? classes : classes.reverse()));\n control.setAttribute(\"aria-expanded\", open);\n control.dataset.hover = open;\n }\n };\n\n const mouseenterHandler = (control, panel) => () =>\n hover(control, panel, true);\n\n const mouseleaveHandler = (control, panel) => () =>\n hover(control, panel, false);\n\n const clickHandler = (control, panel) => () => {\n controls.forEach(\n (node) => node !== control && node.setAttribute(\"aria-expanded\", false),\n );\n\n panels.forEach(\n (node) =>\n node !== panel && node.classList.replace(\"visible\", \"invisible\"),\n );\n\n const ariaExpanded = control.getAttribute(\"aria-expanded\");\n\n // Prevent closing of the panel if it was already opened by hovering\n const openedByHover = control.dataset.hover === \"true\";\n\n if (ariaExpanded === \"true\" && !openedByHover) {\n control.setAttribute(\"aria-expanded\", false);\n panel.classList.replace(\"visible\", \"invisible\");\n } else {\n control.setAttribute(\"aria-expanded\", true);\n panel.classList.replace(\"invisible\", \"visible\");\n }\n\n if (openedByHover) {\n control.dataset.hover = false;\n }\n\n if (isSearchControl(control)) {\n const searchInput = queryId(\"meganav-search-input\", panel);\n if (!searchInput) return;\n searchInput.focus();\n } else {\n control.focus();\n }\n };\n\n return controls\n .map((control) => {\n const item = control.parentNode;\n const panel = document.querySelector(\n `#${control.getAttribute(\"aria-controls\")}`,\n );\n const click = clickHandler(control, panel);\n control.addEventListener(\"click\", click);\n let mouseenter, mouseleave;\n\n if (!isSearchControl(control)) {\n mouseenter = mouseenterHandler(control, panel);\n mouseleave = mouseleaveHandler(control, panel);\n\n item.addEventListener(\"mouseenter\", mouseenter);\n item.addEventListener(\"mouseleave\", mouseleave);\n }\n\n return [\n {\n teardown: () => {\n if (mouseenter && mouseleave) {\n item.removeEventListener(\"mouseenter\", mouseenter);\n item.removeEventListener(\"mouseleave\", mouseleave);\n }\n\n control.removeEventListener(\"click\", click);\n },\n clear: () => {\n control.setAttribute(\"aria-expanded\", false);\n panel.classList.replace(\"visible\", \"invisible\");\n },\n },\n ];\n })\n .flat();\n};\n\nexport default MeganavControl;\n"],"names":["queryId","queryIdAll","MeganavControl","controls","Array","from","panels","mdBreakpoint","getComputedStyle","document","documentElement","getPropertyValue","hoverEnabled","window","matchMedia","matches","isSearchControl","node","dataset","control","isSearchPanelOpen","searchPanel","querySelector","classList","contains","controlsHaveFocus","some","activeElement","hover","panel","open","classes","replace","reverse","setAttribute","mouseenterHandler","mouseleaveHandler","clickHandler","forEach","ariaExpanded","getAttribute","openedByHover","searchInput","focus","map","item","parentNode","click","addEventListener","mouseenter","mouseleave","teardown","removeEventListener","clear","flat"],"mappings":"AAAA,OAASA,OAAO,CAAEC,UAAU,KAAQ,iBAAkB,CAEtD,MAAMC,eAAiB,KACrB,MAAMC,SAAWC,MAAMC,IAAI,CAACJ,WAAW,oBACvC,MAAMK,OAASF,MAAMC,IAAI,CAACJ,WAAW,kBACrC,MAAMM,aAAeC,iBACnBC,SAASC,eAAe,EACxBC,gBAAgB,CAAC,WAEnB,MAAMC,aAAe,IACnBC,OAAOC,UAAU,CACf,CAAC,mDAAmD,EAAEP,aAAa,CAAC,CAAC,EACrEQ,OAAO,CAEX,MAAMC,gBAAkB,AAACC,MAASA,KAAKC,OAAO,CAACC,OAA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AQD,OAAO,CAACU,KAAK,CAAG,KAC1B,CAEA,GAAIZ,gBAAgBG,SAAU,CAC5B,MAAMuB,YAAc1C,QAAQ,uBAAwB6B,OACpD,GAAI,CAACa,YAAa,OAClBA,YAAYC,KAAK,EACnB,KAAO,CACLxB,QAAQwB,KAAK,EACf,CACF,EAEA,OAAOxC,SACJyC,GAAG,CAAC,AAACzB,UACJ,MAAM0B,KAAO1B,QAAQ2B,UAAU,CAC/B,MAAMjB,MAAQpB,SAASa,aAAa,CAClC,CAAC,CAAC,EAAEH,QAAQqB,YAAY,CAAC,iBAAiB,CAAC,EAE7C,MAAMO,MAAQV,aAAalB,QAASU,OACpCV,QAAQ6B,gBAAgB,CAAC,QAASD,OAClC,IAAIE,WAAYC,WAEhB,GAAI,CAAClC,gBAAgBG,SAAU,CAC7B8B,WAAad,kBAAkBhB,QAASU,OACxCqB,WAAad,kBAAkBjB,QAASU,OAExCgB,KAAKG,gBAAgB,CAAC,aAAcC,YACpCJ,KAAKG,gBAAgB,CAAC,aAAcE,WACtC,CAEA,MAAO,CACL,CACEC,SAAU,KACR,GAAIF,YAAcC,WAAY,CAC5BL,KAAKO,mBAAmB,CAAC,aAAcH,YACvCJ,KAAKO,mBAAmB,CAAC,aAAcF,WACzC,CAEA/B,QAAQiC,mBAAmB,CAAC,QAASL,MACvC,EACAM,MAAO,KACLlC,QAAQe,YAAY,CAAC,gBAAiB,OACtCL,MAAMN,SAAS,CAACS,OAAO,CAAC,UAAW,YACrC,CACF,EACD,AACH,GACCsB,IAAI,EACT,CAEA,gBAAepD,cAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import scrollLock from"scroll-lock";import{queryId}from"../../dom-query";const MeganavControlMobileDropdown=({clearPanels})=>{const control=queryId("meganav-control-mobile-dropdown");const dropdown=queryId("meganav-mobile-dropdown");const menuIcon=queryId("meganav-control-mobile-dropdown-menu");const closeIcon=queryId("meganav-control-mobile-dropdown-close");const clickHandler=()=>{const ariaExpanded=control.getAttribute("aria-expanded");if(ariaExpanded==="false"){dropdown.classList.replace("invisible","visible");control.setAttribute("aria-expanded",true);scrollLock.disablePageScroll()}else{dropdown.classList.replace("visible","invisible");control.setAttribute("aria-expanded",false);scrollLock.enablePageScroll();clearPanels()}menuIcon.classList.toggle("hidden");closeIcon.classList.toggle("hidden")};control.addEventListener("click",clickHandler);return{teardown:()=>{control.removeEventListener("click",clickHandler);scrollLock.enablePageScroll()},clear:()=>{dropdown.classList.replace("visible","invisible");control.setAttribute("aria-expanded",false);menuIcon.classList.remove("hidden");closeIcon.classList.add("hidden");scrollLock.enablePageScroll()}}};export default MeganavControlMobileDropdown;
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/LegacyMeganav/MeganavControlMobileDropdown/component.js"],"sourcesContent":["import scrollLock from \"scroll-lock\";\n\nimport { queryId } from \"../../dom-query\";\n\nconst MeganavControlMobileDropdown = ({ clearPanels }) => {\n const control = queryId(\"meganav-control-mobile-dropdown\");\n const dropdown = queryId(\"meganav-mobile-dropdown\");\n const menuIcon = queryId(\"meganav-control-mobile-dropdown-menu\");\n const closeIcon = queryId(\"meganav-control-mobile-dropdown-close\");\n\n const clickHandler = () => {\n const ariaExpanded = control.getAttribute(\"aria-expanded\");\n\n if (ariaExpanded === \"false\") {\n dropdown.classList.replace(\"invisible\", \"visible\");\n control.setAttribute(\"aria-expanded\", true);\n scrollLock.disablePageScroll();\n } else {\n dropdown.classList.replace(\"visible\", \"invisible\");\n control.setAttribute(\"aria-expanded\", false);\n scrollLock.enablePageScroll();\n clearPanels();\n }\n\n menuIcon.classList.toggle(\"hidden\");\n closeIcon.classList.toggle(\"hidden\");\n };\n\n control.addEventListener(\"click\", clickHandler);\n\n return {\n teardown: () => {\n control.removeEventListener(\"click\", clickHandler);\n scrollLock.enablePageScroll();\n },\n clear: () => {\n dropdown.classList.replace(\"visible\", \"invisible\");\n control.setAttribute(\"aria-expanded\", false);\n menuIcon.classList.remove(\"hidden\");\n closeIcon.classList.add(\"hidden\");\n scrollLock.enablePageScroll();\n },\n };\n};\n\nexport default MeganavControlMobileDropdown;\n"],"names":["scrollLock","queryId","MeganavControlMobileDropdown","clearPanels","control","dropdown","menuIcon","closeIcon","clickHandler","ariaExpanded","getAttribute","classList","replace","setAttribute","disablePageScroll","enablePageScroll","toggle","addEventListener","teardown","removeEventListener","clear","remove","add"],"mappings":"AAAA,OAAOA,eAAgB,aAAc,AAErC,QAASC,OAAO,KAAQ,iBAAkB,CAE1C,MAAMC,6BAA+B,CAAC,CAAEC,WAAW,CAAE,IACnD,MAAMC,QAAUH,QAAQ,mCACxB,MAAMI,SAAWJ,QAAQ,2BACzB,MAAMK,SAAWL,QAAQ,wCACzB,MAAMM,UAAYN,QAAQ,yCAE1B,MAAMO,aAAe,KACnB,MAAMC,aAAeL,QAAQM,YAAY,CAAC,iBAE1C,GAAID,eAAiB,QAAS,CAC5BJ,SAASM,SAAS,CAACC,OAAO,CAAC,YAAa,WACxCR,QAAQS,YAAY,CAAC,gBAAiB,MACtCb,WAAWc,iBAAiB,EAC9B,KAAO,CACLT,SAASM,SAAS,CAACC,OAAO,CAAC,UAAW,aACtCR,QAAQS,YAAY,CAAC,gBAAiB,OACtCb,WAAWe,gBAAgB,GAC3BZ,aACF,CAEAG,SAASK,SAAS,CAACK,MAAM,CAAC,UAC1BT,UAAUI,SAAS,CAACK,MAAM,CAAC,SAC7B,EAEAZ,QAAQa,gBAAgB,CAAC,QAAST,cAElC,MAAO,CACLU,SAAU,KACRd,QAAQe,mBAAmB,CAAC,QAASX,cACrCR,WAAWe,gBAAgB,EAC7B,EACAK,MAAO,KACLf,SAASM,SAAS,CAACC,OAAO,CAAC,UAAW,aACtCR,QAAQS,YAAY,CAAC,gBAAiB,OACtCP,SAASK,SAAS,CAACU,MAAM,CAAC,UAC1Bd,UAAUI,SAAS,CAACW,GAAG,CAAC,UACxBtB,WAAWe,gBAAgB,EAC7B,CACF,CACF,CAEA,gBAAeb,4BAA6B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{queryIdAll}from"../../dom-query";export default(()=>{const closeControls=Array.from(queryIdAll("meganav-control-mobile-panel-close"));const openControls=Array.from(queryIdAll("meganav-control-mobile-panel-open"));const clickHandler=(btn,openBtn,panel)=>()=>{btn.setAttribute("aria-expanded",false);openBtn.setAttribute("aria-expanded",false);panel.classList.replace("block","hidden");panel.style.height=null};return closeControls.map(btn=>{const openBtn=openControls.find(open=>open.getAttribute("aria-controls")===btn.getAttribute("aria-controls"));const panel=document.querySelector(`#${btn.getAttribute("aria-controls")}`);const handler=clickHandler(btn,openBtn,panel);btn.addEventListener("click",handler);return{teardown:()=>btn.removeEventListener("click",handler),clear:()=>btn.setAttribute("aria-expanded",false)}})});
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/LegacyMeganav/MeganavControlMobilePanelClose/component.js"],"sourcesContent":["import { queryIdAll } from \"../../dom-query\";\n\nexport default () => {\n const closeControls = Array.from(\n queryIdAll(\"meganav-control-mobile-panel-close\"),\n );\n const openControls = Array.from(\n queryIdAll(\"meganav-control-mobile-panel-open\"),\n );\n\n const clickHandler = (btn, openBtn, panel) => () => {\n btn.setAttribute(\"aria-expanded\", false);\n openBtn.setAttribute(\"aria-expanded\", false);\n panel.classList.replace(\"block\", \"hidden\");\n panel.style.height = null;\n };\n\n return closeControls.map((btn) => {\n const openBtn = openControls.find(\n (open) =>\n open.getAttribute(\"aria-controls\") ===\n btn.getAttribute(\"aria-controls\"),\n );\n const panel = document.querySelector(\n `#${btn.getAttribute(\"aria-controls\")}`,\n );\n const handler = clickHandler(btn, openBtn, panel);\n\n btn.addEventListener(\"click\", handler);\n\n return {\n teardown: () => btn.removeEventListener(\"click\", handler),\n clear: () => btn.setAttribute(\"aria-expanded\", false),\n };\n });\n};\n"],"names":["queryIdAll","closeControls","Array","from","openControls","clickHandler","btn","openBtn","panel","setAttribute","classList","replace","style","height","map","find","open","getAttribute","document","querySelector","handler","addEventListener","teardown","removeEventListener","clear"],"mappings":"AAAA,OAASA,UAAU,KAAQ,iBAAkB,AAE7C,eAAe,CAAA,KACb,MAAMC,cAAgBC,MAAMC,IAAI,CAC9BH,WAAW,uCAEb,MAAMI,aAAeF,MAAMC,IAAI,CAC7BH,WAAW,sCAGb,MAAMK,aAAe,CAACC,IAAKC,QAASC,QAAU,KAC5CF,IAAIG,YAAY,CAAC,gBAAiB,OAClCF,QAAQE,YAAY,CAAC,gBAAiB,OACtCD,MAAME,SAAS,CAACC,OAAO,CAAC,QAAS,SACjCH,CAAAA,MAAMI,KAAK,CAACC,MAAM,CAAG,IACvB,EAEA,OAAOZ,cAAca,GAAG,CAAC,AAACR,MACxB,MAAMC,QAAUH,aAAaW,IAAI,CAC/B,AAACC,MACCA,KAAKC,YAAY,CAAC,mBAClBX,IAAIW,YAAY,CAAC,kBAErB,MAAMT,MAAQU,SAASC,aAAa,CAClC,CAAC,CAAC,EAAEb,IAAIW,YAAY,CAAC,iBAAiB,CAAC,EAEzC,MAAMG,QAAUf,aAAaC,IAAKC,QAASC,OAE3CF,IAAIe,gBAAgB,CAAC,QAASD,SAE9B,MAAO,CACLE,SAAU,IAAMhB,IAAIiB,mBAAmB,CAAC,QAASH,SACjDI,MAAO,IAAMlB,IAAIG,YAAY,CAAC,gBAAiB,MACjD,CACF,EACF,CAAA,CAAE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{queryId,queryIdAll}from"../../dom-query";import{remsToPixelValue}from"../../css";export default(()=>{const closeControls=Array.from(queryIdAll("meganav-control-mobile-panel-close"));const openControls=Array.from(queryIdAll("meganav-control-mobile-panel-open"));const dropdown=queryId("meganav-mobile-dropdown");const meganavHeight=remsToPixelValue(getComputedStyle(document.documentElement).getPropertyValue("--ui-meganav-height"));const clickHandler=(btn,closeBtn,panel)=>()=>{btn.setAttribute("aria-expanded",true);closeBtn.setAttribute("aria-expanded",true);panel.classList.replace("hidden","block");panel.style.height=`${window.innerHeight-meganavHeight>panel.offsetHeight?panel.offsetHeight:window.innerHeight-meganavHeight}px`};return openControls.map(btn=>{const closeBtn=closeControls.find(node=>node.getAttribute("aria-controls")===btn.getAttribute("aria-controls"));const panel=document.querySelector(`#${btn.getAttribute("aria-controls")}`);const handler=clickHandler(btn,closeBtn,panel);btn.addEventListener("click",handler);return{teardown:()=>btn.removeEventListener("click",handler),clear:()=>{panel.classList.replace("block","hidden");dropdown.classList.remove("ui-meganav-mobile-dropdown-expand");btn.setAttribute("aria-expanded",false);panel.style.height=null}}})});
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/LegacyMeganav/MeganavControlMobilePanelOpen/component.js"],"sourcesContent":["import { queryId, queryIdAll } from \"../../dom-query\";\nimport { remsToPixelValue } from \"../../css\";\n\nexport default () => {\n const closeControls = Array.from(\n queryIdAll(\"meganav-control-mobile-panel-close\"),\n );\n const openControls = Array.from(\n queryIdAll(\"meganav-control-mobile-panel-open\"),\n );\n const dropdown = queryId(\"meganav-mobile-dropdown\");\n\n // Height is defined in rem's so to get the pixel value we need to find the fontSize on root\n const meganavHeight = remsToPixelValue(\n getComputedStyle(document.documentElement).getPropertyValue(\n \"--ui-meganav-height\",\n ),\n );\n\n const clickHandler = (btn, closeBtn, panel) => () => {\n btn.setAttribute(\"aria-expanded\", true);\n closeBtn.setAttribute(\"aria-expanded\", true);\n panel.classList.replace(\"hidden\", \"block\");\n\n // On devices where we don't have enough space for the panel, set it's height to\n // the height of the viewport (minus the meganav height) - this will trigger a scroll.\n // Otherwise just set it to the panel height. This handles the case where the ratio of vertical\n // space to horizontal is especially high (think tablets, but not only).\n panel.style.height = `${\n window.innerHeight - meganavHeight > panel.offsetHeight\n ? panel.offsetHeight\n : window.innerHeight - meganavHeight\n }px`;\n };\n\n return openControls.map((btn) => {\n const closeBtn = closeControls.find(\n (node) =>\n node.getAttribute(\"aria-controls\") ===\n btn.getAttribute(\"aria-controls\"),\n );\n const panel = document.querySelector(\n `#${btn.getAttribute(\"aria-controls\")}`,\n );\n const handler = clickHandler(btn, closeBtn, panel);\n\n btn.addEventListener(\"click\", handler);\n\n return {\n teardown: () => btn.removeEventListener(\"click\", handler),\n clear: () => {\n panel.classList.replace(\"block\", \"hidden\");\n dropdown.classList.remove(\"ui-meganav-mobile-dropdown-expand\");\n btn.setAttribute(\"aria-expanded\", false);\n panel.style.height = null;\n },\n };\n });\n};\n"],"names":["queryId","queryIdAll","remsToPixelValue","closeControls","Array","from","openControls","dropdown","meganavHeight","getComputedStyle","document","documentElement","getPropertyValue","clickHandler","btn","closeBtn","panel","setAttribute","classList","replace","style","height","window","innerHeight","offsetHeight","map","find","node","getAttribute","querySelector","handler","addEventListener","teardown","removeEventListener","clear","remove"],"mappings":"AAAA,OAASA,OAAO,CAAEC,UAAU,KAAQ,iBAAkB,AACtD,QAASC,gBAAgB,KAAQ,WAAY,AAE7C,eAAe,CAAA,KACb,MAAMC,cAAgBC,MAAMC,IAAI,CAC9BJ,WAAW,uCAEb,MAAMK,aAAeF,MAAMC,IAAI,CAC7BJ,WAAW,sCAEb,MAAMM,SAAWP,QAAQ,2BAGzB,MAAMQ,cAAgBN,iBACpBO,iBAAiBC,SAASC,eAAe,EAAEC,gBAAgB,CACzD,wBAIJ,MAAMC,aAAe,CAACC,IAAKC,SAAUC,QAAU,KAC7CF,IAAIG,YAAY,CAAC,gBAAiB,MAClCF,SAASE,YAAY,CAAC,gBAAiB,MACvCD,MAAME,SAAS,CAACC,OAAO,CAAC,SAAU,QAMlCH,CAAAA,MAAMI,KAAK,CAACC,MAAM,CAAG,CAAC,EACpBC,OAAOC,WAAW,CAAGf,cAAgBQ,MAAMQ,YAAY,CACnDR,MAAMQ,YAAY,CAClBF,OAAOC,WAAW,CAAGf,cAC1B,EAAE,CAAC,AACN,EAEA,OAAOF,aAAamB,GAAG,CAAC,AAACX,MACvB,MAAMC,SAAWZ,cAAcuB,IAAI,CACjC,AAACC,MACCA,KAAKC,YAAY,CAAC,mBAClBd,IAAIc,YAAY,CAAC,kBAErB,MAAMZ,MAAQN,SAASmB,aAAa,CAClC,CAAC,CAAC,EAAEf,IAAIc,YAAY,CAAC,iBAAiB,CAAC,EAEzC,MAAME,QAAUjB,aAAaC,IAAKC,SAAUC,OAE5CF,IAAIiB,gBAAgB,CAAC,QAASD,SAE9B,MAAO,CACLE,SAAU,IAAMlB,IAAImB,mBAAmB,CAAC,QAASH,SACjDI,MAAO,KACLlB,MAAME,SAAS,CAACC,OAAO,CAAC,QAAS,UACjCZ,SAASW,SAAS,CAACiB,MAAM,CAAC,qCAC1BrB,IAAIG,YAAY,CAAC,gBAAiB,MAClCD,CAAAA,MAAMI,KAAK,CAACC,MAAM,CAAG,IACvB,CACF,CACF,EACF,CAAA,CAAE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{queryId}from"../../dom-query";import AddSearchClient from"addsearch-js-client";const init=({input,container,listContainer,clear,client})=>{client.setAnalyticsTag("Meganav autocomplete");client.setThrottleTime(400);const clearResults=()=>{container.classList.add("hidden");listContainer.innerHTML=""};const toggleClearBtn=query=>{if((query||"").length>0&&clear){clear.classList.remove("invisible")}else if(clear){clear.classList.add("invisible")}};const markQueryInSuggestion=(suggestionValue,query)=>{return suggestionValue.replace(query.toLowerCase(),`<span class="font-light">${query}</span>`)};const navigateToUrl=q=>window.location=`/search?q=${q}`;const focusNext=index=>{const nextSuggestion=listContainer.querySelector(`[data-suggestion-index="${index+1}"]`);if(!nextSuggestion)return;nextSuggestion.focus()};const focusPrevious=index=>{const previousIndex=index-1;const previousSuggestion=listContainer.querySelector(`[data-suggestion-index="${previousIndex}"]`);if(!previousSuggestion)return;previousSuggestion.focus()};const renderResults=query=>(results={})=>{toggleClearBtn(query);if(!Array.isArray(results.suggestions)){clearResults();return}if(results.suggestions.length===0){clearResults();return}const items=results.suggestions.map((suggestion,index)=>{const li=document.createElement("li");const button=document.createElement("button");button.type="button";button.classList.add("ui-text-menu2","font-medium","p-8","w-full","text-left","rounded","hover:text-gui-hover","focus:outline-gui-focus","hover:bg-light-grey");button.innerHTML=markQueryInSuggestion(suggestion.value,query);button.dataset.suggestionIndex=index;button.addEventListener("click",()=>{navigateToUrl(suggestion.value)});button.addEventListener("keydown",e=>{const key=e.key;if(key==="ArrowDown"){focusNext(index)}else if(key==="ArrowUp"&&index-1<0){input.focus()}else if(key==="ArrowUp"&&index-1>=0){focusPrevious(index)}else if(key==="Enter"||key==="Space"){navigateToUrl(suggestion.value)}});li.appendChild(button);return li});listContainer.innerHTML="";items.forEach(item=>listContainer.appendChild(item));container.classList.remove("hidden")};const keyupHandler=e=>{const query=e.target.value;const key=e.key;if(key==="ArrowDown"){focusNext(0);return}if(!query){clearResults()}else{client.suggestions(query,renderResults(query))}};let clearHandler;if(clear){clearHandler=()=>{input.value="";clear.classList.add("invisible");clearResults()};clear.addEventListener("click",clearHandler)}input.addEventListener("keyup",keyupHandler);return{teardown:()=>{input.removeEventListener("keyup",keyupHandler);if(clear)clear.removeEventListener("click",clearHandler)},clear:()=>{input.value="";clearResults()}}};export default(apiKey=>{if(!apiKey){console.log(`No AddSearch API key provided, skipping search suggestions.`);return[]}const client=new AddSearchClient(apiKey);return[queryId("meganav-search-input"),queryId("meganav-mobile-search-input")].filter(i=>i).map(input=>{const parent=input.parentNode;const container=queryId("meganav-search-autocomplete-container",parent);const listContainer=queryId("meganav-search-autocomplete-list",parent);const clear=queryId("meganav-search-input-clear",parent);return init({input,container,listContainer,client,clear})})});
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/LegacyMeganav/MeganavSearchAutocomplete/component.js"],"sourcesContent":["import { queryId } from \"../../dom-query\";\nimport AddSearchClient from \"addsearch-js-client\";\n\nconst init = ({ input, container, listContainer, clear, client }) => {\n client.setAnalyticsTag(\"Meganav autocomplete\");\n client.setThrottleTime(400);\n\n const clearResults = () => {\n container.classList.add(\"hidden\");\n listContainer.innerHTML = \"\";\n };\n\n const toggleClearBtn = (query) => {\n if ((query || \"\").length > 0 && clear) {\n clear.classList.remove(\"invisible\");\n } else if (clear) {\n clear.classList.add(\"invisible\");\n }\n };\n\n const markQueryInSuggestion = (suggestionValue, query) => {\n return suggestionValue.replace(\n query.toLowerCase(),\n `<span class=\"font-light\">${query}</span>`,\n );\n };\n\n const navigateToUrl = (q) => (window.location = `/search?q=${q}`);\n\n const focusNext = (index) => {\n const nextSuggestion = listContainer.querySelector(\n `[data-suggestion-index=\"${index + 1}\"]`,\n );\n if (!nextSuggestion) return;\n nextSuggestion.focus();\n };\n\n const focusPrevious = (index) => {\n const previousIndex = index - 1;\n\n const previousSuggestion = listContainer.querySelector(\n `[data-suggestion-index=\"${previousIndex}\"]`,\n );\n if (!previousSuggestion) return;\n previousSuggestion.focus();\n };\n\n const renderResults =\n (query) =>\n (results = {}) => {\n toggleClearBtn(query);\n\n // Prevent invalid access error when key is invalid\n if (!Array.isArray(results.suggestions)) {\n clearResults();\n return;\n }\n\n // Prevent key error from invalid key\n if (results.suggestions.length === 0) {\n clearResults();\n return;\n }\n\n const items = results.suggestions.map((suggestion, index) => {\n const li = document.createElement(\"li\");\n const button = document.createElement(\"button\");\n button.type = \"button\";\n\n button.classList.add(\n \"ui-text-menu2\",\n \"font-medium\",\n \"p-8\",\n \"w-full\",\n \"text-left\",\n \"rounded\",\n \"hover:text-gui-hover\",\n \"focus:outline-gui-focus\",\n \"hover:bg-light-grey\",\n );\n\n button.innerHTML = markQueryInSuggestion(suggestion.value, query);\n\n button.dataset.suggestionIndex = index;\n\n button.addEventListener(\"click\", () => {\n navigateToUrl(suggestion.value);\n });\n\n button.addEventListener(\"keydown\", (e) => {\n const key = e.key;\n\n if (key === \"ArrowDown\") {\n focusNext(index);\n } else if (key === \"ArrowUp\" && index - 1 < 0) {\n input.focus();\n } else if (key === \"ArrowUp\" && index - 1 >= 0) {\n focusPrevious(index);\n } else if (key === \"Enter\" || key === \"Space\") {\n navigateToUrl(suggestion.value);\n }\n });\n\n li.appendChild(button);\n return li;\n });\n\n listContainer.innerHTML = \"\";\n items.forEach((item) => listContainer.appendChild(item));\n container.classList.remove(\"hidden\");\n };\n\n const keyupHandler = (e) => {\n const query = e.target.value;\n const key = e.key;\n\n if (key === \"ArrowDown\") {\n focusNext(0);\n return;\n }\n\n if (!query) {\n clearResults();\n } else {\n client.suggestions(query, renderResults(query));\n }\n };\n\n let clearHandler;\n if (clear) {\n clearHandler = () => {\n input.value = \"\";\n clear.classList.add(\"invisible\");\n clearResults();\n };\n clear.addEventListener(\"click\", clearHandler);\n }\n\n input.addEventListener(\"keyup\", keyupHandler);\n\n return {\n teardown: () => {\n input.removeEventListener(\"keyup\", keyupHandler);\n if (clear) clear.removeEventListener(\"click\", clearHandler);\n },\n clear: () => {\n input.value = \"\";\n clearResults();\n },\n };\n};\n\nexport default (apiKey) => {\n if (!apiKey) {\n console.log(`No AddSearch API key provided, skipping search suggestions.`);\n return [];\n }\n\n const client = new AddSearchClient(apiKey);\n\n return [\n queryId(\"meganav-search-input\"),\n queryId(\"meganav-mobile-search-input\"),\n ]\n .filter((i) => i)\n .map((input) => {\n const parent = input.parentNode;\n const container = queryId(\n \"meganav-search-autocomplete-container\",\n parent,\n );\n const listContainer = queryId(\"meganav-search-autocomplete-list\", parent);\n const clear = queryId(\"meganav-search-input-clear\", parent);\n\n return init({ input, container, listContainer, client, clear });\n });\n};\n"],"names":["queryId","AddSearchClient","init","input","container","listContainer","clear","client","setAnalyticsTag","setThrottleTime","clearResults","classList","add","innerHTML","toggleClearBtn","query","length","remove","markQueryInSuggestion","suggestionValue","replace","toLowerCase","navigateToUrl","q","window","location","focusNext","index","nextSuggestion","querySelector","focus","focusPrevious","previousIndex","previousSuggestion","renderResults","results","Array","isArray","suggestions","items","map","suggestion","li","document","createElement","button","type","value","dataset","suggestionIndex","addEventListener","e","key","appendChild","forEach","item","keyupHandler","target","clearHandler","teardown","removeEventListener","apiKey","console","log","filter","i","parent","parentNode"],"mappings":"AAAA,OAASA,OAAO,KAAQ,iBAAkB,AAC1C,QAAOC,oBAAqB,qBAAsB,CAElD,MAAMC,KAAO,CAAC,CAAEC,KAAK,CAAEC,SAAS,CAAEC,aAAa,CAAEC,KAAK,CAAEC,MAAM,CAAE,IAC9DA,OAAOC,eAAe,CAAC,wBACvBD,OAAOE,eAAe,CAAC,KAEvB,MAAMC,aAAe,KACnBN,UAAUO,SAAS,CAACC,GAAG,CAAC,SACxBP,CAAAA,cAAcQ,SAAS,CAAG,EAC5B,EAEA,MAAMC,eAAiB,AAACC,QACtB,GAAI,AAACA,CAAAA,OAAS,EAAC,EAAGC,MAAM,CAAG,GAAKV,MAAO,CACrCA,MAAMK,SAAS,CAACM,MAAM,CAAC,YACzB,MAAO,GAAIX,MAAO,CAChBA,MAAMK,SAAS,CAACC,GAAG,CAAC,YACtB,CACF,EAEA,MAAMM,sBAAwB,CAACC,gBAAiBJ,SAC9C,OAAOI,gBAAgBC,OAAO,CAC5BL,MAAMM,WAAW,GACjB,CAAC,yBAAyB,EAAEN,MAAM,OAAO,CAAC,CAE9C,EAEA,MAAMO,cAAgB,AAACC,GAAOC,OAAOC,QAAQ,CAAG,CAAC,UAAU,EAAEF,EAAE,CAAC,CAEhE,MAAMG,UAAY,AAACC,QACjB,MAAMC,eAAiBvB,cAAcwB,aAAa,CAChD,CAAC,wBAAwB,EAAEF,MAAQ,EAAE,EAAE,CAAC,EAE1C,GAAI,CAACC,eAAgB,OACrBA,eAAeE,KAAK,EACtB,EAEA,MAAMC,cAAgB,AAACJ,QACrB,MAAMK,cAAgBL,MAAQ,EAE9B,MAAMM,mBAAqB5B,cAAcwB,aAAa,CACpD,CAAC,wBAAwB,EAAEG,cAAc,EAAE,CAAC,EAE9C,GAAI,CAACC,mBAAoB,OACzBA,mBAAmBH,KAAK,EAC1B,EAEA,M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ComputedStyle(node).transform).e;const updateTranslateX=(node,value)=>node.style.transform=`translateX(${value}px)`;const dragLeftBoundary=(translateX,threshold)=>translateX>=threshold;const dragRightBoundary=(translateX,itemsWidth,windowWidth,threshold)=>Math.abs(translateX-windowWidth+threshold)>itemsWidth;const getDistance=(e,touchStartX)=>e.changedTouches[0]?.clientX-touchStartX;const withinBuffer=distance=>Math.abs(distance)<DRAG_BUFFER;const getItemsTotalWidth=nodes=>nodes.map(item=>item.getBoundingClientRect().width).reduce((acc,val)=>acc+val,0);const MeganavSearchSuggestions=()=>{const suggestionsToggle=queryId("meganav-mobile-search-input");const suggestions=queryId("meganav-mobile-search-suggestions");const list=suggestions.querySelector("ul");const listItems=Array.from(list.querySelectorAll("li"));const dragLeft=(distance,threshold)=>{const currentTranslateX=getTranslateX(list);const translateX=Math.round(currentTranslateX+distance);if(dragLeftBoundary(translateX,threshold))return;updateTranslateX(list,translateX)};const dragLeftEnd=(distance,threshold)=>{const currentTranslateX=getTranslateX(list);let translateX=Math.round(currentTranslateX+distance);if(dragLeftBoundary(translateX,threshold)){translateX=0}updateTranslateX(list,translateX)};const dragRight=(distance,threshold)=>{const listWidth=list.getBoundingClientRect().width;const currentTranslateX=getTranslateX(list);const translateX=Math.round(currentTranslateX+distance);const itemsTotalWidth=getItemsTotalWidth(listItems);if(dragRightBoundary(translateX,itemsTotalWidth,listWidth,threshold)){return}updateTranslateX(list,translateX)};const dragRightEnd=(distance,threshold)=>{const listWidth=list.getBoundingClientRect().width;const currentTranslateX=getTranslateX(list);const itemsTotalWidth=getItemsTotalWidth(listItems);let translateX=Math.round(currentTranslateX+distance);if(dragRightBoundary(translateX,itemsTotalWidth,listWidth,threshold)){translateX=-(itemsTotalWidth-listWidth+threshold)}updateTranslateX(list,translateX)};let touchStartX;const touchstartHandler=e=>{touchStartX=e.touches[0]?.clientX};const touchmoveHandler=e=>{const distance=getDistance(e,touchStartX);if(withinBuffer(distance))return;distance>0?dragLeft(distance,24):dragRight(distance,96)};const touchendHandler=e=>{const distance=getDistance(e,touchStartX);if(withinBuffer(distance))return;distance>0?dragLeftEnd(distance,24):dragRightEnd(distance,48)};const focusSuggestionsHandler=()=>{suggestions.classList.add("max-h-96")};const blurSuggestionsHandler=e=>{if(e.relatedTarget===suggestions.querySelectorAll("a")[0]){return}suggestions.classList.remove("max-h-96")};const wheelHandler=e=>{const distance=e.deltaY*4;if(withinBuffer(distance))return;distance>0?dragLeftEnd(distance,24):dragRightEnd(distance,48)};suggestionsToggle?.addEventListener("focus",focusSuggestionsHandler);suggestionsToggle?.addEventListener("blur",blurSuggestionsHandler);suggestions.addEventListener("touchstart",touchstartHandler);suggestions.addEventListener("touchmove",touchmoveHandler);suggestions.addEventListener("touchend",touchendHandler);suggestions.addEventListener("wheel",wheelHandler);return{teardown:()=>{suggestionsToggle?.removeEventListener("focus",focusSuggestionsHandler);suggestionsToggle?.removeEventListener("blur",blurSuggestionsHandler);suggestions.removeEventListener("touchstart",touchstartHandler);suggestions.removeEventListener("touchmove",touchmoveHandler);suggestions.removeEventListener("touchend",touchendHandler)},clear:()=>{suggestions.classList.remove("max-h-96");list.style.transform=`translateX(0px)`}}};export default MeganavSearchSuggestions;
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/LegacyMeganav/MeganavSearchSuggestions/component.js"],"sourcesContent":["import { queryId } from \"../../dom-query\";\n\nconst DRAG_BUFFER = 5;\n\nconst getTranslateX = (node) =>\n new DOMMatrix(window.getComputedStyle(node).transform).e;\n\nconst updateTranslateX = (node, value) =>\n (node.style.transform = `translateX(${value}px)`);\n\nconst dragLeftBoundary = (translateX, threshold) => translateX >= threshold;\n\nconst dragRightBoundary = (translateX, itemsWidth, windowWidth, threshold) =>\n Math.abs(translateX - windowWidth + threshold) > itemsWidth;\n\nconst getDistance = (e, touchStartX) =>\n e.changedTouches[0]?.clientX - touchStartX;\n\nconst withinBuffer = (distance) => Math.abs(distance) < DRAG_BUFFER;\n\nconst getItemsTotalWidth = (nodes) =>\n nodes\n .map((item) => item.getBoundingClientRect().width)\n .reduce((acc, val) => acc + val, 0);\n\nconst MeganavSearchSuggestions = () => {\n const suggestionsToggle = queryId(\"meganav-mobile-search-input\");\n const suggestions = queryId(\"meganav-mobile-search-suggestions\");\n const list = suggestions.querySelector(\"ul\");\n const listItems = Array.from(list.querySelectorAll(\"li\"));\n\n const dragLeft = (distance, threshold) => {\n const currentTranslateX = getTranslateX(list);\n const translateX = Math.round(currentTranslateX + distance);\n if (dragLeftBoundary(translateX, threshold)) return;\n updateTranslateX(list, translateX);\n };\n\n const dragLeftEnd = (distance, threshold) => {\n const currentTranslateX = getTranslateX(list);\n let translateX = Math.round(currentTranslateX + distance);\n\n if (dragLeftBoundary(translateX, threshold)) {\n translateX = 0;\n }\n\n updateTranslateX(list, translateX);\n };\n\n const dragRight = (distance, threshold) => {\n const listWidth = list.getBoundingClientRect().width;\n const currentTranslateX = getTranslateX(list);\n const translateX = Math.round(currentTranslateX + distance);\n const itemsTotalWidth = getItemsTotalWidth(listItems);\n\n if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {\n return;\n }\n\n updateTranslateX(list, translateX);\n };\n\n const dragRightEnd = (distance, threshold) => {\n const listWidth = list.getBoundingClientRect().width;\n const currentTranslateX = getTranslateX(list);\n const itemsTotalWidth = getItemsTotalWidth(listItems);\n let translateX = Math.round(currentTranslateX + distance);\n\n if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {\n translateX = -(itemsTotalWidth - listWidth + threshold);\n }\n\n updateTranslateX(list, translateX);\n };\n\n let touchStartX;\n\n const touchstartHandler = (e) => {\n touchStartX = e.touches[0]?.clientX;\n };\n\n const touchmoveHandler = (e) => {\n const distance = getDistance(e, touchStartX);\n if (withinBuffer(distance)) return;\n distance > 0 ? dragLeft(distance, 24) : dragRight(distance, 96);\n };\n\n const touchendHandler = (e) => {\n const distance = getDistance(e, touchStartX);\n if (withinBuffer(distance)) return;\n distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);\n };\n\n const focusSuggestionsHandler = () => {\n suggestions.classList.add(\"max-h-96\");\n };\n\n const blurSuggestionsHandler = (e) => {\n if (e.relatedTarget === suggestions.querySelectorAll(\"a\")[0]) {\n return;\n }\n suggestions.classList.remove(\"max-h-96\");\n };\n\n const wheelHandler = (e) => {\n const distance = e.deltaY * 4;\n if (withinBuffer(distance)) return;\n distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);\n };\n\n suggestionsToggle?.addEventListener(\"focus\", focusSuggestionsHandler);\n suggestionsToggle?.addEventListener(\"blur\", blurSuggestionsHandler);\n suggestions.addEventListener(\"touchstart\", touchstartHandler);\n suggestions.addEventListener(\"touchmove\", touchmoveHandler);\n suggestions.addEventListener(\"touchend\", touchendHandler);\n suggestions.addEventListener(\"wheel\", wheelHandler);\n\n return {\n teardown: () => {\n suggestionsToggle?.removeEventListener(\"focus\", focusSuggestionsHandler);\n suggestionsToggle?.removeEventListener(\"blur\", blurSuggestionsHandler);\n suggestions.removeEventListener(\"touchstart\", touchstartHandler);\n suggestions.removeEventListener(\"touchmove\", touchmoveHandler);\n suggestions.removeEventListener(\"touchend\", touchendHandler);\n },\n clear: () => {\n suggestions.classList.remove(\"max-h-96\");\n list.style.transform = `translateX(0px)`;\n },\n };\n};\n\nexport default MeganavSearchSuggestions;\n"],"names":["queryId","DRAG_BUFFER","getTranslateX","node","DOMMatrix","window","getComputedStyle","transform","e","updateTranslateX","value","style","dragLeftBoundary","translateX","threshold","dragRightBoundary","itemsWidth","windowWidth","Math","abs","getDistance","touchStartX","changedTouches","clientX","withinBuffer","distance","getItemsTotalWidth","nodes","map","item","getBoundingClientRect","width","reduce","acc","val","MeganavSearchSuggestions","suggestionsToggle","suggestions","list","querySelector","listItems","Array","from","querySelectorAll","dragLeft","currentTranslateX","round","dragLeftEnd","dragRight","listWidth","itemsTotalWidth","dragRightEnd","touchstartHandler","touches","touchmoveHandler","touchendHandler","focusSuggestionsHandler","classList","add","blurSuggestionsHandler","relatedTarget","remove","wheelHandler","deltaY","addEventListener","teardown","removeEventListener","clear"],"mappings":"AAAA,OAASA,OAAO,KAAQ,iBAAkB,CAE1C,MAAMC,YAAc,EAEpB,MAAMC,cAAgB,AAACC,MACrB,IAAIC,UAAUC,OAAOC,gBAAgB,CAACH,MAAMI,SAAS,EAAEC,CAAC,CAE1D,MAAMC,iBAAmB,CAACN,KAAMO,QAC7BP,KAAKQ,KAAK,CAACJ,SAAS,CAAG,CAAC,WAAW,EAAEG,MAAM,GAAG,CAAC,CAElD,MAAME,iBAAmB,CAACC,WAAYC,YAAcD,YAAcC,UAElE,MAAMC,kBAAoB,CAACF,WAAYG,WAAYC,YAAaH,YAC9DI,KAAKC,GAAG,CAACN,WAAaI,YAAcH,WAAaE,WAEnD,MAAMI,YAAc,CAACZ,EAAGa,cACtBb,EAAEc,cAAc,CAAC,EAAE,EAAEC,QAAUF,YAEjC,MAAMG,aAAe,AAACC,UAAaP,KAAKC,GAAG,CAACM,UAAYxB,YAExD,MAAMyB,mBAAqB,AAACC,OAC1BA,MACGC,GAAG,CAAC,AAACC,MAASA,KAAKC,qBAAqB,GAAGC,KAAK,EAChDC,MAAM,CAAC,CAACC,IAAKC,MAAQD,IAAMC,IAAK,GAErC,MAAMC,yBAA2B,KAC/B,MAAMC,kBAAoBpC,QAAQ,+BAClC,MAAMqC,YAAcrC,QAAQ,qCAC5B,MAAMsC,KAAOD,YAAYE,aAAa,CAAC,MACvC,MAAMC,UAAYC,MAAMC,IAAI,CAACJ,KAAKK,gBAAgB,CAAC,OAEnD,MAAMC,SAAW,CAACnB,SAAUX,aAC1B,MAAM+B,kBAAoB3C,cAAcoC,MACxC,MAAMzB,WAAaK,KAAK4B,KAAK,CAACD,kBAAoBpB,UAClD,GAAIb,iBAAiBC,WAAYC,WAAY,OAC7CL,iBAAiB6B,KAAMzB,WACzB,EAEA,MAAMkC,YAAc,CAACt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,SAAW,EAAIsB,YAAYtB,SAAU,IAAM0B,aAAa1B,SAAU,GACpE,EAEA,MAAM+B,wBAA0B,KAC9BnB,YAAYoB,SAAS,CAACC,GAAG,CAAC,WAC5B,EAEA,MAAMC,uBAAyB,AAACnD,IAC9B,GAAIA,EAAEoD,aAAa,GAAKvB,YAAYM,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAE,CAC5D,MACF,CACAN,YAAYoB,SAAS,CAACI,MAAM,CAAC,WAC/B,EAEA,MAAMC,aAAe,AAACtD,IACpB,MAAMiB,SAAWjB,EAAEuD,MAAM,CAAG,EAC5B,GAAIvC,aAAaC,UAAW,MAC5BA,CAAAA,SAAW,EAAIsB,YAAYtB,SAAU,IAAM0B,aAAa1B,SAAU,GACpE,EAEAW,mBAAmB4B,iBAAiB,QAASR,yBAC7CpB,mBAAmB4B,iBAAiB,OAAQL,wBAC5CtB,YAAY2B,gBAAgB,CAAC,aAAcZ,mBAC3Cf,YAAY2B,gBAAgB,CAAC,YAAaV,kBAC1CjB,YAAY2B,gBAAgB,CAAC,WAAYT,iBACzClB,YAAY2B,gBAAgB,CAAC,QAASF,cAEtC,MAAO,CACLG,SAAU,KACR7B,mBAAmB8B,oBAAoB,QAASV,yBAChDpB,mBAAmB8B,oBAAoB,OAAQP,wBAC/CtB,YAAY6B,mBAAmB,CAAC,aAAcd,mBAC9Cf,YAAY6B,mBAAmB,CAAC,YAAaZ,kBAC7CjB,YAAY6B,mBAAmB,CAAC,WAAYX,gBAC9C,EACAY,MAAO,KACL9B,YAAYoB,SAAS,CAACI,MAAM,CAAC,WAC7BvB,CAAAA,KAAK3B,KAAK,CAACJ,SAAS,CAAG,CAAC,eAAe,CAAC,AAC1C,CACF,CACF,CAEA,gBAAe4B,wBAAyB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import throttle from"lodash.throttle";import{queryId,queryIdAll}from"../dom-query";import MeganavControl from"./MeganavControl/component.js";import MeganavControlMobileDropdown from"./MeganavControlMobileDropdown/component.js";import MobilePanelOpenClick from"./MeganavControlMobilePanelOpen/component.js";import MobilePanelCloseClick from"./MeganavControlMobilePanelClose/component.js";import MeganavSearchAutocomplete from"./MeganavSearchAutocomplete/component.js";import MeganavSearchSuggestions from"./MeganavSearchSuggestions/component.js";const windowOnBlur=closeAll=>{window.onblur=()=>closeAll();return{teardown:()=>window.onblur=null}};const documentClick=closeAll=>{const meganav=queryId("meganav");const clickHandler=e=>{if(meganav.contains(e.target))return;closeAll()};document.addEventListener("click",clickHandler);return{teardown:()=>document.removeEventListener("click",clickHandler)}};const documentScroll=themeName=>{if(themeName!=="transparentToWhite")return{teardown:()=>{}};const meganav=queryId("meganav");const navItems=queryIdAll("meganav-link");const controlMobileDropdownMenu=queryId("meganav-control-mobile-dropdown-menu");const controlMobileDropdownClose=queryId("meganav-control-mobile-dropdown-close");const controls=queryIdAll("meganav-control");const signUpBtn=queryId("meganav-sign-up-btn");const invertTextCollection=[...Array.from(controls),...Array.from(navItems),queryId("meganav-logo")];const invertMobleDropdownColor=invert=>{const whiteToBlack=["ui-icon-white","ui-icon-cool-black"];const blackToWhite=[...whiteToBlack].reverse();if(invert){controlMobileDropdownMenu?.classList.replace(...whiteToBlack);controlMobileDropdownClose?.classList.replace(...whiteToBlack)}else{controlMobileDropdownMenu?.classList.replace(...blackToWhite);controlMobileDropdownClose?.classList.replace(...blackToWhite)}};const inverSignupBtnColors=invert=>{if(invert){signUpBtn?.classList.replace("bg-white","bg-cool-black");signUpBtn?.classList.replace("text-cool-black","text-white")}else{signUpBtn?.classList.replace("bg-cool-black","bg-white");signUpBtn?.classList.replace("text-white","text-cool-black")}};const scrollHandler=throttle(()=>{if(window.scrollY>5){meganav.classList.replace("bg-transparent","bg-white");inverSignupBtnColors(true);invertMobleDropdownColor(true);invertTextCollection.forEach(n=>n.classList.replace("text-white","text-cool-black"))}else{meganav.classList.replace("bg-white","bg-transparent");inverSignupBtnColors(false);invertMobleDropdownColor(false);invertTextCollection.forEach(n=>n.classList.replace("text-cool-black","text-white"))}},150);document.addEventListener("scroll",scrollHandler);return{teardown:()=>document.removeEventListener("scroll",scrollHandler)}};export default function Meganav({themeName,addSearchApiKey}){const controls=MeganavControl();const panelOpenControls=MobilePanelOpenClick();const panelCloseControls=MobilePanelCloseClick();const search=MeganavSearchAutocomplete(addSearchApiKey);const searchSuggestions=MeganavSearchSuggestions();const mobileDropdownControl=MeganavControlMobileDropdown({clearPanels:()=>[...panelOpenControls,...panelCloseControls].forEach(i=>i.clear())});const closeAll=()=>[mobileDropdownControl,searchSuggestions,...panelOpenControls,...panelCloseControls,...controls,...search].forEach(i=>i.clear());const teardowns=[documentScroll(themeName??null),documentClick(closeAll),windowOnBlur(closeAll),mobileDropdownControl,searchSuggestions,...controls,...panelOpenControls,...panelCloseControls,...search].map(i=>i.teardown);return()=>teardowns.forEach(teardown=>teardown())}
|
|
2
|
+
//# sourceMappingURL=component.js.map
|