@fynd-design-engineering/fynd-one-v2 3.3.33 → 3.3.35
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/dist/accordians/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[fynd-faq-element="wrapper"]').forEach(
|
|
1
|
+
"use strict";(()=>{document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[fynd-faq-element="wrapper"]').forEach(e=>{let t=e.querySelector('[fynd-faq-element="toggle"]'),n=e.querySelector('[fynd-faq-element="content"]'),i=e.querySelector('[fynd-faq-element="content-inner"]'),l=t?.querySelector('[fynd-faq-element="x-line"]')||null,s=t?.querySelector('[fynd-faq-element="y-line"]')||null;if(!t||!n||!i||!l||!s){console.warn("Required FAQ elements not found in wrapper");return}let u=e.closest("[fynd-faq-group]"),r=u?.getAttribute("fynd-faq-group")||null,c=u?.getAttribute("fynd-faq-type")||"one-at-a-time";e.getAttribute("fynd-faq-initialopen")==="true"?(gsap.set(n,{height:"auto",overflow:"hidden"}),gsap.set(i,{opacity:1}),gsap.set(l,{rotation:180}),gsap.set(s,{rotation:270}),t.setAttribute("data-state","open"),q(e,r),p(e,r),E(e,r),h(e,r)):(gsap.set(n,{height:0}),gsap.set(i,{opacity:0}),gsap.set(l,{rotation:0}),gsap.set(s,{rotation:0}),t.setAttribute("data-state","closed"));let a=!1;t.addEventListener("click",()=>{if(a)return;a=!0;let f=t.getAttribute("data-state")==="open";if(c==="one-at-a-time"&&u){let d=u.querySelectorAll('[fynd-faq-element="wrapper"] [data-state="open"]');if(f&&d.length===1){a=!1;return}}f?g(e,()=>{a=!1}):(c==="one-at-a-time"&&u&&T(u),L(e,r,()=>{a=!1}))})}),y(),A(),setTimeout(H,500)});window.addEventListener("resize",()=>{y()});function y(){if(window.innerWidth<992)return;document.querySelectorAll("[fynd-faq-image-target]").forEach(t=>{let n=t.parentElement;!n||n.getAttribute("ratio-height")!=="true"||(n.style.height="auto",requestAnimationFrame(()=>{let l=n.offsetHeight;n.style.height=`${l}px`}))}),document.querySelectorAll('[fynd-faq-tabgroup][ratio-height="true"]').forEach(t=>{t.style.height="auto",requestAnimationFrame(()=>{let n=t.offsetHeight;t.style.height=`${n}px`})})}function L(o,e,t){let n=o.querySelector('[fynd-faq-element="toggle"]'),i=o.querySelector('[fynd-faq-element="content"]'),l=o.querySelector('[fynd-faq-element="content-inner"]'),s=n?.querySelector('[fynd-faq-element="x-line"]')||null,u=n?.querySelector('[fynd-faq-element="y-line"]')||null;if(!n||!i||!l||!s||!u){console.warn("Required elements not found for opening accordion");return}i.gsapAnimation&&i.gsapAnimation.kill();let r=gsap.timeline({onComplete:()=>t&&t()});gsap.set(i,{height:"auto",visibility:"hidden",opacity:0});let c=i.offsetHeight;gsap.set(i,{height:0,visibility:"visible",opacity:1}),r.to(s,{rotation:180,duration:.4,ease:"power2.inOut"},0),r.to(u,{rotation:270,duration:.4,ease:"power2.inOut"},0),r.to(i,{height:c,duration:.5,ease:"power3.inOut",clearProps:"height",onComplete:()=>{i.style.height="auto"}},0),r.to(l,{opacity:1,duration:.4,ease:"power2.out"},"-=0.35"),i.gsapAnimation=r,n.setAttribute("data-state","open"),window.innerWidth<992&&setTimeout(()=>{b(o)},600);let a=n.querySelector('[fynd-faq-element="chevron"]');a&&gsap.to(a,{rotation:180,duration:.4,ease:"back.out(1.7)"}),q(o,e),p(o,e),E(o,e),h(o,e)}function g(o,e){let t=o.querySelector('[fynd-faq-element="toggle"]'),n=o.querySelector('[fynd-faq-element="content"]'),i=o.querySelector('[fynd-faq-element="content-inner"]'),l=t?.querySelector('[fynd-faq-element="x-line"]')||null,s=t?.querySelector('[fynd-faq-element="y-line"]')||null;if(!t||!n||!i||!l||!s){console.warn("Required elements not found for closing accordion");return}n.gsapAnimation&&n.gsapAnimation.kill();let u=n.offsetHeight;n.style.height=`${u}px`;let r=gsap.timeline({onComplete:()=>e&&e()});r.to(l,{rotation:0,duration:.4,ease:"power2.inOut"},0),r.to(s,{rotation:0,duration:.4,ease:"power2.inOut"},0),r.to(i,{opacity:0,duration:.3,ease:"power2.in"},0),r.to(n,{height:0,duration:.4,ease:"power3.inOut"},"-=0.25"),n.gsapAnimation=r,t.setAttribute("data-state","closed");let c=t.querySelector('[fynd-faq-element="chevron"]');c&&gsap.to(c,{rotation:0,duration:.4,ease:"back.out(1.7)"})}function T(o){o.querySelectorAll('[fynd-faq-element="wrapper"] [data-state="open"]').forEach(t=>{let n=t.closest('[fynd-faq-element="wrapper"]');n&&g(n)})}function q(o,e){if(!e)return;let t=document.querySelector(`[fynd-faq-image-target="${e}"]`);if(!t)return;let n=o.querySelector("[fynd-faq-image-source]");if(!n)return;let i=n.getAttribute("src"),l=n.getAttribute("srcset");i&&t.setAttribute("src",i),l&&t.setAttribute("srcset","")}function p(o,e){if(!e)return;let t=document.querySelector(`[fynd-faq-text-target="${e}"]`);if(!t)return;let n=o.querySelector("[fynd-faq-text-source]");n&&(t.textContent=n.textContent)}function E(o,e){if(!e)return;let t=document.querySelector(`[fynd-faq-button-text-target="${e}"]`),n=document.querySelector(`[fynd-faq-button-link-target="${e}"]`),i=o.querySelector("[fynd-faq-link-source]");if(i&&(t&&(t.textContent=i.textContent),n))for(let l=0;l<i.attributes.length;l++){let s=i.attributes[l];n.setAttribute(s.name,s.value)}}function h(o,e){if(!e)return;let t=document.querySelector(`[fynd-faq-video-target="${e}"]`);if(!t)return;let n=o.querySelector("[fynd-faq-video]"),i=o.querySelector("[fynd-faq-image]"),l=o.querySelector("[fynd-faq-video-source]"),s=window.innerWidth<992,u=l?.querySelector("source")||null,r=(u?.getAttribute("src")||"").trim(),c=(u?.getAttribute("type")||"video/mp4").trim(),a=!!l&&!!u&&r!=="";if(s&&(n&&(n.style.display=a?"block":"none"),i&&(i.style.display=a?"none":"block")),!a){t.style.display="none";let d=t.querySelector("source");if(d){d.removeAttribute("src"),d.removeAttribute("type");try{t.load()}catch{}}return}let f=t.querySelector("source");f||(f=document.createElement("source"),t.appendChild(f)),f.setAttribute("src",r),f.setAttribute("type",c),t.setAttribute("loop",""),t.setAttribute("autoplay",""),t.setAttribute("muted",""),t.setAttribute("playsinline",""),s&&l&&(l.setAttribute("loop",""),l.setAttribute("autoplay",""),l.setAttribute("muted",""),l.setAttribute("playsinline",""),m(l));try{t.load()}catch{}m(t),t.style.display="block"}function m(o){!o.isConnected||o.style.display==="none"||requestAnimationFrame(()=>{let e=o.play();e&&typeof e.catch=="function"&&e.catch(()=>{})})}function A(){let o=document.querySelectorAll("[fynd-faq-video-target]");if(!o.length)return;let e=new IntersectionObserver(t=>{t.forEach(n=>{let i=n.target;if(!(!i.querySelector("source[src]")||i.style.display==="none"))if(n.isIntersecting&&n.intersectionRatio>=.5)i.setAttribute("autoplay",""),i.setAttribute("muted",""),i.setAttribute("playsinline",""),i.setAttribute("loop",""),m(i);else try{i.pause()}catch{}})},{threshold:[0,.5,1]});o.forEach(t=>e.observe(t))}async function H(){let o=document.querySelectorAll("video[fynd-faq-video-target], video.fynd-faq-video-target, video[data-fynd-faq-video-target], video[fynd-faq-video-source]");for(let e of o)if(e.src||e.querySelector("source[src]")){e.setAttribute("muted",""),e.setAttribute("playsinline",""),e.setAttribute("autoplay",""),e.setAttribute("loop",""),e.preload="auto",e.muted=!0;try{await e.play()}catch{}}}function b(o){if(!o)return;let e=o.querySelector('[fynd-faq-element="scroll-trigger"]');if(!e){console.warn('No element with [fynd-faq-element="scroll-trigger"] found inside the wrapper:',o);return}e.scrollIntoView({behavior:"smooth"})}})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{async function b(){try{let e=await fetch("https://ipwho.is/");if(!e.ok)throw new Error("Failed to fetch geolocation");let n=await e.json();return n.success===!1?(console.error("Geolocation lookup failed:",n.message),null):{ip:n.ip,country:n.country,region:n.region,city:n.city,latitude:n.latitude,longitude:n.longitude,isp:n.connection?.isp||"",timezone:n.timezone?.id||""}}catch(e){return console.error("Error fetching geolocation:",e),null}}var w="geo:data:v1",f="geo_country",m=7*24*60*60*1e3;function C(e,n,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(n)}; Max-Age=${t}; Path=/; SameSite=Lax; Secure`}function v(e){let n=`${encodeURIComponent(e)}=`,t=document.cookie.split("; ");for(let o of t)if(o.startsWith(n))return decodeURIComponent(o.slice(n.length));return null}function N(e){try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);return!t?.expiresAt||Date.now()>t.expiresAt?(localStorage.removeItem(e),null):t.data}catch{return localStorage.removeItem(e),null}}function $(e,n,t){let o={data:n,expiresAt:Date.now()+t};try{localStorage.setItem(e,JSON.stringify(o))}catch{}}async function p(e){if(typeof window>"u")return null;if(!(e?.forceRefresh??!1)){let o=N(w);if(o)return window.__GEO=o,v(f)||C(f,o.country??"",Math.floor(m/1e3)),o}let t=await b();return t
|
|
1
|
+
"use strict";(()=>{async function b(){try{let e=await fetch("https://ipwho.is/");if(!e.ok)throw new Error("Failed to fetch geolocation");let n=await e.json();return n.success===!1?(console.error("Geolocation lookup failed:",n.message),null):{ip:n.ip,country:n.country,region:n.region,city:n.city,latitude:n.latitude,longitude:n.longitude,isp:n.connection?.isp||"",timezone:n.timezone?.id||""}}catch(e){return console.error("Error fetching geolocation:",e),null}}var w="geo:data:v1",f="geo_country",m=7*24*60*60*1e3;function C(e,n,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(n)}; Max-Age=${t}; Path=/; SameSite=Lax; Secure`}function v(e){let n=`${encodeURIComponent(e)}=`,t=document.cookie.split("; ");for(let o of t)if(o.startsWith(n))return decodeURIComponent(o.slice(n.length));return null}function N(e){try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);return!t?.expiresAt||Date.now()>t.expiresAt?(localStorage.removeItem(e),null):t.data}catch{return localStorage.removeItem(e),null}}function $(e,n,t){let o={data:n,expiresAt:Date.now()+t};try{localStorage.setItem(e,JSON.stringify(o))}catch{}}async function p(e){if(typeof window>"u")return null;if(!(e?.forceRefresh??!1)){let o=N(w);if(o)return window.__GEO=o,v(f)||C(f,o.country??"",Math.floor(m/1e3)),o}let t=null;try{t=await b()}catch(o){console.warn("getGeolocation() failed; defaulting to India:",o)}return t||(t={country:"India"}),$(w,t,m),C(f,t.country??"",Math.floor(m/1e3)),window.__GEO=t,t}function x(){return v(f)}function S(e,n,t="auto"){let r=(window||{}).gsap;if(!r){console.warn("GSAP not found on window. Did you include it globally?");return}let i=document.querySelector(e),u=document.querySelector(n);if(!i||!u){console.warn("openBanner: Element(s) not found for selectors:",{mainSelector:e,innerSelector:n});return}r.set(i,{height:0,overflow:"hidden"}),r.set(u,{opacity:0});let s=r.timeline();return s.to(i,{height:t,duration:.5,ease:"power2.out"}),s.to(u,{opacity:1,duration:.3,ease:"power1.out"},.2),s}function E(e,n,t=0){let r=(window||{}).gsap;if(!r){console.warn("GSAP not found on window. Did you include it globally?");return}let i=document.querySelector(e),u=document.querySelector(n);if(!i||!u){console.warn("closeBanner: Element(s) not found for selectors:",{mainSelector:e,innerSelector:n});return}r.set(i,{overflow:"hidden"});let s=r.timeline();return s.to(u,{opacity:0,duration:.25,ease:"power1.out"}),s.to(i,{height:t,duration:.45,ease:"power2.inOut"},.2),s}function T(e,n,t){let o=new Date;o.setTime(o.getTime()+t*60*60*1e3),document.cookie=`${e}=${n}; expires=${o.toUTCString()}; path=/`}function k(e){let n=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return n?n[2]:null}function h(){let e=window.innerWidth;return e>=992?"desktop":e>=768?"tablet":e>=480?"mobileLandscape":"mobilePortrait"}var l=[{country:"united arab emirates",aliases:["uae","u.a.e","united arab emirates"],countryCode:"ae",url:"/ae",tagline:"You're in the UAE. Welcome!"},{country:"saudi arabia",aliases:["saudi","ksa","kingdom of saudi arabia"],countryCode:"sa",url:"/sa",tagline:"Hello Saudi Arabia!"},{country:"south africa",aliases:["rsa"],countryCode:"za",url:"/za",tagline:"Hi South Africa!"},{country:"malaysia",countryCode:"my",url:"/my",tagline:"Selamat datang, Malaysia!"},{country:"indonesia",aliases:["idn"],countryCode:"id",url:"/id",tagline:"Halo Indonesia!"},{country:"philippines",aliases:["phl","the philippines"],countryCode:"ph",url:"/ph",tagline:"Kumusta, Philippines!"},{country:"india",aliases:["bharat"],countryCode:"in",url:"/in",tagline:"This country is India. Hi some text"},{country:"global",aliases:["global","rest of world","others"],countryCode:"global",url:"/global",tagline:"This is rest of world. Hi some text"}];function c(e){return(e??"").trim().toLowerCase()}function L(e){let n=e.trim();return n?n.startsWith("/")?n:`/${n}`:"/"}async function R(){if(typeof window>"u")return null;let e=x();if(e)return c(e);let n=await p();return c(n?.country)}function G(e){let n=c(e);if(!n)return null;let t=l.find(i=>c(i.countryCode)===n);if(t)return t;let o=l.find(i=>c(i.country)===n);if(o)return o;let r=l.find(i=>(i.aliases??[]).some(u=>c(u)===n));return r||null}function y(){let e=l.find(n=>n.country==="global");if(!e)throw new Error("[geo-banner] Global config not found in COUNTRY_CONFIG");return e}function q(e){if(typeof window>"u")return;let n=c(e),t=l.find(r=>c(r.countryCode)===n)||y(),o=document.querySelector('[fynd-banner-field="link"]');if(o){let r=window.location.origin;o.href=`${r}${L(t.url)}`}}function F(e,n){let t=G(n)??l.find(s=>s.country==="global");if(!t)return console.warn("[geo-banner] No matching config for",n),!1;let o=t.countryCode,r=Array.from(e.options),i=r.find(s=>c(s.value)===c(o));if(!i)return console.warn("[geo-banner] No matching <option> for",o,"on",e),!1;let u=e.value;return e.value=i.value,e.value!==i.value&&(e.selectedIndex=r.indexOf(i)),r.forEach(s=>s.selected=s===i),u!==e.value&&(e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))),console.log("[geo-banner] Select updated \u2192",t.country,"(",t.countryCode,")"),!0}function U(e){if(typeof window>"u")return;let n=c(e),t=l.find(i=>c(i.countryCode)===n)||y(),o=document.querySelector("#geoswitch-select")||document.querySelector('[fynd-banner-field="geoswitch"]');o?(console.log(`country code is ${t.countryCode}`),F(o,t.countryCode),o.value=t.countryCode,o.dispatchEvent(new Event("change",{bubbles:!0}))):console.warn('[geo-banner] Select not found: #geoswitch-select / [fynd-banner-field="geoswitch"]');let r=document.querySelector('[fynd-banner-field="link"]');if(r){let i=window.location.origin;r.href=`${i}${L(t.url)}`}}async function I(){if(typeof window>"u")return y();document.readyState==="loading"&&await new Promise(r=>{document.addEventListener("DOMContentLoaded",()=>r(),{once:!0})});let e=await R(),t=G(e)??y();console.log("[geo-banner] rawCountry:",e,"\u2192 resolved:",t.countryCode),U(t.countryCode);let o=document.querySelector('[fynd-banner-field="geoswitch"]');return o&&!o.__geoHandlerAttached&&(o.addEventListener("change",r=>{let i=r.target.value;q(i)}),o.__geoHandlerAttached=!0),t}var _={"/global":{mode:"country",countries:["India"]},"/":{mode:"notCountry",countries:["India"]}},M='[fynd-navigation="ip-banner"]',D='[fynd-navigation="ip-banner-inner"]',Y='[fynd-navigation="ip-banner-close"]',d=document.querySelector('[fynd-navigation="announcement-bar"]'),H=document.querySelector('[fynd-navigation="announcement-list"]'),a={ipbanner:{visibility:!1,height:{desktop:"56px",tablet:"60px",mobileLandscape:"120px",mobilePortrait:"120px"}},announcementbar:{visibility:!0,height:{desktop:"40px",tablet:"40px",mobileLandscape:"40px",mobilePortrait:"46px"}},default:{visibility:!0,height:{desktop:"70px",tablet:"64px",mobileLandscape:"40px",mobilePortrait:"64px"}}};window.navigationData=a;function g(e,n){let t=o=>{if(typeof o=="number")return o;let r=parseInt(o,10);return isNaN(r)?0:r};return`${t(e)+t(n)}px`}function P(e,n){let t=o=>{if(typeof o=="number")return o;let r=parseInt(o,10);return isNaN(r)?0:r};return`${t(e)-t(n)}px`}var O=e=>{try{let n=e.split("?")[0].split("#")[0];return n==="/"?"/":n.replace(/\/+$/,"")||"/"}catch{return"/"}};function z(e){let n=O(e),t="";for(let o of Object.keys(_)){let r=O(o);(n===r||n.startsWith(r+"/"))&&r.length>t.length&&(t=r)}return t?{key:t,rule:_[t]}:null}function K(e,n){let t=z(e);if(!t)return!1;let{rule:o}=t,r=(n?.country||"").toLowerCase();switch(o.mode){case"always":return!0;case"country":return o.countries.some(i=>i.toLowerCase()===r);case"notCountry":return!o.countries.some(i=>i.toLowerCase()===r);case"predicate":return!!o.test?.(n);default:return!1}}function W(){let e=document.querySelector('[fynd-navigation="announcement-swiper"]');if(e&&!e.__swiperInstance)try{let n=window.Swiper,t=new n(e,{slidesPerView:1,spaceBetween:0,effect:"fade",fadeEffect:{crossFade:!0},autoplay:{delay:3e3,disableOnInteraction:!1},loop:!0,speed:1e3,allowTouchMove:!1,on:{init:function(){this.slides.length<=1&&this.autoplay&&typeof this.autoplay.stop=="function"&&this.autoplay.stop()}}});e.__swiperInstance=t}catch(n){console.warn("Announcement Swiper init failed:",n)}d&&H&&H.children.length>0?a.announcementbar.visibility=!0:(a.announcementbar.visibility=!1,d&&d.parentNode&&(e&&e.__swiperInstance&&(e.__swiperInstance.destroy(!0,!0),e.__swiperInstance=void 0),d.parentNode.removeChild(d)))}function A(){let e='[fynd-navigation="dropdown-container"]',n=document.querySelector(e);if(!n){console.warn(`initDesktopDropdownMenu: element not found: ${e}`);return}let t=h?.()??"unknown";if(t!=="desktop"){n.style.transition=n.style.transition||"transform 0.3s ease",n.style.transform="translateY(0px)";return}let o=a.default.height?.[t],r=!1;if(a.announcementbar?.visibility){let i=a.announcementbar.height?.[t];o=g(o,i),o=P(o,"46px"),r=!0}a.ipbanner?.visibility&&(o=g(o,"0px"),r||(o=P(o,"46px"))),n.style.transform=`translateY(${o})`}function B(){let e=document.querySelector('[fynd-navigation="spacer"][data-wf--navigation-spacer--variant="dynamic"]');if(!e){console.warn("initNavigationSpacer: spacer element not found");return}let n=r=>{if(typeof r=="number")return r;if(typeof r=="string"){let i=parseFloat(r);return Number.isFinite(i)?i:0}return 0},t=h?.()??"desktop",o=a.default.height?.[t];if(a.announcementbar?.visibility){let r=a.announcementbar.height?.[t];o=g(o,r)}if(a.ipbanner?.visibility){let r=n(a.ipbanner.height?.[t]);o=g(o,r)}e.style.height=`${o}`}async function j(){if(k("ipBannerClosed")==="true"){a.ipbanner.visibility=!1;return}let n=await p(),t=window.location.pathname||"/",o=K(t,n??void 0),r=await I();if(o&&r){S(M,D,a.ipbanner.height.desktop),a.ipbanner.visibility=!0;let i=document.querySelector(Y);i&&i.addEventListener("click",()=>{E(M,D),T("ipBannerClosed","true",24),a.ipbanner.visibility=!1,A(),B()})}else a.ipbanner.visibility=!1}document.addEventListener("DOMContentLoaded",async()=>{await j(),W(),A(),B()});})();
|
package/package.json
CHANGED