@attio/react-native-bottom-sheet-toolbox-dev-tools
Version:
1 lines • 13.6 kB
JavaScript
(()=>{"use strict";var e={626:function(e,t,s){var i=s(512),n=s(735),l=s(645);function r(e){let{className:t}=e;return(0,i.jsxs)("output",{className:t,children:[(0,i.jsxs)("svg",{"aria-hidden":"true",className:"w-8 h-8 text-tertiary animate-spin fill-blue-500",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),(0,i.jsx)("span",{className:"sr-only",children:"Loading..."})]})}function a(){return(0,i.jsxs)("svg",{className:"fill-white-100 h-[40px]",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 40",fill:"none",children:[(0,i.jsx)("title",{children:"Attio Logo"}),(0,i.jsx)("path",{d:"M81.774 6.104h-4.111v4.112h4.11V6.104Z"}),(0,i.jsx)("path",{fillRule:"evenodd",d:"M65.769 16.66h-3.61v6.681c0 .557.138.964.416 1.22.279.258.686.408 1.22.45.535.021 1.2.012 1.993-.031v3.758c-2.805.321-4.807.063-6.006-.77-1.178-.856-1.766-2.398-1.766-4.625v-6.68h-2.794v-3.985h2.794V9.434l4.143-1.252v4.498h6.404V9.436l4.143-1.252v4.498h3.629v3.984h-3.63v6.68c0 .558.139.965.417 1.22.279.259.686.408 1.22.451.535.02 1.2.012 1.99-.032v3.759c-2.804.32-4.805.063-6.005-.77-1.177-.856-1.766-2.398-1.766-4.625v-6.681h-2.794l.002-.008Z",clipRule:"evenodd"}),(0,i.jsx)("path",{d:"M81.793 12.674H77.65v16.062h4.143V12.674Z"}),(0,i.jsx)("path",{fillRule:"evenodd",d:"M91.553 12.257a8.448 8.448 0 0 0-8.446 8.449 8.448 8.448 0 1 0 16.893 0 8.446 8.446 0 0 0-8.447-8.449Zm-.014 12.915a4.482 4.482 0 0 1 0-8.962 4.48 4.48 0 0 1 4.479 4.48 4.48 4.48 0 0 1-4.48 4.482ZM49.791 12.642v.892a8.448 8.448 0 0 0-12.909 7.172 8.448 8.448 0 0 0 12.91 7.172v.891h4.11V12.642h-4.11Zm-4.477 12.53a4.482 4.482 0 0 1 0-8.962 4.462 4.462 0 0 1 4.477 4.406v.148a4.478 4.478 0 0 1-4.477 4.406v.002Z",clipRule:"evenodd"}),(0,i.jsx)("path",{d:"m29.754 22.362-2.512-4.02s-.009-.017-.015-.024l-.198-.316a2.03 2.03 0 0 0-1.726-.96l-4.046-.014-.282.453-4.835 7.736-.267.428L17.9 28.88c.374.602 1.02.961 1.732.961h5.67c.699 0 1.36-.368 1.73-.959l.2-.32s.008-.008.01-.012l2.515-4.025a2.045 2.045 0 0 0 0-2.164h-.002Zm-.766 1.683-2.516 4.025c-.01.02-.024.034-.035.05a.34.34 0 0 1-.544-.05l-2.515-4.027a1.116 1.116 0 0 1-.13-.29 1.127 1.127 0 0 1 .127-.908l2.512-4.02.006-.01c.06-.09.135-.131.2-.144.026-.008.049-.01.067-.013h.028c.058 0 .202.018.292.164l2.511 4.02c.23.366.23.837 0 1.203h-.003ZM22.322 12.636a2.053 2.053 0 0 0 0-2.164l-2.512-4.02-.21-.338a2.031 2.031 0 0 0-1.732-.959h-5.67c-.707 0-1.354.36-1.731.96L.314 22.366a2.03 2.03 0 0 0-.002 2.162l2.723 4.359a2.026 2.026 0 0 0 1.73.959h5.67c.712 0 1.358-.36 1.732-.96l.208-.33v-.004l.003-.007 2.024-3.237 5.999-9.6 1.917-3.07.004-.001Zm-.593-1.082c0 .207-.058.416-.175.601l-9.946 15.918a.34.34 0 0 1-.291.16.342.342 0 0 1-.292-.16l-2.513-4.027a1.141 1.141 0 0 1 0-1.202l9.945-15.913a.339.339 0 0 1 .292-.163c.058 0 .202.017.293.164l2.512 4.02c.117.185.175.394.175.602Z"})]})}function o(e){let{children:t}=e;return(0,i.jsxs)("div",{className:"w-svh h-svh grid grid-rows-[max-content_1fr]",children:[(0,i.jsxs)("header",{className:"grid grid-cols-[1fr_auto_1fr] bg-development py-[4px] font-display items-center px-[32px]",children:[(0,i.jsx)("div",{className:"flex",children:(0,i.jsx)("a",{href:"https://attio.com",target:"__blank",children:(0,i.jsx)(a,{})})}),(0,i.jsx)("h1",{className:"text-white-100 text-center font-display font-semibold text-xl",children:"React Native Bottom Sheet Toolbox Dev Tools"}),(0,i.jsxs)("div",{className:"flex justify-end gap-[16px]",children:[(0,i.jsx)("a",{className:"font-body text-white-100",href:"https://github.com/attio/react-native-bottom-sheet-toolbox",target:"__blank",children:"GitHub"}),(0,i.jsx)("a",{className:"font-body text-white-100",href:"https://improved-adventure-37r2k1k.pages.github.io/",target:"__blank",children:"Documentation"})]})]}),(0,i.jsx)("main",{className:"bg-primary font-body",children:t})]})}var h=s(803),c=s(331),d=s(565),u=s(633);class p{async setup(){if(!this._isSettingUp){this._isSettingUp=!0,this._setClient({state:"pending"});try{let e=await (0,u.yo)(this._pluginName);this._setClient({state:"complete",value:e})}catch(e){this._setClient({state:"error",error:`Failed to setup client. ${e}`})}this._isSettingUp=!1}}async teardown(){if(this._isTearingDown)return;this._isTearingDown=!0;let e=this._client;this._setClient({state:"error",error:"Client disconnected"});try{switch(e.state){case"complete":await e.value.closeAsync();break;case"pending":{let e=new Promise(e=>{let t=async()=>{"complete"===this._client.state?(await this.teardown(),e()):this.listenToEventEmitterEvent("client-change",t,!0)};this.listenToEventEmitterEvent("client-change",t,!0)});await e}}}catch(e){this._setClient({state:"error",error:`Failed to teardown client: ${e}`})}this._isTearingDown=!1}sendToClient(e,t){let s=this.getClientState();if("complete"!==s.state)throw Error("Cannot send message to client as it is not connected.");s.value.sendMessage(e,t)}listenToEventEmitterEvent(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return s?this._eventEmitter.once(e,t):this._eventEmitter.on(e,t),()=>{this._eventEmitter.removeListener(e,t)}}listenToClientEvent(e,t){let s=e=>{t(e)},i=this.getClientState();if("complete"===i.state){let t=i.value.addMessageListener(e,s);return()=>{t.remove()}}{let t=!1,i=null,n=this.listenToEventEmitterEvent("client-change",()=>{let n=this.getClientState();if("complete"===n.state){if(t)return;i=n.value.addMessageListener(e,s)}});return()=>{t=!0,null==i||i.remove(),n()}}}emit(e){this._eventEmitter.emit(e)}_setClient(e){this._client=e,this.emit("client-change")}constructor(){(0,c._)(this,"_client",{state:"pending"}),(0,c._)(this,"_eventEmitter",new d.Z),(0,c._)(this,"_pluginName","react-native-bottom-sheet-toolbox"),(0,c._)(this,"_isSettingUp",!1),(0,c._)(this,"_isTearingDown",!1),(0,c._)(this,"listenToClientState",this.listenToEventEmitterEvent.bind(this,"client-change")),(0,c._)(this,"getClientState",()=>this._client)}}let v=new class extends p{async setup(){this._isSettingUp||(this._attachClientListeners(),this.listenToClientState(()=>{"complete"===this.getClientState().state&&this.sendToClient("did-connect")}),await super.setup())}listenToSheet(e,t){if(!this._sheetData.has(e))throw Error(`Cannot listen to sheet "${e}" as it does not yet exist.`);return this.listenToEventEmitterEvent(`sheet-updated:${e}`,t)}sendToClient(e,t){super.sendToClient(e,t)}listenToClientEvent(e,t){return super.listenToClientEvent(e,t)}_attachClientListeners(){this._attachUpsertSheetListener(),this._attachDeleteSheetListener(),this._attachDeviceConfigListener()}_attachUpsertSheetListener(){this.listenToClientEvent("upsert-sheet",e=>{let{sheetId:t,...s}=e,i=!this._sheetData.has(t);this._sheetData.set(t,s),i?this._updateSheetIds():this.emit(`sheet-updated:${t}`)})}_attachDeleteSheetListener(){this.listenToClientEvent("delete-sheet",e=>{let{sheetId:t}=e;this._sheetData.delete(t)&&this._updateSheetIds()})}_attachDeviceConfigListener(){this.listenToClientEvent("update-device-config",e=>{let{width:t,height:s,theme:i}=e;this._deviceConfig={width:t,height:s,theme:i},this.emit("device-config-updated")})}_updateSheetIds(){this._sheetIds=Array.from(this._sheetData.keys()),this.emit("sheet-ids-updated")}constructor(...e){super(...e),(0,c._)(this,"_sheetIds",[]),(0,c._)(this,"_sheetData",new Map),(0,c._)(this,"_deviceConfig",{width:0,height:0,theme:"light"}),(0,c._)(this,"listenToSheetIds",this.listenToEventEmitterEvent.bind(this,"sheet-ids-updated")),(0,c._)(this,"getSheetIds",()=>this._sheetIds),(0,c._)(this,"getSheet",e=>this._sheetData.get(e)),(0,c._)(this,"listenToDeviceConfig",this.listenToEventEmitterEvent.bind(this,"device-config-updated")),(0,c._)(this,"getDeviceConfig",()=>this._deviceConfig)}};function m(){return n.useSyncExternalStore(v.listenToDeviceConfig,v.getDeviceConfig)}var f=s(393);function g(e){let{currentPosition:t,wrapperHeight:s,isReady:n}=e;return(0,i.jsx)("div",{className:(0,f.W)("w-full h-full",n?"bg-success":"bg-danger"),style:{transform:`translateY(${100-t/s*100}%)`}})}function x(e){let{snapPoint:t,wrapperHeight:s}=e,n="0.25em",l=t===s?"0px":0===t?`(${n} * -1)`:`(calc(${n} / 2)*-1)`;return(0,i.jsx)("div",{className:"w-full bg-blue-500 absolute top-0",style:{height:n,top:`calc(${100-t/s*100}% + ${l})`}})}function _(e){let{snapPoints:t,wrapperHeight:s}=e;return(0,i.jsx)("div",{className:"absolute w-full h-full top-0",children:(0,i.jsx)("div",{className:"relative w-full h-full",children:t.map((e,t)=>{let n=`${e}-${t}`;return(0,i.jsx)(x,{snapPoint:e,wrapperHeight:s},n)})})})}let w=n.memo(function(e){let{sheetId:t}=e,s=function(e){let t=n.useCallback(t=>v.listenToSheet(e,t),[e]),s=n.useCallback(()=>v.getSheet(e),[e]);return n.useSyncExternalStore(t,s)}(t),l=m(),a=(0,h.Z)(),o=(a.height??0)*(l.width/l.height);return(0,i.jsx)("div",{ref:a.ref,className:"h-full rounded-3xl overflow-hidden",style:{width:o},children:(0,i.jsxs)("div",{className:"bg-surface w-full h-full overflow-y-hidden relative",children:[(null==s?void 0:s.wrapperHeight)?(0,i.jsx)(g,{currentPosition:s.currentPosition,wrapperHeight:s.wrapperHeight,isReady:s.isReady}):(0,i.jsx)("div",{className:"w-full h-full bg-warning flex items-center justify-center",children:(0,i.jsx)(r,{})}),s&&null!==s.snapPoints&&null!==s.wrapperHeight&&(0,i.jsx)(_,{snapPoints:s.snapPoints,wrapperHeight:s.wrapperHeight})]})})});function j(){let e=n.useSyncExternalStore(v.listenToSheetIds,v.getSheetIds),t=m();return n.useEffect(()=>{let e=document.documentElement.classList.contains("dark");return document.documentElement.classList.toggle("dark","dark"===t.theme),()=>{document.documentElement.classList.toggle("dark",e)}},[t.theme]),(0,i.jsx)(o,{children:(0,i.jsx)("div",{className:"w-full h-full px-[32px] py-[32px]",children:e.map(e=>(0,i.jsx)(w,{sheetId:e},e))})})}let C=document.getElementById("root");if(!C)throw Error("Root element not found");l.createRoot(C).render((0,i.jsx)(n.StrictMode,{children:(0,i.jsx)(function(){let e=n.useSyncExternalStore(v.listenToClientState,v.getClientState);switch(n.useEffect(()=>(v.setup(),()=>{v.teardown()}),[]),e.state){case"pending":return(0,i.jsx)(o,{children:(0,i.jsx)("div",{className:"flex justify-center items-center w-full h-full",children:(0,i.jsxs)("article",{className:"flex flex-col justify-center items-center w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700 px-6 py-6 gap-3",children:[(0,i.jsx)(r,{className:""}),(0,i.jsx)("h1",{className:"font-display text-lg",children:"Loading"}),(0,i.jsxs)("section",{className:"flex flex-col gap-4",children:[(0,i.jsx)("p",{children:"Waiting to connect with the React Native Bottom Sheet Toolbox Dev Tools running on your device."}),(0,i.jsxs)("p",{children:["Be sure to include"," ",(0,i.jsx)("span",{className:"text-development break-all",children:"useReactNativeBottomSheetToolboxDevTools()"})," ","in your app?"]})]})]})})});case"error":return(0,i.jsx)(o,{children:(0,i.jsx)("div",{className:"flex justify-center items-center w-full h-full",children:(0,i.jsxs)("article",{className:"flex flex-col justify-center items-center w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700 px-6 py-6 gap-3",children:[(0,i.jsx)("h1",{className:"font-display text-lg",children:"Unable to Setup DevTools Client"}),(0,i.jsx)("section",{className:"flex flex-col gap-4",children:(0,i.jsxs)("p",{children:["Reason:"," ",(0,i.jsx)("span",{className:"break-all",children:e.error})]})})]})})});case"complete":return(0,i.jsx)(j,{})}},{})}))}},t={};function s(i){var n=t[i];if(void 0!==n)return n.exports;var l=t[i]={exports:{}};return e[i](l,l.exports,s),l.exports}s.m=e,s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e=[];s.O=(t,i,n,l)=>{if(i){l=l||0;for(var r=e.length;r>0&&e[r-1][2]>l;r--)e[r]=e[r-1];e[r]=[i,n,l];return}for(var a=1/0,r=0;r<e.length;r++){for(var[i,n,l]=e[r],o=!0,h=0;h<i.length;h++)(!1&l||a>=l)&&Object.keys(s.O).every(e=>s.O[e](i[h]))?i.splice(h--,1):(o=!1,l<a&&(a=l));if(o){e.splice(r--,1);var c=n();void 0!==c&&(t=c)}}return t}})(),s.rv=()=>"1.3.10",(()=>{var e={980:0};s.O.j=t=>0===e[t];var t=(t,i)=>{var n,l,[r,a,o]=i,h=0;if(r.some(t=>0!==e[t])){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);if(o)var c=o(s)}for(t&&t(i);h<r.length;h++)l=r[h],s.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return s.O(c)},i=self.webpackChunkweb_ui=self.webpackChunkweb_ui||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})(),s.ruid="bundler=rspack@1.3.10";var i=s.O(void 0,["361","688"],function(){return s(626)});i=s.O(i)})();