@joy-ride/game 0.25.0 → 0.25.1
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/README.md +3 -0
- package/embed-chunks/{CodeBlock-SbsdRltK.js → CodeBlock-DMi-BeLY.js} +1 -1
- package/embed-chunks/{Documentation-it27YLKx.js → Documentation-CI9JoAsv.js} +2 -2
- package/embed-chunks/{EmbedPanel-yRsx9glF.js → EmbedPanel-CgEZTMF7.js} +1 -1
- package/embed-chunks/{JoyRideView-o-2qdJkr.js → JoyRideView-C3AYwIPH.js} +1 -1
- package/embed-chunks/{src-BJXg-amK.js → src-v4km-Xn-.js} +2 -2
- package/embed-chunks/{vehicle-popover-CtdtJ1cl.js → vehicle-popover-CBTIiR6Q.js} +1 -1
- package/embed.js +1 -1
- package/{index-sebzwsKw.d.ts → index-BqJy85Tu.d.ts} +12 -8
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/npm-chunks/{Documentation-B6U46upd.js → Documentation-D5RIEQza.js} +2 -2
- package/npm-chunks/{EmbedPanel-dnDwQhT5.js → EmbedPanel-COgcEIgT.js} +1 -1
- package/npm-chunks/{vehicle-popover-D0e1ZKfF.js → vehicle-popover-CbBEYEjM.js} +1 -1
- package/package.json +1 -1
- package/react.d.ts +5 -3
- package/react.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./configuration~index~embed~bookmarklet~vehicle-popover~EmbedPanel~Documentation~JoyRideView~~n76yhyet-zf1LIsS8.js";import{f as n,m as r,p as i,u as a}from"./configuration~index~embed~bookmarklet-C8RUCiUX.js";import{i as o,t as s}from"./react-vendor~index~embed-BNCMh3YF.js";import{N as c,S as l,a as u,c as d,h as f,l as p,m,o as h,u as g,x as _,y as v}from"./X.es-d7B7rOGv.js";import{t as y}from"./CodeBlock-SbsdRltK.js";import{C as b,D as x,E as S,_ as C,a as w,b as T,c as E,g as D,h as O,i as k,l as A,m as j,n as M,o as ee,p as N,r as P,s as F,t as I,v as te,w as L,x as R,y as z}from"./vehicle-popover-CtdtJ1cl.js";var B=e(o(),1),V=B.createContext(void 0);function H(){let e=B.useContext(V);if(e===void 0)throw Error(v(10));return e}var U=s(),W={value:()=>null},ne=B.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,hiddenUntilFound:a,keepMounted:o,loopFocus:s,onValueChange:c,multiple:u=!1,orientation:f=`vertical`,value:p,defaultValue:m,style:h,..._}=e,v=m??g,y=B.useRef([]),[b,x]=A({controlled:p,default:v,name:`Accordion`,state:`value`}),S=l((e,t,n)=>{let r;r=u?t?[...b,e]:b.filter(t=>t!==e):b[0]===e?[]:[e],c?.(r,n),!n.isCanceled&&x(r)}),C=B.useMemo(()=>({value:b,disabled:i,orientation:f}),[b,i,f]),w=B.useMemo(()=>({disabled:i,handleValueChange:S,hiddenUntilFound:a??!1,keepMounted:o??!1,state:C,value:b}),[i,S,a,o,C,b]),T=d(`div`,e,{state:C,ref:t,props:_,stateAttributesMapping:W});return(0,U.jsx)(V.Provider,{value:w,children:(0,U.jsx)(E,{elementsRef:y,children:T})})});function re(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=A({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:u}=D(a,!0,!0),d=L(),[f,p]=B.useState(),m=f===null?void 0:f??d,h=l(e=>{let t=!a,n=O(j,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return B.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:m,setMounted:c,setOpen:o,setPanelIdState:p,transitionStatus:u}),[d,i,h,s,a,m,c,o,p,u])}var ie=B.createContext(void 0);function G(){let e=B.useContext(ie);if(e===void 0)throw Error(v(15));return e}var K=B.createContext(void 0);function q(){let e=B.useContext(K);if(e===void 0)throw Error(v(9));return e}var ae=`data-open`,oe=`data-closed`,J=b,se=`data-panel-open`,ce={[ae]:``},le={[oe]:``},ue={open(e){return e?{[se]:``}:null}},de={open(e){return e?ce:le}},fe=`data-index`,Y={...de,index:e=>({[fe]:String(e)}),...R,value:()=>null},pe=B.forwardRef(function(e,t){let{className:n,disabled:r=!1,onOpenChange:i,render:a,value:o,style:s,...c}=e,{ref:u,index:f}=F(),{disabled:p,handleValueChange:m,state:h,value:g}=H(),_=L(),v=o??_,y=r||p,b=g.includes(v),x=l((e,t)=>{i?.(e,t),!t.isCanceled&&m(v,e,t)}),S=re({open:b,onOpenChange:x,disabled:y}),C=B.useMemo(()=>({...S,onOpenChange:x,state:{open:S.open,disabled:S.disabled,transitionStatus:S.transitionStatus}}),[S,x]),w=B.useMemo(()=>({...h,hidden:!b&&!S.mounted,index:f,disabled:y,open:b}),[S.mounted,y,f,b,h]),T=L(),[E,D]=B.useState(),O=E===null?void 0:E??T,k=B.useMemo(()=>({defaultTriggerId:T,open:b,state:w,setTriggerId:D,triggerId:O}),[T,b,w,D,O]),A=d(`div`,e,{state:w,ref:[t,u],props:c,stateAttributesMapping:Y});return(0,U.jsx)(ie.Provider,{value:C,children:(0,U.jsx)(K.Provider,{value:k,children:A})})}),me=B.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{state:o}=q();return d(`h3`,e,{state:o,ref:t,props:a,stateAttributesMapping:Y})}),he={...Y,...ue},ge=B.forwardRef(function(e,t){let{disabled:n,className:r,id:i,render:a,nativeButton:o=!0,style:s,...c}=e,{panelId:l,open:u,handleTrigger:p,disabled:m}=G(),{getButtonProps:h,buttonRef:g}=f({disabled:n||m,native:o}),{defaultTriggerId:v,state:y,setTriggerId:b}=q(),x=i||void 0,S=x??v;return _(()=>(b(e=>x??(e===null?void 0:e)),()=>{b(e=>e===x?null:e)}),[x,b]),d(`button`,e,{state:y,ref:[t,g],props:[{"aria-controls":u?l:void 0,"aria-expanded":u,id:S,onClick:p},c,h],stateAttributesMapping:he})}),X={height:void 0,width:void 0};function _e(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:u,transitionStatus:d}=e,f=B.useRef(null),p=B.useRef(null),[h,g]=B.useState(X),v=B.useRef(X),y=B.useRef(!1),b=B.useRef(s),x=B.useRef(!1),[S,E]=B.useState(!1),D=B.useRef(null),k=m(t,f),A=w(s),j=te(f),M=!s&&!a,P=S?`idle`:d,F=s&&(b.current||x.current),I=!s&&a&&p.current===`css-animation`&&h.height===void 0&&h.width===void 0?v.current:h,L=n&&M&&p.current!==`css-animation`,R=l((e,t=!0)=>{t&&(v.current=e),g(e)}),V=l(()=>{D.current?.(),D.current=null}),H=l(e=>{V(),D.current=()=>{D.current=null,e()}}),U=l(()=>{s&&a&&p.current===`css-animation`&&(x.current=!0)});_(()=>{S&&d!==`starting`&&E(!1)},[S,d]),B.useEffect(()=>()=>{U(),V()},[U,V]),_(()=>{s||(b.current=!1,x.current=!1);let e=f.current;if(!e)return;!s&&D.current&&V();let t=ve(e,F);if(p.current=t,s&&d===`idle`&&b.current&&t===`css-animation`){v.current=Z(e);return}if(s&&d===`starting`){let n=y.current;if(y.current=!1,t===`none`){R(Z(e)),E(!0);return}if(t===`css-transition`){let t=be(e);if(R(Z(e)),!n)return t;let r=Q(e,`transition-duration`,`0s`);return H(r),E(!0),t}R(Z(e));let r=Q(e,`animation-name`,`none`);if(!n){r();return}let i=Q(e,`animation-duration`,`0s`);r(),H(i),E(!0);return}if(!s&&a&&(d===`idle`||d===`starting`)){if(t===`none`){R(X,!1),c(!1);return}R(Z(e));return}if(d!==`ending`)return;if(t===`none`){c(!1);return}let n=Z(e);n.height>0||n.width>0?(R(n),t===`css-animation`&&Q(e,`animation-name`,`none`)()):c(!1)},[a,s,V,R,c,H,F,d]),C({enabled:s&&a&&P===`idle`,open:!0,ref:f,onComplete(){s&&R(X,!1)}}),B.useEffect(()=>{if(s||!a||P!==`ending`)return;if(!f.current){c(!1),R(X,!1);return}let e=new AbortController,t=-1;function n(){A.current||(c(!1),R(X,!1))}return t=z.request(()=>{j(n,e.signal)}),()=>{z.cancel(t),e.abort()}},[A,a,s,P,j,R,c]),_(()=>{let e=f.current;e&&n&&M&&e.setAttribute(`hidden`,`until-found`)},[M,n]),B.useEffect(function(){let e=f.current;if(!e)return;let t=T.create(),n=-1,r=(r,i)=>{t.start(0,()=>{A.current||(n=z.request(()=>{A.current||(r&&(y.current=!1),i&&e.setAttribute(J,``),e.setAttribute(`hidden`,`until-found`))}))})},i=ee(e,`beforematch`,t=>{let n=O(N,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}y.current=!0;let i=e.hasAttribute(J);e.removeAttribute(J),u(!0),r(!0,i)});return()=>{t.clear(),z.cancel(n),i()}},[A,o,u]);let W=i||n||a||s;return{height:I.height,props:{...L?{[J]:``}:void 0,hidden:M,id:r},ref:k,shouldPreventOpenAnimation:F,shouldRender:W,transitionStatus:P,width:I.width}}function Z(e){return{height:e.scrollHeight,width:e.scrollWidth}}function ve(e,t){let n=c(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&ye(n.animationDuration),i=ye(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function ye(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Q(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{r===``?e.style.removeProperty(t):e.style.setProperty(t,r,i)}}function be(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{n===``?e.style.removeProperty(t):e.style.setProperty(t,n)})}let r=z.request(n);return()=>{z.cancel(r),n()}}var xe=`--accordion-panel-height`,Se=`--accordion-panel-width`,Ce=B.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,id:a,render:o,style:s,...c}=e,{hiddenUntilFound:l,keepMounted:u}=H(),{defaultPanelId:f,mounted:m,onOpenChange:h,open:g,setMounted:v,setOpen:y,setPanelIdState:b,transitionStatus:x}=G(),S=r??l,C=i??u,w=a||void 0,T=a??f;_(()=>(b(e=>w??(e===null?void 0:e)),()=>{b(e=>e===w?null:e)}),[w,b]);let{height:E,props:D,ref:O,shouldPreventOpenAnimation:k,shouldRender:A,transitionStatus:j,width:M}=_e({externalRef:t,hiddenUntilFound:S,id:T,keepMounted:C,mounted:m,onOpenChange:h,open:g,setMounted:v,setOpen:y,transitionStatus:x}),{state:ee,triggerId:N}=q(),P={...ee,transitionStatus:j},F=p(s,P),I=d(`div`,{...e,style:void 0},{state:P,ref:O,props:[D,{"aria-labelledby":N,role:`region`,style:{[xe]:E===void 0?`auto`:`${E}px`,[Se]:M===void 0?`auto`:`${M}px`}},c,F?{style:F}:void 0,k?{style:{animationName:`none`}}:void 0],stateAttributesMapping:Y});return A?I:null});function we({className:e,...t}){return(0,U.jsx)(ne,{"data-slot":`accordion`,className:h(`flex w-full flex-col`,e),...t})}function Te({className:e,...t}){return(0,U.jsx)(pe,{"data-slot":`accordion-item`,className:h(`not-last:border-b`,e),...t})}function Ee({className:e,children:t,...n}){return(0,U.jsx)(me,{className:`flex`,children:(0,U.jsxs)(ge,{"data-slot":`accordion-trigger`,className:h(`group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground`,e),...n,children:[t,(0,U.jsx)(x,{"aria-hidden":`true`,"data-slot":`accordion-trigger-icon`,className:`pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden`}),(0,U.jsx)(S,{"aria-hidden":`true`,"data-slot":`accordion-trigger-icon`,className:`pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline`})]})})}function De({className:e,children:t,...n}){return(0,U.jsx)(Ce,{"data-slot":`accordion-content`,className:`overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up`,...n,children:(0,U.jsx)(`div`,{className:h(`h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),children:t})})}function Oe({className:e,size:t=`default`,...n}){return(0,U.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:h(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function ke({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-header`,className:h(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function Ae({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-title`,className:h(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function je({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-description`,className:h(`text-sm text-muted-foreground`,e),...t})}function Me({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-action`,className:h(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}var $={game:{title:`Game`,description:`Visuals, sound, performance, tools, and rules`},dialog:{title:`Dialog`,description:`Appearance, visible tabs, and visitor settings access`}};function Ne({value:e,onChange:o}){let[s,c]=(0,B.useState)(),l=n(r(a,e)),d=(t,n,r)=>o({...e,[t]:{...e[t],[n]:r}});return(0,U.jsxs)(`section`,{"aria-label":`Embed options`,className:`space-y-3 py-2 text-xs`,ref:e=>{let t=e?.getRootNode();t instanceof ShadowRoot&&t!==s&&c(t)},children:[(0,U.jsx)(Oe,{size:`sm`,className:`gap-0 bg-muted/30`,children:(0,U.jsxs)(ke,{className:`grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3`,children:[(0,U.jsx)(Ae,{children:`Configure your embed`}),(0,U.jsx)(je,{children:`Choose the experience and what visitors can change.`}),(0,U.jsx)(Me,{children:(0,U.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>{let t={...e};for(let e of Object.keys(i))Object.assign(t,{[e]:{...t[e],...i[e]}});o(t)},children:`Use SFW defaults`})})]})}),(0,U.jsx)(we,{defaultValue:[],className:`gap-2`,children:Object.keys($).map(e=>(0,U.jsxs)(Te,{value:e,className:`rounded-lg border bg-card/40 px-3`,children:[(0,U.jsx)(Ee,{className:`py-3 hover:no-underline`,children:(0,U.jsxs)(`span`,{className:`grid gap-1`,children:[(0,U.jsx)(`span`,{children:$[e].title}),(0,U.jsx)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:$[e].description})]})}),(0,U.jsx)(De,{children:(0,U.jsx)(`div`,{className:`divide-y border-t`,children:t.filter(t=>t.category===e).map(e=>{let t=`embed-${e.category}-${e.key}`,n=l[e.category][e.key],r=[`hint`,`tabs`].includes(e.control);return(0,U.jsxs)(`div`,{className:r?`grid gap-3 py-3`:`flex items-center justify-between gap-4 py-3`,children:[(0,U.jsxs)(`label`,{htmlFor:t,className:`grid min-w-0 gap-1 font-medium`,children:[(0,U.jsx)(`span`,{children:e.label}),e.help&&(0,U.jsx)(`span`,{className:`max-w-72 font-normal text-muted-foreground`,children:e.help})]}),(0,U.jsx)(k,{id:t,entry:e,value:n,container:s,onChange:t=>d(e.category,e.key,t)})]},e.key)})})})]},e))})]})}function Pe({embed:e}){let[t,n]=(0,B.useState)(`html`),r={html:{code:e.html,language:`html`,title:`HTML embed`},async:{code:e.async,language:`javascript`,title:`CDN`},npm:{code:e.npm,language:`javascript`,title:`JavaScript`},react:{code:e.react??``,language:`tsx`,title:`React`},bookmarklet:{code:e.bookmarklet,language:`javascript`,title:`Bookmarklet URL`}}[t];return(0,U.jsxs)(`section`,{className:`min-h-full px-3 py-2.5 text-sm`,children:[e.error?(0,U.jsx)(`p`,{role:`alert`,children:e.error}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I,{value:t,onValueChange:e=>n(e),className:`my-2.5 gap-0`,children:(0,U.jsxs)(M,{className:`w-full`,"aria-label":`Embed format`,children:[(0,U.jsx)(P,{value:`html`,className:`text-sm`,children:`HTML`}),(0,U.jsx)(P,{value:`async`,className:`text-sm`,children:`CDN`}),(0,U.jsx)(P,{value:`npm`,className:`text-sm`,children:`JavaScript`}),(0,U.jsx)(P,{value:`react`,className:`text-sm`,disabled:!e.react,children:`React`}),(0,U.jsx)(P,{value:`bookmarklet`,className:`text-sm`,children:`Bookmarklet`})]})}),(t===`npm`||t===`react`)&&(0,U.jsx)(`div`,{className:`mb-3`,children:(0,U.jsx)(y,{code:`npm install @joy-ride/game`,language:`shell`,title:`Install the package`,compact:!0})}),(0,U.jsx)(y,{code:r.code,language:r.language,title:r.title,compact:!0,maxHeight:210,wrap:t===`html`||t===`bookmarklet`})]}),e.configuration&&e.onConfigure&&(0,U.jsx)(Ne,{value:e.configuration,onChange:e.onConfigure})]})}export{Pe as EmbedPanel};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./configuration~index~embed~bookmarklet~vehicle-popover~EmbedPanel~Documentation~JoyRideView~~n76yhyet-zf1LIsS8.js";import{f as n,m as r,p as i,u as a}from"./configuration~index~embed~bookmarklet-C8RUCiUX.js";import{i as o,t as s}from"./react-vendor~index~embed-BNCMh3YF.js";import{N as c,S as l,a as u,c as d,h as f,l as p,m,o as h,u as g,x as _,y as v}from"./X.es-d7B7rOGv.js";import{t as y}from"./CodeBlock-DMi-BeLY.js";import{C as b,D as x,E as S,_ as C,a as w,b as T,c as E,g as D,h as O,i as k,l as A,m as j,n as M,o as ee,p as N,r as P,s as F,t as I,v as te,w as L,x as R,y as z}from"./vehicle-popover-CBTIiR6Q.js";var B=e(o(),1),V=B.createContext(void 0);function H(){let e=B.useContext(V);if(e===void 0)throw Error(v(10));return e}var U=s(),W={value:()=>null},ne=B.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,hiddenUntilFound:a,keepMounted:o,loopFocus:s,onValueChange:c,multiple:u=!1,orientation:f=`vertical`,value:p,defaultValue:m,style:h,..._}=e,v=m??g,y=B.useRef([]),[b,x]=A({controlled:p,default:v,name:`Accordion`,state:`value`}),S=l((e,t,n)=>{let r;r=u?t?[...b,e]:b.filter(t=>t!==e):b[0]===e?[]:[e],c?.(r,n),!n.isCanceled&&x(r)}),C=B.useMemo(()=>({value:b,disabled:i,orientation:f}),[b,i,f]),w=B.useMemo(()=>({disabled:i,handleValueChange:S,hiddenUntilFound:a??!1,keepMounted:o??!1,state:C,value:b}),[i,S,a,o,C,b]),T=d(`div`,e,{state:C,ref:t,props:_,stateAttributesMapping:W});return(0,U.jsx)(V.Provider,{value:w,children:(0,U.jsx)(E,{elementsRef:y,children:T})})});function re(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=A({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:u}=D(a,!0,!0),d=L(),[f,p]=B.useState(),m=f===null?void 0:f??d,h=l(e=>{let t=!a,n=O(j,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return B.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:m,setMounted:c,setOpen:o,setPanelIdState:p,transitionStatus:u}),[d,i,h,s,a,m,c,o,p,u])}var ie=B.createContext(void 0);function G(){let e=B.useContext(ie);if(e===void 0)throw Error(v(15));return e}var K=B.createContext(void 0);function q(){let e=B.useContext(K);if(e===void 0)throw Error(v(9));return e}var ae=`data-open`,oe=`data-closed`,J=b,se=`data-panel-open`,ce={[ae]:``},le={[oe]:``},ue={open(e){return e?{[se]:``}:null}},de={open(e){return e?ce:le}},fe=`data-index`,Y={...de,index:e=>({[fe]:String(e)}),...R,value:()=>null},pe=B.forwardRef(function(e,t){let{className:n,disabled:r=!1,onOpenChange:i,render:a,value:o,style:s,...c}=e,{ref:u,index:f}=F(),{disabled:p,handleValueChange:m,state:h,value:g}=H(),_=L(),v=o??_,y=r||p,b=g.includes(v),x=l((e,t)=>{i?.(e,t),!t.isCanceled&&m(v,e,t)}),S=re({open:b,onOpenChange:x,disabled:y}),C=B.useMemo(()=>({...S,onOpenChange:x,state:{open:S.open,disabled:S.disabled,transitionStatus:S.transitionStatus}}),[S,x]),w=B.useMemo(()=>({...h,hidden:!b&&!S.mounted,index:f,disabled:y,open:b}),[S.mounted,y,f,b,h]),T=L(),[E,D]=B.useState(),O=E===null?void 0:E??T,k=B.useMemo(()=>({defaultTriggerId:T,open:b,state:w,setTriggerId:D,triggerId:O}),[T,b,w,D,O]),A=d(`div`,e,{state:w,ref:[t,u],props:c,stateAttributesMapping:Y});return(0,U.jsx)(ie.Provider,{value:C,children:(0,U.jsx)(K.Provider,{value:k,children:A})})}),me=B.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{state:o}=q();return d(`h3`,e,{state:o,ref:t,props:a,stateAttributesMapping:Y})}),he={...Y,...ue},ge=B.forwardRef(function(e,t){let{disabled:n,className:r,id:i,render:a,nativeButton:o=!0,style:s,...c}=e,{panelId:l,open:u,handleTrigger:p,disabled:m}=G(),{getButtonProps:h,buttonRef:g}=f({disabled:n||m,native:o}),{defaultTriggerId:v,state:y,setTriggerId:b}=q(),x=i||void 0,S=x??v;return _(()=>(b(e=>x??(e===null?void 0:e)),()=>{b(e=>e===x?null:e)}),[x,b]),d(`button`,e,{state:y,ref:[t,g],props:[{"aria-controls":u?l:void 0,"aria-expanded":u,id:S,onClick:p},c,h],stateAttributesMapping:he})}),X={height:void 0,width:void 0};function _e(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:u,transitionStatus:d}=e,f=B.useRef(null),p=B.useRef(null),[h,g]=B.useState(X),v=B.useRef(X),y=B.useRef(!1),b=B.useRef(s),x=B.useRef(!1),[S,E]=B.useState(!1),D=B.useRef(null),k=m(t,f),A=w(s),j=te(f),M=!s&&!a,P=S?`idle`:d,F=s&&(b.current||x.current),I=!s&&a&&p.current===`css-animation`&&h.height===void 0&&h.width===void 0?v.current:h,L=n&&M&&p.current!==`css-animation`,R=l((e,t=!0)=>{t&&(v.current=e),g(e)}),V=l(()=>{D.current?.(),D.current=null}),H=l(e=>{V(),D.current=()=>{D.current=null,e()}}),U=l(()=>{s&&a&&p.current===`css-animation`&&(x.current=!0)});_(()=>{S&&d!==`starting`&&E(!1)},[S,d]),B.useEffect(()=>()=>{U(),V()},[U,V]),_(()=>{s||(b.current=!1,x.current=!1);let e=f.current;if(!e)return;!s&&D.current&&V();let t=ve(e,F);if(p.current=t,s&&d===`idle`&&b.current&&t===`css-animation`){v.current=Z(e);return}if(s&&d===`starting`){let n=y.current;if(y.current=!1,t===`none`){R(Z(e)),E(!0);return}if(t===`css-transition`){let t=be(e);if(R(Z(e)),!n)return t;let r=Q(e,`transition-duration`,`0s`);return H(r),E(!0),t}R(Z(e));let r=Q(e,`animation-name`,`none`);if(!n){r();return}let i=Q(e,`animation-duration`,`0s`);r(),H(i),E(!0);return}if(!s&&a&&(d===`idle`||d===`starting`)){if(t===`none`){R(X,!1),c(!1);return}R(Z(e));return}if(d!==`ending`)return;if(t===`none`){c(!1);return}let n=Z(e);n.height>0||n.width>0?(R(n),t===`css-animation`&&Q(e,`animation-name`,`none`)()):c(!1)},[a,s,V,R,c,H,F,d]),C({enabled:s&&a&&P===`idle`,open:!0,ref:f,onComplete(){s&&R(X,!1)}}),B.useEffect(()=>{if(s||!a||P!==`ending`)return;if(!f.current){c(!1),R(X,!1);return}let e=new AbortController,t=-1;function n(){A.current||(c(!1),R(X,!1))}return t=z.request(()=>{j(n,e.signal)}),()=>{z.cancel(t),e.abort()}},[A,a,s,P,j,R,c]),_(()=>{let e=f.current;e&&n&&M&&e.setAttribute(`hidden`,`until-found`)},[M,n]),B.useEffect(function(){let e=f.current;if(!e)return;let t=T.create(),n=-1,r=(r,i)=>{t.start(0,()=>{A.current||(n=z.request(()=>{A.current||(r&&(y.current=!1),i&&e.setAttribute(J,``),e.setAttribute(`hidden`,`until-found`))}))})},i=ee(e,`beforematch`,t=>{let n=O(N,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}y.current=!0;let i=e.hasAttribute(J);e.removeAttribute(J),u(!0),r(!0,i)});return()=>{t.clear(),z.cancel(n),i()}},[A,o,u]);let W=i||n||a||s;return{height:I.height,props:{...L?{[J]:``}:void 0,hidden:M,id:r},ref:k,shouldPreventOpenAnimation:F,shouldRender:W,transitionStatus:P,width:I.width}}function Z(e){return{height:e.scrollHeight,width:e.scrollWidth}}function ve(e,t){let n=c(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&ye(n.animationDuration),i=ye(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function ye(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Q(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{r===``?e.style.removeProperty(t):e.style.setProperty(t,r,i)}}function be(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{n===``?e.style.removeProperty(t):e.style.setProperty(t,n)})}let r=z.request(n);return()=>{z.cancel(r),n()}}var xe=`--accordion-panel-height`,Se=`--accordion-panel-width`,Ce=B.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,id:a,render:o,style:s,...c}=e,{hiddenUntilFound:l,keepMounted:u}=H(),{defaultPanelId:f,mounted:m,onOpenChange:h,open:g,setMounted:v,setOpen:y,setPanelIdState:b,transitionStatus:x}=G(),S=r??l,C=i??u,w=a||void 0,T=a??f;_(()=>(b(e=>w??(e===null?void 0:e)),()=>{b(e=>e===w?null:e)}),[w,b]);let{height:E,props:D,ref:O,shouldPreventOpenAnimation:k,shouldRender:A,transitionStatus:j,width:M}=_e({externalRef:t,hiddenUntilFound:S,id:T,keepMounted:C,mounted:m,onOpenChange:h,open:g,setMounted:v,setOpen:y,transitionStatus:x}),{state:ee,triggerId:N}=q(),P={...ee,transitionStatus:j},F=p(s,P),I=d(`div`,{...e,style:void 0},{state:P,ref:O,props:[D,{"aria-labelledby":N,role:`region`,style:{[xe]:E===void 0?`auto`:`${E}px`,[Se]:M===void 0?`auto`:`${M}px`}},c,F?{style:F}:void 0,k?{style:{animationName:`none`}}:void 0],stateAttributesMapping:Y});return A?I:null});function we({className:e,...t}){return(0,U.jsx)(ne,{"data-slot":`accordion`,className:h(`flex w-full flex-col`,e),...t})}function Te({className:e,...t}){return(0,U.jsx)(pe,{"data-slot":`accordion-item`,className:h(`not-last:border-b`,e),...t})}function Ee({className:e,children:t,...n}){return(0,U.jsx)(me,{className:`flex`,children:(0,U.jsxs)(ge,{"data-slot":`accordion-trigger`,className:h(`group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground`,e),...n,children:[t,(0,U.jsx)(x,{"aria-hidden":`true`,"data-slot":`accordion-trigger-icon`,className:`pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden`}),(0,U.jsx)(S,{"aria-hidden":`true`,"data-slot":`accordion-trigger-icon`,className:`pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline`})]})})}function De({className:e,children:t,...n}){return(0,U.jsx)(Ce,{"data-slot":`accordion-content`,className:`overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up`,...n,children:(0,U.jsx)(`div`,{className:h(`h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),children:t})})}function Oe({className:e,size:t=`default`,...n}){return(0,U.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:h(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function ke({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-header`,className:h(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function Ae({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-title`,className:h(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function je({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-description`,className:h(`text-sm text-muted-foreground`,e),...t})}function Me({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-action`,className:h(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}var $={game:{title:`Game`,description:`Visuals, sound, performance, tools, and rules`},dialog:{title:`Dialog`,description:`Appearance, visible tabs, and visitor settings access`}};function Ne({value:e,onChange:o}){let[s,c]=(0,B.useState)(),l=n(r(a,e)),d=(t,n,r)=>o({...e,[t]:{...e[t],[n]:r}});return(0,U.jsxs)(`section`,{"aria-label":`Embed options`,className:`space-y-3 py-2 text-xs`,ref:e=>{let t=e?.getRootNode();t instanceof ShadowRoot&&t!==s&&c(t)},children:[(0,U.jsx)(Oe,{size:`sm`,className:`gap-0 bg-muted/30`,children:(0,U.jsxs)(ke,{className:`grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3`,children:[(0,U.jsx)(Ae,{children:`Configure your embed`}),(0,U.jsx)(je,{children:`Choose the experience and what visitors can change.`}),(0,U.jsx)(Me,{children:(0,U.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>{let t={...e};for(let e of Object.keys(i))Object.assign(t,{[e]:{...t[e],...i[e]}});o(t)},children:`Use SFW defaults`})})]})}),(0,U.jsx)(we,{defaultValue:[],className:`gap-2`,children:Object.keys($).map(e=>(0,U.jsxs)(Te,{value:e,className:`rounded-lg border bg-card/40 px-3`,children:[(0,U.jsx)(Ee,{className:`py-3 hover:no-underline`,children:(0,U.jsxs)(`span`,{className:`grid gap-1`,children:[(0,U.jsx)(`span`,{children:$[e].title}),(0,U.jsx)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:$[e].description})]})}),(0,U.jsx)(De,{children:(0,U.jsx)(`div`,{className:`divide-y border-t`,children:t.filter(t=>t.category===e).map(e=>{let t=`embed-${e.category}-${e.key}`,n=l[e.category][e.key],r=[`hint`,`tabs`].includes(e.control);return(0,U.jsxs)(`div`,{className:r?`grid gap-3 py-3`:`flex items-center justify-between gap-4 py-3`,children:[(0,U.jsxs)(`label`,{htmlFor:t,className:`grid min-w-0 gap-1 font-medium`,children:[(0,U.jsx)(`span`,{children:e.label}),e.help&&(0,U.jsx)(`span`,{className:`max-w-72 font-normal text-muted-foreground`,children:e.help})]}),(0,U.jsx)(k,{id:t,entry:e,value:n,container:s,onChange:t=>d(e.category,e.key,t)})]},e.key)})})})]},e))})]})}function Pe({embed:e}){let[t,n]=(0,B.useState)(`html`),r={html:{code:e.html,language:`html`,title:`HTML embed`},async:{code:e.async,language:`javascript`,title:`CDN`},npm:{code:e.npm,language:`javascript`,title:`JavaScript`},react:{code:e.react??``,language:`tsx`,title:`React`},bookmarklet:{code:e.bookmarklet,language:`javascript`,title:`Bookmarklet URL`}}[t];return(0,U.jsxs)(`section`,{className:`min-h-full px-3 py-2.5 text-sm`,children:[e.error?(0,U.jsx)(`p`,{role:`alert`,children:e.error}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I,{value:t,onValueChange:e=>n(e),className:`my-2.5 gap-0`,children:(0,U.jsxs)(M,{className:`w-full`,"aria-label":`Embed format`,children:[(0,U.jsx)(P,{value:`html`,className:`text-sm`,children:`HTML`}),(0,U.jsx)(P,{value:`async`,className:`text-sm`,children:`CDN`}),(0,U.jsx)(P,{value:`npm`,className:`text-sm`,children:`JavaScript`}),(0,U.jsx)(P,{value:`react`,className:`text-sm`,disabled:!e.react,children:`React`}),(0,U.jsx)(P,{value:`bookmarklet`,className:`text-sm`,children:`Bookmarklet`})]})}),(t===`npm`||t===`react`)&&(0,U.jsx)(`div`,{className:`mb-3`,children:(0,U.jsx)(y,{code:`npm install @joy-ride/game`,language:`shell`,title:`Install the package`,compact:!0})}),(0,U.jsx)(y,{code:r.code,language:r.language,title:r.title,compact:!0,maxHeight:210,wrap:t===`html`||t===`bookmarklet`})]}),e.configuration&&e.onConfigure&&(0,U.jsx)(Ne,{value:e.configuration,onChange:e.onConfigure})]})}export{Pe as EmbedPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n}from"./controls~index~embed-B_C92tUz.js";import{d as r}from"./runtime~index~embed-B2Zpd22X.js";import{i,r as a,t as o}from"./react-vendor~index~embed-BNCMh3YF.js";import{n as s}from"./runtime~JoyRideView~browser-session-core-Ya-yv4PC.js";import{i as c,o as l}from"./src-BJXg-amK.js";import{a as u,i as d,n as f,r as p,t as m}from"./X.es-d7B7rOGv.js";var h=e(a(),1),g=e(i(),1),_=o(),v={steer:0,gas:!1,brake:!1,boost:!1,handbrake:!1,attractor:!1},y={position:`fixed`,bottom:`calc(var(--joy-ride-controls-bottom, 0px) + max(18px, env(safe-area-inset-bottom)))`,zIndex:n(`controls`),touchAction:`none`,userSelect:`none`,WebkitUserSelect:`none`,color:`#f4f4f0`,fontFamily:`Arial, sans-serif`},b={border:`1px solid rgba(255,255,255,.38)`,background:`rgba(24,26,29,.84)`,color:`inherit`,boxShadow:`0 4px 16px #0005`,touchAction:`none`,cursor:`pointer`};function x({onChange:e}){let[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(v),o=(0,g.useRef)(v),s=(0,g.useRef)(null),c=(0,g.useRef)(e);c.current=e,(0,g.useEffect)(()=>{let e=window.matchMedia(`(pointer: coarse) and (max-width: 850px)`),t=()=>r(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let l=e=>{let n={...o.current,...e};o.current=n,a(n),c.current({...t(n.gas,n.brake),steer:n.steer,action:n.handbrake,boost:n.boost,attractor:n.attractor})};if((0,g.useEffect)(()=>{let e=()=>{s.current=null,o.current=v,a(v),c.current({throttle:0,steer:0,action:!1,boost:!1})};return window.addEventListener(`blur`,e),()=>{window.removeEventListener(`blur`,e),e()}},[]),!n)return null;let d=e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width/2;l({steer:Math.max(-1,Math.min(1,(n-(e.clientX-t.left))/(n*.72)))})},f=(e,t,n,r)=>(0,_.jsx)(u,{type:`button`,"aria-label":t,"aria-pressed":i[e],onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),l({[e]:!0})},onPointerUp:t=>{t.preventDefault(),l({[e]:!1})},onPointerCancel:()=>l({[e]:!1}),onLostPointerCapture:()=>l({[e]:!1}),style:{...b,gridArea:r,width:e===`attractor`?`100%`:62,height:e===`attractor`?44:62,borderRadius:16,background:i[e]?`rgba(90,94,98,.96)`:b.background,display:`grid`,placeItems:`center`,lineHeight:1,fontSize:10,fontWeight:700,letterSpacing:`.08em`,textTransform:`uppercase`},children:(0,_.jsxs)(`span`,{style:{display:`grid`,gap:3,justifyItems:`center`},children:[(0,_.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:20,lineHeight:1},children:n}),t]})});return(0,_.jsxs)(`div`,{"data-jr-touch-controls":``,"aria-label":`Touch driving controls`,children:[(0,_.jsx)(`div`,{style:{...y,left:`max(16px, env(safe-area-inset-left))`},children:(0,_.jsxs)(`div`,{role:`slider`,"aria-label":`Steering`,"aria-valuemin":-100,"aria-valuemax":100,"aria-valuenow":Math.round(-i.steer*100),tabIndex:0,onKeyDown:e=>{e.key===`ArrowLeft`&&(e.preventDefault(),l({steer:1})),e.key===`ArrowRight`&&(e.preventDefault(),l({steer:-1}))},onKeyUp:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&l({steer:0})},onPointerDown:e=>{e.preventDefault(),s.current=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),d(e)},onPointerMove:e=>{s.current===e.pointerId&&d(e)},onPointerUp:e=>{s.current===e.pointerId&&(s.current=null,l({steer:0}))},onPointerCancel:()=>{s.current=null,l({steer:0})},style:{...b,width:116,height:116,borderRadius:`50%`,position:`relative`,display:`grid`,placeItems:`center`},children:[(0,_.jsx)(`span`,{"aria-hidden":`true`,style:{position:`absolute`,top:14,fontSize:10,fontWeight:700,letterSpacing:`.1em`,opacity:.8},children:`STEER`}),(0,_.jsx)(`span`,{"aria-hidden":`true`,style:{width:48,height:48,borderRadius:`50%`,background:`#d1d3d2`,boxShadow:`0 2px 8px #0008`,transform:`translateX(${-i.steer*27}px)`,pointerEvents:`none`}})]})}),(0,_.jsxs)(`div`,{style:{...y,right:`max(16px, env(safe-area-inset-right))`,display:`grid`,gridTemplateAreas:`"attractor attractor" "boost gas" "handbrake brake"`,gap:8},children:[f(`attractor`,`Attract`,`◎`,`attractor`),f(`boost`,`Boost`,(0,_.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,_.jsx)(`path`,{d:`M13.7 2 5 13h6l-.7 9L19 10h-6l.7-8Z`})}),`boost`),f(`gas`,`Gas`,`↑`,`gas`),f(`handbrake`,`Drift`,`↺`,`handbrake`),f(`brake`,`Brake`,`↓`,`brake`)]})]})}var S=new Map([[`bold`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z`}))],[`duotone`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),g.createElement(`path`,{d:`M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z`}))],[`fill`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z`}))],[`light`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M142,176a6,6,0,0,1-6,6,14,14,0,0,1-14-14V128a2,2,0,0,0-2-2,6,6,0,0,1,0-12,14,14,0,0,1,14,14v40a2,2,0,0,0,2,2A6,6,0,0,1,142,176ZM124,94a10,10,0,1,0-10-10A10,10,0,0,0,124,94Zm106,34A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z`}))],[`thin`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M140,176a4,4,0,0,1-4,4,12,12,0,0,1-12-12V128a4,4,0,0,0-4-4,4,4,0,0,1,0-8,12,12,0,0,1,12,12v40a4,4,0,0,0,4,4A4,4,0,0,1,140,176ZM124,92a8,8,0,1,0-8-8A8,8,0,0,0,124,92Zm104,36A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),C=g.forwardRef((e,t)=>g.createElement(d,{ref:t,...e,weights:S}));C.displayName=`InfoIcon`;var w=(0,g.forwardRef)(function({visible:e=!0,className:t=``,children:n,...r},i){return(0,_.jsx)(`div`,{ref:i,role:`toolbar`,"data-jr-toolbar":``,"data-visible":e,className:`inline-flex items-center gap-0.5 transition-opacity duration-150 ease-out data-[visible=false]:pointer-events-none data-[visible=false]:opacity-0 ${t}`,...r,children:n})});function T({iconOnly:e=!1,className:t=``,children:n,...r}){return(0,_.jsx)(u,{type:`button`,variant:`ghost`,size:e?`icon-xs`:`xs`,className:`h-[25px] min-h-[25px] rounded-sm border-0 bg-[#202326] px-2 text-[10px] font-semibold text-white shadow-[0_3px_10px_#0004] hover:bg-[#34383b] hover:text-white focus-visible:ring-white/40 [&_svg]:size-[13px] ${e?`w-[25px] p-0`:``} ${t}`,...r,children:n})}var E=l(c);function D(e,t){let i=(0,g.useRef)(e);i.current=e;let a=(0,g.useRef)(null),[o,s]=(0,g.useState)(null),c=!!e.onExit,l=!!e.overlay&&(c||!!e.onToggleMute||!!e.onControlsHelp);(0,g.useEffect)(()=>{if(!l)return;let e=document.createElement(`joy-ride-vehicle-toolbar`);e.dataset.jrUi=``,e.style.cssText=`position:fixed;left:0;top:0;z-index:${n(`controls`)};pointer-events:none`;let t=e.attachShadow({mode:`open`}),r=document.createElement(`style`);return r.textContent=E,t.append(r),document.body.append(e),s(t),()=>{e.remove(),s(null)}},[l]);let u=e=>r(e=>{let n=t.current?.handle.getPlayground()?.registry;n?n.report(e):console.error(`JoyRide host callback failed`,e)},e);return{adapter:(0,g.useMemo)(()=>({toolbar:()=>a.current,cameraFrame(){let e=Array.from(document.querySelectorAll(`[data-jr-touch-controls] > div`)),t=e.length?Math.min(...e.map(e=>e.getBoundingClientRect().top))-16:window.innerHeight;return e.length?{x:0,y:0,width:window.innerWidth,height:Math.max(160,t)}:null}}),[]),toolbar:e.overlay&&o&&(c||e.onToggleMute||e.onControlsHelp)?(0,h.createPortal)((0,_.jsxs)(w,{ref:a,"data-jr-ui":``,"aria-label":`Vehicle controls`,visible:!1,inert:!0,className:`fixed pointer-events-auto`,style:{zIndex:n(`controls`)},children:[e.onToggleMute&&(0,_.jsx)(T,{iconOnly:!0,"aria-label":(e.masterVolume??1)>0?`Mute audio`:`Unmute audio`,onClick:()=>u(i.current.onToggleMute),children:(e.masterVolume??1)>0?(0,_.jsx)(p,{size:14}):(0,_.jsx)(f,{size:14})}),e.onControlsHelp&&(0,_.jsx)(T,{iconOnly:!0,"aria-label":`Open controls help`,title:`Controls help`,onClick:()=>u(i.current.onControlsHelp),children:(0,_.jsx)(C,{size:14})}),c&&(0,_.jsx)(T,{iconOnly:!0,"aria-label":`Quit simulation`,onClick:()=>u(i.current.onExit),children:(0,_.jsx)(m,{size:14})})]}),o):null}}function O({ref:e,overlayRoot:t,className:n,style:r,onControlsHelp:i,...a}){return a}var k=e=>t=>{let r=t,i=O(t),{ref:a,overlay:o=s.overlay,overlayRoot:c,className:l,style:u,mode:d,initialMode:f=s.initialMode,paused:p=s.paused,showTouchControls:m=s.showTouchControls}=r,v=(0,g.useRef)(null),y=(0,g.useRef)(null),b=(0,g.useRef)(i);b.current=i;let S=D(r,y);(0,g.useLayoutEffect)(()=>{if(!v.current)return;let t=e(v.current,b.current,S.adapter);return y.current=t,()=>{t.dispose(),y.current=null}},[S.adapter]),(0,g.useImperativeHandle)(a,()=>y.current.handle,[]),(0,g.useLayoutEffect)(()=>{y.current?.update(i)});let C=(0,_.jsx)(`canvas`,{ref:v,className:l,style:{display:`block`,width:o?void 0:`100%`,height:o?void 0:`100%`,outline:`none`,touchAction:`none`,...u,...o?{position:`absolute`,zIndex:n(`world`),pointerEvents:`none`}:{}},"data-jr-overlay":o?``:void 0,tabIndex:o?-1:0,"aria-label":`Joy Ride vehicle simulation`});return o&&typeof document<`u`?(0,_.jsxs)(_.Fragment,{children:[(0,h.createPortal)((0,_.jsxs)(_.Fragment,{children:[C,m&&!p&&(d??f)===`car`&&(0,_.jsx)(x,{onChange:e=>y.current?.touchChange(e)})]}),c??document.body),S.toolbar]}):C};export{k as createJoyRide};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n}from"./controls~index~embed-B_C92tUz.js";import{d as r}from"./runtime~index~embed-B2Zpd22X.js";import{i,r as a,t as o}from"./react-vendor~index~embed-BNCMh3YF.js";import{n as s}from"./runtime~JoyRideView~browser-session-core-Ya-yv4PC.js";import{i as c,o as l}from"./src-v4km-Xn-.js";import{a as u,i as d,n as f,r as p,t as m}from"./X.es-d7B7rOGv.js";var h=e(a(),1),g=e(i(),1),_=o(),v={steer:0,gas:!1,brake:!1,boost:!1,handbrake:!1,attractor:!1},y={position:`fixed`,bottom:`calc(var(--joy-ride-controls-bottom, 0px) + max(18px, env(safe-area-inset-bottom)))`,zIndex:n(`controls`),touchAction:`none`,userSelect:`none`,WebkitUserSelect:`none`,color:`#f4f4f0`,fontFamily:`Arial, sans-serif`},b={border:`1px solid rgba(255,255,255,.38)`,background:`rgba(24,26,29,.84)`,color:`inherit`,boxShadow:`0 4px 16px #0005`,touchAction:`none`,cursor:`pointer`};function x({onChange:e}){let[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(v),o=(0,g.useRef)(v),s=(0,g.useRef)(null),c=(0,g.useRef)(e);c.current=e,(0,g.useEffect)(()=>{let e=window.matchMedia(`(pointer: coarse) and (max-width: 850px)`),t=()=>r(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let l=e=>{let n={...o.current,...e};o.current=n,a(n),c.current({...t(n.gas,n.brake),steer:n.steer,action:n.handbrake,boost:n.boost,attractor:n.attractor})};if((0,g.useEffect)(()=>{let e=()=>{s.current=null,o.current=v,a(v),c.current({throttle:0,steer:0,action:!1,boost:!1})};return window.addEventListener(`blur`,e),()=>{window.removeEventListener(`blur`,e),e()}},[]),!n)return null;let d=e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width/2;l({steer:Math.max(-1,Math.min(1,(n-(e.clientX-t.left))/(n*.72)))})},f=(e,t,n,r)=>(0,_.jsx)(u,{type:`button`,"aria-label":t,"aria-pressed":i[e],onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),l({[e]:!0})},onPointerUp:t=>{t.preventDefault(),l({[e]:!1})},onPointerCancel:()=>l({[e]:!1}),onLostPointerCapture:()=>l({[e]:!1}),style:{...b,gridArea:r,width:e===`attractor`?`100%`:62,height:e===`attractor`?44:62,borderRadius:16,background:i[e]?`rgba(90,94,98,.96)`:b.background,display:`grid`,placeItems:`center`,lineHeight:1,fontSize:10,fontWeight:700,letterSpacing:`.08em`,textTransform:`uppercase`},children:(0,_.jsxs)(`span`,{style:{display:`grid`,gap:3,justifyItems:`center`},children:[(0,_.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:20,lineHeight:1},children:n}),t]})});return(0,_.jsxs)(`div`,{"data-jr-touch-controls":``,"aria-label":`Touch driving controls`,children:[(0,_.jsx)(`div`,{style:{...y,left:`max(16px, env(safe-area-inset-left))`},children:(0,_.jsxs)(`div`,{role:`slider`,"aria-label":`Steering`,"aria-valuemin":-100,"aria-valuemax":100,"aria-valuenow":Math.round(-i.steer*100),tabIndex:0,onKeyDown:e=>{e.key===`ArrowLeft`&&(e.preventDefault(),l({steer:1})),e.key===`ArrowRight`&&(e.preventDefault(),l({steer:-1}))},onKeyUp:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&l({steer:0})},onPointerDown:e=>{e.preventDefault(),s.current=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),d(e)},onPointerMove:e=>{s.current===e.pointerId&&d(e)},onPointerUp:e=>{s.current===e.pointerId&&(s.current=null,l({steer:0}))},onPointerCancel:()=>{s.current=null,l({steer:0})},style:{...b,width:116,height:116,borderRadius:`50%`,position:`relative`,display:`grid`,placeItems:`center`},children:[(0,_.jsx)(`span`,{"aria-hidden":`true`,style:{position:`absolute`,top:14,fontSize:10,fontWeight:700,letterSpacing:`.1em`,opacity:.8},children:`STEER`}),(0,_.jsx)(`span`,{"aria-hidden":`true`,style:{width:48,height:48,borderRadius:`50%`,background:`#d1d3d2`,boxShadow:`0 2px 8px #0008`,transform:`translateX(${-i.steer*27}px)`,pointerEvents:`none`}})]})}),(0,_.jsxs)(`div`,{style:{...y,right:`max(16px, env(safe-area-inset-right))`,display:`grid`,gridTemplateAreas:`"attractor attractor" "boost gas" "handbrake brake"`,gap:8},children:[f(`attractor`,`Attract`,`◎`,`attractor`),f(`boost`,`Boost`,(0,_.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,_.jsx)(`path`,{d:`M13.7 2 5 13h6l-.7 9L19 10h-6l.7-8Z`})}),`boost`),f(`gas`,`Gas`,`↑`,`gas`),f(`handbrake`,`Drift`,`↺`,`handbrake`),f(`brake`,`Brake`,`↓`,`brake`)]})]})}var S=new Map([[`bold`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z`}))],[`duotone`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),g.createElement(`path`,{d:`M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z`}))],[`fill`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z`}))],[`light`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M142,176a6,6,0,0,1-6,6,14,14,0,0,1-14-14V128a2,2,0,0,0-2-2,6,6,0,0,1,0-12,14,14,0,0,1,14,14v40a2,2,0,0,0,2,2A6,6,0,0,1,142,176ZM124,94a10,10,0,1,0-10-10A10,10,0,0,0,124,94Zm106,34A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z`}))],[`thin`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M140,176a4,4,0,0,1-4,4,12,12,0,0,1-12-12V128a4,4,0,0,0-4-4,4,4,0,0,1,0-8,12,12,0,0,1,12,12v40a4,4,0,0,0,4,4A4,4,0,0,1,140,176ZM124,92a8,8,0,1,0-8-8A8,8,0,0,0,124,92Zm104,36A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),C=g.forwardRef((e,t)=>g.createElement(d,{ref:t,...e,weights:S}));C.displayName=`InfoIcon`;var w=(0,g.forwardRef)(function({visible:e=!0,className:t=``,children:n,...r},i){return(0,_.jsx)(`div`,{ref:i,role:`toolbar`,"data-jr-toolbar":``,"data-visible":e,className:`inline-flex items-center gap-0.5 transition-opacity duration-150 ease-out data-[visible=false]:pointer-events-none data-[visible=false]:opacity-0 ${t}`,...r,children:n})});function T({iconOnly:e=!1,className:t=``,children:n,...r}){return(0,_.jsx)(u,{type:`button`,variant:`ghost`,size:e?`icon-xs`:`xs`,className:`h-[25px] min-h-[25px] rounded-sm border-0 bg-[#202326] px-2 text-[10px] font-semibold text-white shadow-[0_3px_10px_#0004] hover:bg-[#34383b] hover:text-white focus-visible:ring-white/40 [&_svg]:size-[13px] ${e?`w-[25px] p-0`:``} ${t}`,...r,children:n})}var E=l(c);function D(e,t){let i=(0,g.useRef)(e);i.current=e;let a=(0,g.useRef)(null),[o,s]=(0,g.useState)(null),c=!!e.onExit,l=!!e.overlay&&(c||!!e.onToggleMute||!!e.onControlsHelp);(0,g.useEffect)(()=>{if(!l)return;let e=document.createElement(`joy-ride-vehicle-toolbar`);e.dataset.jrUi=``,e.style.cssText=`position:fixed;left:0;top:0;z-index:${n(`controls`)};pointer-events:none`;let t=e.attachShadow({mode:`open`}),r=document.createElement(`style`);return r.textContent=E,t.append(r),document.body.append(e),s(t),()=>{e.remove(),s(null)}},[l]);let u=e=>r(e=>{let n=t.current?.handle.getPlayground()?.registry;n?n.report(e):console.error(`JoyRide host callback failed`,e)},e);return{adapter:(0,g.useMemo)(()=>({toolbar:()=>a.current,cameraFrame(){let e=Array.from(document.querySelectorAll(`[data-jr-touch-controls] > div`)),t=e.length?Math.min(...e.map(e=>e.getBoundingClientRect().top))-16:window.innerHeight;return e.length?{x:0,y:0,width:window.innerWidth,height:Math.max(160,t)}:null}}),[]),toolbar:e.overlay&&o&&(c||e.onToggleMute||e.onControlsHelp)?(0,h.createPortal)((0,_.jsxs)(w,{ref:a,"data-jr-ui":``,"aria-label":`Vehicle controls`,visible:!1,inert:!0,className:`fixed pointer-events-auto`,style:{zIndex:n(`controls`)},children:[e.onToggleMute&&(0,_.jsx)(T,{iconOnly:!0,"aria-label":(e.masterVolume??1)>0?`Mute audio`:`Unmute audio`,onClick:()=>u(i.current.onToggleMute),children:(e.masterVolume??1)>0?(0,_.jsx)(p,{size:14}):(0,_.jsx)(f,{size:14})}),e.onControlsHelp&&(0,_.jsx)(T,{iconOnly:!0,"aria-label":`Open controls help`,title:`Controls help`,onClick:()=>u(i.current.onControlsHelp),children:(0,_.jsx)(C,{size:14})}),c&&(0,_.jsx)(T,{iconOnly:!0,"aria-label":`Quit simulation`,onClick:()=>u(i.current.onExit),children:(0,_.jsx)(m,{size:14})})]}),o):null}}function O({ref:e,overlayRoot:t,className:n,style:r,onControlsHelp:i,...a}){return a}var k=e=>t=>{let r=t,i=O(t),{ref:a,overlay:o=s.overlay,overlayRoot:c,className:l,style:u,mode:d,initialMode:f=s.initialMode,paused:p=s.paused,showTouchControls:m=s.showTouchControls}=r,v=(0,g.useRef)(null),y=(0,g.useRef)(null),b=(0,g.useRef)(i);b.current=i;let S=D(r,y);(0,g.useLayoutEffect)(()=>{if(!v.current)return;let t=e(v.current,b.current,S.adapter);return y.current=t,()=>{t.dispose(),y.current=null}},[S.adapter]),(0,g.useImperativeHandle)(a,()=>y.current.handle,[]),(0,g.useLayoutEffect)(()=>{y.current?.update(i)});let C=(0,_.jsx)(`canvas`,{ref:v,className:l,style:{display:`block`,width:o?void 0:`100%`,height:o?void 0:`100%`,outline:`none`,touchAction:`none`,...u,...o?{position:`absolute`,zIndex:n(`world`),pointerEvents:`none`}:{}},"data-jr-overlay":o?``:void 0,tabIndex:o?-1:0,"aria-label":`Joy Ride vehicle simulation`});return o&&typeof document<`u`?(0,_.jsxs)(_.Fragment,{children:[(0,h.createPortal)((0,_.jsxs)(_.Fragment,{children:[C,m&&!p&&(d??f)===`car`&&(0,_.jsx)(x,{onChange:e=>y.current?.touchChange(e)})]}),c??document.body),S.toolbar]}):C};export{k as createJoyRide};
|