@frigade/react 2.0.0-alpha.4 → 2.0.0-alpha.41
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 +601 -4
- package/dist/index.cjs +65 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1210 -44
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/package.json +17 -3
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
var ee=Object.defineProperty,Fe=Object.defineProperties;var Ee=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var Z=(e,t,o)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))te.call(t,o)&&Z(e,o,t[o]);if($)for(var o of $(t))oe.call(t,o)&&Z(e,o,t[o]);return e},u=(e,t)=>Fe(e,Ee(t));var p=(e,t)=>{var o={};for(var r in e)te.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&$)for(var r of $(e))t.indexOf(r)<0&&oe.call(e,r)&&(o[r]=e[r]);return o};var re=(e,t)=>{for(var o in t)ee(e,o,{get:t[o],enumerable:!0})};var k=(e,t,o)=>new Promise((r,n)=>{var l=c=>{try{d(o.next(c))}catch(f){n(f)}},s=c=>{try{d(o.throw(c))}catch(f){n(f)}},d=c=>c.done?r(c.value):Promise.resolve(c.value).then(l,s);d((o=o.apply(e,t)).next())});var _react = require('react'); var de = _interopRequireWildcard(_react); var U = _interopRequireWildcard(_react);var _clsx = require('clsx');var Ae="px",De=e=>typeof e=="number"?`${4*e}${Ae}`:e,He=[-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,-.5,0,.5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,"auto"],Ve=Object.fromEntries(He.map(e=>[e,De(e)])),We={black:"#000000",gray100:"#14161A",gray200:"#181B20",gray300:"#1F2329",gray400:"#2E343D",gray500:"#4C5766",gray600:"#5A6472",gray700:"#C5CBD3",gray800:"#E2E5E9",gray900:"#F1F2F4",white:"#ffffff",blue400:"#015AC6",blue500:"#0171F8",blue800:"#DBECFF",blue900:"#F5F9FF",green400:"#009E37",green500:"#00D149",green800:"#DBFFE8",transparent:"#FFFFFF00",red500:"#c00000"},I={borders:{md:"1px solid"},borderWidths:{0:"0",md:"1px"},colors:a({},We),fontFamilies:{default:"TT Interphases Pro, sans-serif"},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px",xl:"20px","2xl":"24px","3xl":"30px","4xl":"36px","5xl":"48px"},fontWeights:{regular:"400",demibold:"600",bold:"700"},letterSpacings:{md:"0.02em"},lineHeights:{xs:"18px",sm:"22px",md:"24px",lg:"26px",xl:"30px","2xl":"38px","3xl":"46px","4xl":"60px"},radii:{md:"8px",lg:"20px",round:"50%"},shadows:{md:"0px 4px 20px rgba(0, 0, 0, 0.1)"},space:Ve};var i=e=>`var(--fr-colors-${e})`,ne={neutral:{background:i("white"),border:i("gray900"),foreground:i("black"),surface:i("gray700"),active:{background:i("white"),border:i("gray900"),foreground:i("black"),surface:i("gray700")},focus:{background:i("white"),border:i("gray900"),foreground:i("black"),surface:i("gray700")},hover:{background:i("white"),border:i("gray900"),foreground:i("black"),surface:i("gray700")}},primary:{background:i("blue500"),border:i("blue500"),foreground:i("white"),surface:i("blue500"),active:{background:i("blue400"),border:i("blue400"),foreground:i("white"),surface:i("blue400")},focus:{background:i("blue500"),border:i("blue500"),foreground:i("white"),surface:i("blue500")},hover:{background:i("blue400"),border:i("blue400"),foreground:i("white"),surface:i("blue400")}},secondary:{background:i("gray900"),border:i("gray900"),foreground:i("black"),surface:i("gray900"),active:{background:i("gray800"),border:i("gray800"),foreground:i("black"),surface:i("gray800")},focus:{background:i("gray900"),border:i("gray900"),foreground:i("black"),surface:i("gray900")},hover:{background:i("gray800"),border:i("gray800"),foreground:i("black"),surface:i("gray800")}}};var j=u(a({},I),{colors:a(a({},I.colors),ne)});function O(e,t="",o="."){return Object.keys(e).reduce((r,n)=>{let s=`${t.length?`${t}${o}`:""}${n}`,d=e[n];return typeof d=="object"&&d!==null&&!Array.isArray(d)?Object.assign(r,O(d,s,o)):r[s]=d,r},{})}function L(e){return O(e,"--fr","-")}function ie(e,t="--fr"){let o={};return Object.keys(e).forEach(r=>{let n=e[r];typeof n=="object"&&n!==null&&!Array.isArray(n)?o[r]=ie(n,`${t}-${r}`):o[r]=`var(${t}-${r})`}),o}var se=L(j),g=ie(j);var z=O(g.colors),ae={color:z,backgroundColor:z,borderColor:z,border:g.borders,borderRadius:g.radii,borderWidth:g.borderWidths,fontFamily:g.fontFamilies,fontSize:g.fontSizes,fontWeight:g.fontWeights,gap:g.space,lineHeight:g.lineHeights,margin:g.space,marginTop:g.space,marginRight:g.space,marginBottom:g.space,marginLeft:g.space,padding:g.space,paddingTop:g.space,paddingRight:g.space,paddingBottom:g.space,paddingLeft:g.space,alignContent:["center","start","end","flex-start","flex-end","normal","baseline","first baseline","last baseline","space-between","space-around","space-evenly","stretch","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],alignItems:["normal","stretch","center","start","end","flex-start","flex-end","self-start","self-end","baseline","first baseline","last baseline","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],alignSelf:["auto","normal","center","start","end","self-start","self-end","flex-start","flex-end","baseline","first baseline","last baseline","stretch","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],flexDirection:["row","row-reverse","column","column-reverse","inherit","initial","revert","revert-layer","unset"],flexWrap:["nowrap","wrap","wrap-reverse","inherit","initial","revert","revert-layer","unset"],justifyContent:["center","start","end","flex-start","flex-end","left","right","normal","space-between","space-around","space-evenly","stretch","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],justifyItems:["normal","stretch","center","start","end","flex-start","flex-end","self-start","self-end","left","right","baseline","first baseline","last baseline","safe center","unsafe center","legacy right","legacy left","legacy center","inherit","initial","revert","revert-layer","unset"],boxSizing:["border-box","content-box","inherit","initial","revert","revert-layer","unset"],position:["static","relative","absolute","fixed","sticky","inherit","initial","revert","revert-layer","unset"],display:["block","block flex","block flow","block flow-root","block grid","contents","flex","flow-root","grid","inherit","initial","inline","inline flex","inline flow","inline flow-root","inline grid","inline-block","inline-flex","inline-grid","list-item","none","revert","revert-layer","table","table-row-group","table-header-group","table-footer-group","table-row","table-cell","table-column-group","table-column","table-caption","unset"]},le={m:["margin"],mt:["marginTop"],mr:["marginRight"],mb:["marginBottom"],ml:["marginLeft"],mx:["marginLeft","marginRight"],my:["marginTop","marginBottom"],p:["padding"],pt:["paddingTop"],pr:["paddingRight"],pb:["paddingBottom"],pl:["paddingLeft"],px:["paddingLeft","paddingRight"],py:["paddingTop","paddingBottom"]};function Me(e){if(Array.isArray(e))return new Map(e.map(t=>[t,t]));if(typeof e=="object"&&e!==null)return new Map(Object.entries(e));if(["string","number"].includes(typeof e))return new Map([e,e]);throw new Error("Invalid entry in styleProps")}var $e=new Map(Object.entries(ae).map(([e,t])=>[e,Me(t)])),Ie=new Map(Object.entries(le).map(([e,t])=>[e,new Set(t)]));function pe(e){let t=Object.assign({},e),o={};return Object.entries(t).forEach(([r,n])=>{let l=Ie.get(r);l!=null&&(l.forEach(s=>{t[s]=n}),delete t[r])}),Object.entries(t).forEach(([r,n])=>{let l=$e.get(r);if(l!=null)if(typeof n=="string"&&n.indexOf(" ")>-1){let s=n.split(" ");o[r]=s.map(d=>{var c;return(c=l.get(d.toString()))!=null?c:d}).join(" "),delete t[r]}else l.has(n.toString())&&(o[r]=l.get(n.toString()),delete t[r])}),{cssFromProps:o,unmatchedProps:t}}var _jsxruntime = require('@emotion/react/jsx-runtime');function ce(e){return e&&`fr-${e}`}function Le(e){return e&&(Array.isArray(e)?e.map(t=>ce(t)).join(" "):ce(e))}function ze(d,s){var c=d,{as:e,children:t,className:o,css:r,part:n}=c,l=p(c,["as","children","className","css","part"]);let f=e!=null?e:"div",{cssFromProps:h,unmatchedProps:y}=pe(l),v=Le(n),B=o||v?_clsx.clsx.call(void 0, o,v):void 0;return _jsxruntime.jsx.call(void 0, f,u(a({className:B,css:[a(a({boxSizing:"border-box"},h),r)]},y),{ref:s,children:t}))}var m=de.forwardRef(ze);var K={};re(K,{Body1:()=>Je,Body2:()=>Qe,Caption:()=>Ye,Display1:()=>Ne,Display2:()=>Ue,H1:()=>_e,H2:()=>Xe,H3:()=>qe,H4:()=>Ge,base:()=>P});var P=({fontFamilies:e})=>({fontFamily:e.default,margin:0}),Ne=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e["5xl"],fontWeight:t.bold,lineHeight:o["4xl"]}],Ue=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e["4xl"],fontWeight:t.bold,lineHeight:o["3xl"]}],_e=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e["3xl"],fontWeight:t.bold,lineHeight:o["2xl"]}],Xe=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e["2xl"],fontWeight:t.bold,lineHeight:o.xl}],qe=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e.xl,fontWeight:t.bold,lineHeight:o.lg}],Ge=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e.lg,fontWeight:t.bold,lineHeight:o.md}],Je=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e.md,fontWeight:t.regular,lineHeight:o.md}],Qe=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e.sm,fontWeight:t.regular,lineHeight:o.md}],Ye=({fontSizes:e,fontWeights:t,lineHeights:o})=>[P,{fontSize:e.xs,fontWeight:t.regular,lineHeight:o.sm}];function fe(l){var s=l,{as:e="span",children:t,css:o,variant:r="Body1"}=s,n=p(s,["as","children","css","variant"]);return _jsxruntime.jsx.call(void 0, m,u(a({as:e,css:[K[r],o]},n),{children:t}))}var Ze=["Display1","Display2","H1","H2","H3","H4","Body1","Body2","Caption"],et=Object.fromEntries(Ze.map(e=>{let t=["H1","H2","H3","H4"].includes(e)?e.toLowerCase():void 0,o=r=>_jsxruntime.jsx.call(void 0, fe,u(a({as:t},r),{variant:e,children:r.children}));return o.displayName=`Text.${e}`,[e,o]})),T= exports.Text =Object.assign(fe,et);var N={};re(N,{Link:()=>rt,Plain:()=>nt,Primary:()=>tt,Secondary:()=>ot,base:()=>F});var F=({radii:e,space:t})=>({borderWidth:0,borderRadius:e.md,padding:`${t[2]} ${t[4]}`}),tt=({colors:e})=>[F,{backgroundColor:e.primary.surface,color:e.primary.foreground,"&:hover":{backgroundColor:e.primary.hover.surface}}],ot=({colors:e})=>[F,{backgroundColor:e.secondary.surface,color:e.secondary.foreground,"&:hover":{backgroundColor:e.secondary.hover.surface}}],rt=({colors:e})=>[F,{backgroundColor:e.transparent,color:e.primary.surface,"&:hover":{color:e.primary.hover.surface}}],nt=({colors:e})=>[F,{backgroundColor:e.transparent,color:e.neutral.foreground}];function ge(s){var d=s,{as:e,children:t,css:o={},title:r,variant:n="Primary"}=d,l=p(d,["as","children","css","title","variant"]);return _jsxruntime.jsxs.call(void 0, m,u(a({as:e!=null?e:"button",css:[N[n],o]},l),{children:[t,r&&_jsxruntime.jsx.call(void 0, T.Body2,{fontWeight:"demibold",children:r})]}))}var it=["Primary","Secondary","Link","Plain"],st=Object.fromEntries(it.map(e=>{let t=e.toLocaleLowerCase(),o=l=>{var s=l,{part:r}=s,n=p(s,["part"]);return _jsxruntime.jsx.call(void 0, ge,u(a({part:[`button-${t}`,r]},n),{variant:e,children:n.children}))};return o.displayName=`Text.${e}`,[e,o]})),E= exports.Button =Object.assign(ge,st);var lt=U.forwardRef((n,r)=>{var l=n,{children:e,css:t}=l,o=p(l,["children","css"]);return _jsxruntime.jsx.call(void 0, m,u(a({css:[{display:"flex",flexDirection:"row"},t]},o),{ref:r,children:e}))}),pt=U.forwardRef((n,r)=>{var l=n,{children:e,css:t}=l,o=p(l,["children","css"]);return _jsxruntime.jsx.call(void 0, m,u(a({css:[{display:"flex",flexDirection:"column"},t]},o),{ref:r,children:e}))}),R= exports.Flex ={Column:pt,Row:lt};var _react2 = require('@emotion/react');var _=_react.createContext.call(void 0, {apiKey:"",config:{}});function ut({apiKey:e,children:t,config:o={},theme:r}){let n=r?L(r):{};return _jsxruntime.jsxs.call(void 0, _.Provider,{value:{apiKey:e,config:o},children:[_jsxruntime.jsx.call(void 0, _react2.Global,{styles:{":root":a(a({},se),n)}}),_jsxruntime.jsx.call(void 0, _react2.ThemeProvider,{theme:g,children:t})]})}var _solid = require('@heroicons/react/24/solid');var _reactpopover = require('@radix-ui/react-popover'); var w = _interopRequireWildcard(_reactpopover);function he(){let e="DOMRect"in globalThis?new DOMRect:{height:0,width:0,x:0,y:0,bottom:0,top:0,right:0,left:0,toJSON:()=>{}},[t,o]=_react.useState.call(void 0, e),[r,n]=_react.useState.call(void 0, null),l=_react.useCallback.call(void 0, s=>{n(s)},[]);return _react.useLayoutEffect.call(void 0, ()=>{r&&o(r.getBoundingClientRect())},[r]),{node:r,rect:t,ref:l}}var yt=_react2.keyframes.call(void 0, {"0%":{opacity:.5,transform:"scale(0.5)"},"50%":{opacity:0,transform:"scale(1)"},"100%":{opacity:0,transform:"scale(1)"}});function we(r){var n=r,{style:e={},part:t=""}=n,o=p(n,["style","part"]);return _jsxruntime.jsxs.call(void 0, m,u(a({part:`dot-wrapper ${t}`,style:a({height:"48px",position:"absolute",width:"48px"},e)},o),{children:[_jsxruntime.jsx.call(void 0, m,{backgroundColor:"primary.surface",part:"dot-pulse",css:{animation:`2s ease-out infinite ${yt}`,borderRadius:"24px",height:"48px",left:0,position:"absolute",top:0,transformOrigin:"center center",width:"48px"}}),_jsxruntime.jsx.call(void 0, m,{backgroundColor:"primary.surface",part:"dot",style:{borderRadius:"12px",height:"24px",left:"12px",position:"absolute",top:"12px",width:"24px"}})]}))}function Be(r){var n=r,{part:e,src:t}=n,o=p(n,["part","src"]);return _jsxruntime.jsx.call(void 0, m,a({as:"img",part:["image",e],src:t},o))}function wt(e){var t,o,r;if(e.includes("youtube"))return`https://www.youtube.com/embed/${(t=e.split("v=")[1])==null?void 0:t.split("&")[0]}`;if(e.includes("vimeo"))return`https://player.vimeo.com/video/${(o=e.split("vimeo.com/")[1])==null?void 0:o.split("&")[0]}`;if(e.includes("wistia"))return`https://fast.wistia.net/embed/iframe/${(r=e.split("wistia.com/medias/")[1])==null?void 0:r.split("&")[0]}`;throw new Error("Could not map videoUri to a known provider (Youtube, Vimeo, Wistia).")}function Te(r){var n=r,{part:e,src:t}=n,o=p(n,["part","src"]);let l=wt(t);return _jsxruntime.jsx.call(void 0, m,a({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"gray100",borderWidth:0,part:["video",e],src:l},o))}function X(r){var n=r,{src:e,type:t}=n,o=p(n,["src","type"]);return _jsxruntime.jsx.call(void 0, t==="video"?Te:Be,a({src:e},o))}function Ce({props:e,alignAttr:t,sideAttr:o}){let r=o!=null?o:"bottom",n={},l=()=>{var f;if(["after","before"].includes(e.align)){if(t=="start")return"before";if(t=="end")return"after"}return(f=e.align)!=null?f:"after"},s="-24px",d={top:"bottom",right:"left",bottom:"top",left:"right"};n[d[r]]=s;let c=l();return["before","end"].includes(c)?["top","bottom"].includes(r)?n.right=s:n.bottom=s:["after","start"].includes(c)?["top","bottom"].includes(r)?n.left=s:n.top=s:["top","bottom"].includes(r)?n.left=`calc(50% + ${s})`:n.top=`calc(50% + ${s})`,n}var ve={content:["align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","forceMount","hideWhenDetached","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onInteractOutside","onOpenAutoFocus","onPointerDownOutside","side","sideOffset","sticky"],root:["defaultOpen","modal","onOpenChange","open"]};function Re(e,t){var n,l,s,d,c;let o=Object.fromEntries(ve.content.map(f=>[f,e[f]]).filter(f=>f[1]!==void 0)),r=Object.fromEntries(ve.root.map(f=>[f,e[f]]).filter(f=>f[1]!==void 0));if(o.align=(n=o.align)!=null?n:"after",o.side=(l=o.side)!=null?l:"bottom",["before","after"].includes(o.align)){let f={after:"end",before:"start"},h=(H,V)=>["top","bottom"].includes(V)?H=="after"?"marginLeft":"marginRight":H=="after"?"marginTop":"marginBottom",y=(s=o.alignOffset)!=null?s:0,v=(d=o.style)!=null?d:{},B=(c=o.side)!=null?c:"bottom",A=o.align;o.style=u(a({},v),{[h(A,B)]:y});let D=["top","bottom"].includes(B)?t.width:t.height;o.alignOffset=(D+y)*-1,o.align=f[A]}return{contentProps:o,rootProps:r}}function x(s){var d=s,{anchor:e,children:t,css:o,spotlight:r=!1,style:n}=d,l=p(d,["anchor","children","css","spotlight","style"]);let{node:c,rect:f,ref:h}=he(),{contentProps:y,rootProps:v}=Re(l,f),[B,A]=_react.useState.call(void 0, y.align),[D,H]=_react.useState.call(void 0, y.side);if(c!==null){let S=c.getAttribute("data-align"),Y=c.getAttribute("data-side");B!==S&&A(S),D!==Y&&H(Y)}let V=_react.useRef.call(void 0, null),[W,ke]=_react.useState.call(void 0, null);if(_react.useEffect.call(void 0, ()=>{let S=document.querySelector(e);S!=null&&(V.current=S,ke(V))},[e]),W==null)return null;let M=W.current.getBoundingClientRect(),Q="0";typeof window!="undefined"&&(Q=window.getComputedStyle(W.current).borderRadius);let Oe=Ce({props:l,alignAttr:B,sideAttr:D});return _jsxruntime.jsxs.call(void 0, w.Root,u(a({defaultOpen:!0},v),{children:[_jsxruntime.jsx.call(void 0, w.Anchor,{virtualRef:W}),_jsxruntime.jsx.call(void 0, w.Portal,{children:_jsxruntime.jsxs.call(void 0, "div",{css:o,children:[r&&_jsxruntime.jsx.call(void 0, m,{borderRadius:Q,part:"tooltip-spotlight",position:"absolute",css:{boxShadow:"0 0 0 2000px rgb(0 0 0 / 0.5)",height:M.height,left:M.left,top:M.top,width:M.width}}),_jsxruntime.jsx.call(void 0, w.Content,u(a({asChild:!0},y),{ref:h,children:_jsxruntime.jsxs.call(void 0, R.Column,{backgroundColor:"white",borderRadius:"md",p:5,part:"tooltip-content",position:"relative",css:a({boxShadow:"0px 4px 20px rgba(0, 0, 0, 0.1)",width:"300px"},n),children:[_jsxruntime.jsx.call(void 0, we,{style:Oe}),t]})}))]})})]}))}x.Close=o=>{var r=o,{css:e}=r,t=p(r,["css"]);return _jsxruntime.jsx.call(void 0, w.Close,{"aria-label":"Close",asChild:!0,children:_jsxruntime.jsx.call(void 0, E.Plain,u(a({css:[{top:0,right:0},e],part:"tooltip-close",position:"absolute"},t),{children:_jsxruntime.jsx.call(void 0, _solid.XMarkIcon,{height:"20",fill:"currentColor"})}))})};x.Media=o=>{var r=o,{src:e}=r,t=p(r,["src"]);return e==null?null:_jsxruntime.jsx.call(void 0, X,a({borderRadius:"md md 0 0",borderWidth:"0",css:{aspectRatio:"2"},margin:"-5 -5 5",src:e},t))};x.Primary=r=>{var n=r,{onClick:e,title:t}=n,o=p(n,["onClick","title"]);return t==null?null:_jsxruntime.jsx.call(void 0, E.Primary,a({title:t,onClick:e},o))};x.Progress=o=>{var r=o,{children:e}=r,t=p(r,["children"]);return e==null?null:_jsxruntime.jsx.call(void 0, T.Body2,u(a({fontWeight:"demibold",part:"progress"},t),{children:e}))};x.Secondary=r=>{var n=r,{onClick:e,title:t}=n,o=p(n,["onClick","title"]);return t==null?null:_jsxruntime.jsx.call(void 0, E.Secondary,a({title:t,onClick:e},o))};x.Subtitle=o=>{var r=o,{children:e}=r,t=p(r,["children"]);return e==null?null:_jsxruntime.jsx.call(void 0, T.Body2,u(a({part:"subtitle"},t),{children:e}))};x.Title=o=>{var r=o,{children:e}=r,t=p(r,["children"]);return e==null?null:_jsxruntime.jsx.call(void 0, T.Body1,u(a({fontWeight:"bold",mb:1,part:"title"},t),{children:e}))};var _js = require('@frigade/js');function Se(e){let[t,o]=_react.useState.call(void 0, null),{apiKey:r,config:n}=_react.useContext.call(void 0, _);function l(){return k(this,null,function*(){let s=Object.fromEntries(Object.entries(n).filter(([f,h])=>["apiUrl","userId"].includes(f)&&h!=null)),c=yield(yield new (0, _js.Frigade)(r,s)).getFlow(e);o(c)})}return t===null&&l(),{flow:t,fetchFlow:l}}function Ft(o){var r=o,{flowId:e}=r,t=p(r,["flowId"]);var h;let{flow:n,fetchFlow:l}=Se(e);if(n==null||n!=null&&n.isCompleted||n!=null&&n.isSkipped)return null;n.start();let s=n.getCurrentStep();s==null||s.start();function d(){return k(this,null,function*(){yield n.skip(),l()})}function c(){return k(this,null,function*(){yield s.complete(),l()})}let f=c;return _jsxruntime.jsxs.call(void 0, x,u(a({anchor:s.selector,onOpenAutoFocus:y=>y.preventDefault(),onPointerDownOutside:y=>y.preventDefault()},t),{children:[_jsxruntime.jsx.call(void 0, x.Close,{onClick:d}),_jsxruntime.jsx.call(void 0, x.Media,{src:(h=s.videoUri)!=null?h:s.imageUri,type:s.videoUri?"video":"image"}),_jsxruntime.jsx.call(void 0, x.Title,{children:s.title}),_jsxruntime.jsx.call(void 0, x.Subtitle,{children:s.subtitle}),_jsxruntime.jsxs.call(void 0, R.Row,{pt:4,alignItems:"center",justifyContent:"space-between",children:[_jsxruntime.jsx.call(void 0, x.Progress,{children:`${n.getNumberOfCompletedSteps()}/${n.steps.size}`}),_jsxruntime.jsxs.call(void 0, R.Row,{gap:3,children:[_jsxruntime.jsx.call(void 0, x.Secondary,{title:s.secondaryButtonTitle,onClick:f}),_jsxruntime.jsx.call(void 0, x.Primary,{title:s.primaryButtonTitle,onClick:c})]})]})]}))}exports.Box = m; exports.Button = E; exports.Flex = R; exports.Provider = ut; exports.Text = T; exports.Tooltip = x; exports.Tour = Ft;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var T = require('@radix-ui/react-dialog');
|
|
4
|
+
var solid = require('@heroicons/react/24/solid');
|
|
5
|
+
var ge = require('react');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
var Do = require('known-css-properties');
|
|
8
|
+
var $o = require('dompurify');
|
|
9
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
10
|
+
var react = require('@emotion/react');
|
|
11
|
+
var js = require('@frigade/js');
|
|
12
|
+
var reactHookForm = require('react-hook-form');
|
|
13
|
+
var K = require('@radix-ui/react-radio-group');
|
|
14
|
+
var P = require('@radix-ui/react-select');
|
|
15
|
+
var outline = require('@heroicons/react/24/outline');
|
|
16
|
+
var v = require('@radix-ui/react-popover');
|
|
17
|
+
|
|
18
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
|
|
20
|
+
function _interopNamespace(e) {
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
if (e) {
|
|
24
|
+
Object.keys(e).forEach(function (k) {
|
|
25
|
+
if (k !== 'default') {
|
|
26
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return e[k]; }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
n.default = e;
|
|
35
|
+
return Object.freeze(n);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var T__namespace = /*#__PURE__*/_interopNamespace(T);
|
|
39
|
+
var ge__namespace = /*#__PURE__*/_interopNamespace(ge);
|
|
40
|
+
var Do__default = /*#__PURE__*/_interopDefault(Do);
|
|
41
|
+
var $o__default = /*#__PURE__*/_interopDefault($o);
|
|
42
|
+
var K__namespace = /*#__PURE__*/_interopNamespace(K);
|
|
43
|
+
var P__namespace = /*#__PURE__*/_interopNamespace(P);
|
|
44
|
+
var v__namespace = /*#__PURE__*/_interopNamespace(v);
|
|
45
|
+
|
|
46
|
+
var Ro=Object.defineProperty;var wo=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,t)=>(typeof require<"u"?require:o)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var oe=(e,o)=>{for(var t in o)Ro(e,t,{get:o[t],enumerable:!0});};var Pe={borders:{md:"1px solid"},borderWidths:{0:"0",md:"1px"}};var Ce={black:"#000000",gray100:"#14161A",gray200:"#181B20",gray300:"#1F2329",gray400:"#2E343D",gray500:"#4C5766",gray600:"#5A6472",gray700:"#C5CBD3",gray800:"#E2E5E9",gray900:"#F1F2F4",white:"#ffffff",blue400:"#015AC6",blue500:"#0171F8",blue800:"#DBECFF",blue900:"#F5F9FF",green400:"#009E37",green500:"#00D149",green800:"#DBFFE8",transparent:"#FFFFFF00",inherit:"inherit",red500:"#c00000"};var Se={md:"10px",lg:"20px",round:"50%"};var l=e=>`var(--fr-colors-${e})`,Fe={neutral:{background:l("white"),border:l("gray800"),foreground:l("black"),surface:l("gray700"),active:{background:l("white"),border:l("gray900"),foreground:l("black"),surface:l("gray700")},focus:{background:l("white"),border:l("gray900"),foreground:l("black"),surface:l("gray700")},hover:{background:l("white"),border:l("gray900"),foreground:l("black"),surface:l("gray700")}},primary:{background:l("blue500"),border:l("blue500"),foreground:l("white"),surface:l("blue500"),active:{background:l("blue400"),border:l("blue400"),foreground:l("white"),surface:l("blue400")},focus:{background:l("blue500"),border:l("blue500"),foreground:l("white"),surface:l("blue500")},hover:{background:l("blue400"),border:l("blue400"),foreground:l("white"),surface:l("blue400")}},secondary:{background:l("white"),border:l("gray800"),foreground:l("black"),surface:l("gray900"),active:{background:l("gray900"),border:l("gray800"),foreground:l("black"),surface:l("gray800")},focus:{background:l("gray900"),border:l("gray800"),foreground:l("black"),surface:l("gray900")},hover:{background:l("gray900"),border:l("gray800"),foreground:l("black"),surface:l("gray800")}}};var Te={md:"0px 4px 20px rgba(0, 0, 0, 0.1)"};var vo="px",ko=e=>typeof e=="number"?`${4*e}${vo}`:e,Eo=[-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,-.5,0,.5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,"auto"],Be=Object.fromEntries(Eo.map(e=>[e,ko(e)]));var Re={fontFamilies:{default:"TT Interphases Pro, sans-serif"},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px",xl:"20px","2xl":"24px","3xl":"30px","4xl":"36px","5xl":"48px"},fontWeights:{thin:"100",extralight:"200",light:"300",regular:"400",medium:"500",demibold:"600",bold:"700",extrabold:"800",black:"900"},letterSpacings:{md:"0.02em"},lineHeights:{xs:"18px",sm:"22px",md:"24px",lg:"26px",xl:"30px","2xl":"38px","3xl":"46px","4xl":"60px"}};var de={...Pe,colors:{...Ce,...Fe},...Re,radii:Se,shadows:Te,space:Be};function U(e,o="",t="."){return Object.keys(e).reduce((n,r)=>{let s=`${o.length?`${o}${t}`:""}${r}`,a=e[r];return typeof a=="object"&&a!==null&&!Array.isArray(a)?Object.assign(n,U(a,s,t)):n[s]=a,n},{})}function me(e){return U(e,"--fr","-")}function we(e,o="--fr"){let t={};return Object.keys(e).forEach(n=>{let r=e[n];typeof r=="object"&&r!==null&&!Array.isArray(r)?t[n]=we(r,`${o}-${n}`):t[n]=`var(${o}-${n})`;}),t}var ve=me(de),c=we(de);var Mo=new Set(["alt","size","src"]),Oo=Do__default.default.all.filter(e=>e.indexOf("-")!=0&&!Mo.has(e)).map(e=>[e.replace(/-([a-z])/g,(o,t)=>t.toUpperCase()),null]),Ho=Object.fromEntries(Oo),ce=U(c.colors),Io={color:ce,backgroundColor:ce,borderColor:ce,border:c.borders,borderRadius:c.radii,borderWidth:c.borderWidths,boxShadow:c.shadows,fontFamily:c.fontFamilies,fontSize:c.fontSizes,fontWeight:c.fontWeights,gap:c.space,lineHeight:c.lineHeights,margin:c.space,marginBottom:c.space,marginLeft:c.space,marginRight:c.space,marginTop:c.space,padding:c.space,paddingBottom:c.space,paddingLeft:c.space,paddingRight:c.space,paddingTop:c.space},ke={...Ho,...Io},Ee={bg:["backgroundColor"],m:["margin"],mt:["marginTop"],mr:["marginRight"],mb:["marginBottom"],ml:["marginLeft"],mx:["marginLeft","marginRight"],my:["marginTop","marginBottom"],p:["padding"],pt:["paddingTop"],pr:["paddingRight"],pb:["paddingBottom"],pl:["paddingLeft"],px:["paddingLeft","paddingRight"],py:["paddingTop","paddingBottom"]},De=new Set(["active","focus","focusVisible","focusWithin","hover"]);function Ao(e){return Array.isArray(e)?new Map(e.map(o=>[o,o])):typeof e=="object"&&e!==null?new Map(Object.entries(e)):typeof e=="string"||typeof e=="number"?new Map([[e,e]]):new Map}var Me=new Map(Object.entries(ke).map(([e,o])=>[e,Ao(o)])),Vo=new Map(Object.entries(Ee).map(([e,o])=>[e,new Set(o)])),Lo=new Set(["height","width"]),Wo=new Set(["canvas","embed","iframe","img","input","object","video"]);function Oe(e){let[o,t]=e.split(":");return [o,De.has(t)?t:null]}function He(e,o="div"){let t=Object.assign({},e),n={};function r(i){if(i==null)return n;let a=`&:${i.replace(/[A-Z]/g,m=>`-${m.toLocaleLowerCase()}`)}`;return n[a]==null&&(n[a]={}),n[a]}return Object.entries(t).forEach(([i,s])=>{let[a,m]=Oe(i),f=Vo.get(a);f!=null&&(f.forEach(u=>{let S=`${u}${m?":"+m:""}`;t[S]=s;}),delete t[i]);}),Object.entries(t).forEach(([i,s])=>{let[a,m]=Oe(i),f=Me.get(a);if(f!=null){if(typeof s=="string"&&s.indexOf(" ")>-1){let u=s.split(" ");r(m)[a]=u.map(S=>f.get(S.toString())??S).join(" ");}else f.has(s.toString())?r(m)[a]=f.get(s.toString()):r(m)[a]=s;(typeof o!="string"||!Wo.has(o)||!Lo.has(a))&&delete t[i];}}),Object.keys(t).forEach(i=>{let s=i.substring(1);i.indexOf("_")===0&&Me.has(s)&&(t[s]=t[i],delete t[i]);}),{cssFromProps:n,unmatchedProps:t}}function zo(){if(typeof window>"u"){let{JSDOM:e}=wo("jsdom");return new e("<!DOCTYPE html>").window}return window}function Ie(e){return e?{__html:$o__default.default(zo()).sanitize(e,{ALLOWED_TAGS:["b","i","a","span","div","p","pre","u","br","img","code","li","ul","table","tbody","thead","tr","td","th","h1","h2","h3","h4","video"],ALLOWED_ATTR:["style","class","target","id","href","alt","src","controls","autoplay","loop","muted"]})}:{__html:""}}function Ko(e){return e&&`fr-${e}`}function Le(e){return e&&(Array.isArray(e)?e.map(o=>Le(o)).join(" "):Ko(e))}function No({as:e,children:o,className:t,css:n={},part:r,...i},s){let a=e??"div",{cssFromProps:m,unmatchedProps:f}=He(i,a),u=Le(r),S=t||u?clsx.clsx(t,u):void 0,k=[{boxSizing:"border-box"},m,n];return typeof o=="string"?jsxRuntime.jsx(a,{className:S,css:k,...f,ref:s,dangerouslySetInnerHTML:Ie(o)}):jsxRuntime.jsx(a,{className:S,css:k,...f,ref:s,children:o})}var p=ge__namespace.forwardRef(No);var d={};oe(d,{Body1:()=>st,Body2:()=>lt,Caption:()=>pt,Display1:()=>ot,Display2:()=>tt,H1:()=>rt,H2:()=>nt,H3:()=>it,H4:()=>at});var ue={};oe(ue,{Body1:()=>Yo,Body2:()=>Qo,Caption:()=>Zo,Display1:()=>jo,Display2:()=>Uo,H1:()=>Xo,H2:()=>Jo,H3:()=>Go,H4:()=>qo});var E={color:"neutral.foreground",fontFamily:"default",margin:"0"},jo={...E,fontSize:"5xl",fontWeight:"bold",lineHeight:"4xl"},Uo={...E,fontSize:"4xl",fontWeight:"bold",lineHeight:"3xl"},Xo={...E,fontSize:"3xl",fontWeight:"bold",lineHeight:"2xl"},Jo={...E,fontSize:"2xl",fontWeight:"bold",lineHeight:"xl"},Go={...E,fontSize:"xl",fontWeight:"bold",lineHeight:"lg"},qo={...E,fontSize:"lg",fontWeight:"bold",lineHeight:"md"},Yo={...E,fontSize:"md",fontWeight:"regular",lineHeight:"md"},Qo={...E,fontSize:"sm",fontWeight:"regular",lineHeight:"md"},Zo={...E,fontSize:"xs",fontWeight:"regular",lineHeight:"sm"};var et=["Display1","Display2","H1","H2","H3","H4","Body1","Body2","Caption"],D=Object.fromEntries(et.map(e=>{let o=["H1","H2","H3","H4"].includes(e)?e.toLowerCase():"span",t=ge__namespace.forwardRef(({as:n=o,children:r,...i},s)=>jsxRuntime.jsx(p,{as:n,...ue[e],...i,ref:s,children:r}));return t.displayName=`Text.${e}`,[e,t]})),ot=D.Display1,tt=D.Display2,rt=D.H1,nt=D.H2,it=D.H3,at=D.H4,st=D.Body1,lt=D.Body2,pt=D.Caption;var fe={};oe(fe,{Link:()=>ut,Plain:()=>ft,Primary:()=>mt,Secondary:()=>ct});var te={borderWidth:"0",borderRadius:"md",display:"flex",gap:"2",padding:"2 4"},mt={...te,backgroundColor:"primary.surface",color:"primary.foreground","backgroundColor:hover":"primary.hover.surface"},ct={...te,backgroundColor:"secondary.background",borderColor:"secondary.border",borderStyle:"solid",borderWidth:"1px",color:"secondary.foreground","backgroundColor:hover":"secondary.hover.background"},ut={...te,backgroundColor:"transparent",color:"primary.surface","color:hover":"primary.hover.surface"},ft={...te,backgroundColor:"transparent",color:"neutral.foreground"};function $e({as:e,children:o,part:t,title:n,variant:r="Primary",...i}){let s=r.toLocaleLowerCase();return jsxRuntime.jsxs(p,{as:e??"button",part:[`button-${s}`,t],...fe[r],...i,children:[o,n&&jsxRuntime.jsx(d.Body2,{flexGrow:"1",fontWeight:"demibold",color:"inherit",children:n})]})}var gt=["Primary","Secondary","Link","Plain"],xt=Object.fromEntries(gt.map(e=>{let o=t=>jsxRuntime.jsx($e,{...t,variant:e,children:t.children});return o.displayName=`Text.${e}`,[e,o]})),g=Object.assign($e,xt);var x={};oe(x,{Column:()=>bt,Row:()=>ht});var ht=ge__namespace.forwardRef(({children:e,css:o,...t},n)=>jsxRuntime.jsx(p,{css:[{display:"flex",flexDirection:"row"},o],...t,ref:n,children:e})),bt=ge__namespace.forwardRef(({children:e,css:o,...t},n)=>jsxRuntime.jsx(p,{css:[{display:"flex",flexDirection:"column"},o],...t,ref:n,children:e}));var M=ge.createContext({apiKey:"",modals:new Set,setModals:()=>{},currentModal:null,navigate:()=>{}});function wt({children:e,navigate:o,theme:t,...n}){let r=t?me(t):{},[i,s]=ge.useState(new Set),a=ge.useMemo(()=>new js.Frigade(n.apiKey,{apiKey:n.apiKey,apiUrl:n.apiUrl,userId:n.userId,groupId:n.groupId,__readOnly:n.__readOnly,__flowConfigOverrides:n.__flowConfigOverrides}),[n.userId,n.groupId,n.apiKey]),m=o??((u,S="_self")=>{window.open(u,S);});ge.useEffect(()=>()=>{a.destroy();},[]);let f=i.size>0?i.values().next().value:null;return jsxRuntime.jsxs(M.Provider,{value:{modals:i,setModals:s,currentModal:f,navigate:m,...n,frigade:a},children:[jsxRuntime.jsx(react.Global,{styles:{":root":{...ve,...r}}}),jsxRuntime.jsx(react.ThemeProvider,{theme:c,children:e})]})}function X(e,o){let[t,n]=ge.useState(),[,r]=ge.useState(""),{frigade:i}=ge.useContext(M),s=a=>{a.id===e&&(o!=null&&o.variables&&a.applyVariables(o.variables),n(a),r(Math.random().toString()));};return ge.useEffect(()=>((async()=>{let a=await i.getFlow(e);if(!a||i.hasFailedToLoad()){n(void 0);return}o!=null&&o.variables&&a.applyVariables(o.variables),n(a);})(),i.onStateChange(s),()=>{i.removeStateChangeHandler(s);}),[]),{flow:t}}function V(e,{onComplete:o,onDismiss:t}={}){let n=ge.useRef(null);return ge.useEffect(()=>{e!=null&&(e.isCompleted&&n.current===!1&&(async()=>await(o==null?void 0:o(e)))(),n.current=e==null?void 0:e.isCompleted);},[e==null?void 0:e.isCompleted]),{handleDismiss:ge.useCallback(async r=>{if(await(t==null?void 0:t(e,r))===!1)return r.preventDefault(),!1;await e.skip();},[e])}}function J(e,{onPrimary:o,onSecondary:t}={}){let{navigate:n}=ge.useContext(M);return {handlePrimary:ge.useCallback(async r=>{if(await(o==null?void 0:o(e,r))===!1)return r.preventDefault(),!1;await e.complete(),e.primaryButtonUri!=null&&n(e.primaryButtonUri,e.primaryButtonUriTarget);},[e]),handleSecondary:ge.useCallback(async r=>{if(await(t==null?void 0:t(e,r))===!1)return r.preventDefault(),!1;await e.complete(),e.secondaryButtonUri!=null&&n(e.secondaryButtonUri,e.secondaryButtonUriTarget);},[e])}}function G(e){let{currentModal:o,modals:t,setModals:n}=ge.useContext(M),[r,i]=ge.useState(!1);ge.useEffect(()=>{e!=null&&e.isVisible&&e&&!t.has(e.id)&&n(a=>new Set(a).add(e.id));},[e==null?void 0:e.id,e==null?void 0:e.isVisible]),ge.useEffect(()=>{let a=o===(e==null?void 0:e.id);(e==null?void 0:e.id)!=null&&a!==r&&i(a);},[e==null?void 0:e.id,o]);function s(){t.has(e==null?void 0:e.id)&&n(a=>{let m=new Set(a);return m.delete(e==null?void 0:e.id),m});}return {isCurrentModal:r,removeModal:s}}function Wt(e){return jsxRuntime.jsx(g.Plain,{part:"close",position:"absolute",right:"-4px",top:"4px",...e,children:jsxRuntime.jsx(solid.XMarkIcon,{height:"24",fill:"currentColor"})})}function H({as:e,container:o,dismissible:t=!0,flowId:n,onComplete:r,onDismiss:i,onPrimary:s,onSecondary:a,variables:m,...f}){let u=o==="dialog"?F:e??p,S=u.Close??Wt;return {FlowComponent:function({children:Y,...se}){let{flow:h}=X(n,{variables:m}),N=h==null?void 0:h.getCurrentStep(),{handleDismiss:Q}=V(h,{onComplete:r,onDismiss:i}),{handlePrimary:le,handleSecondary:pe}=J(N,{onPrimary:s,onSecondary:a}),{isCurrentModal:j,removeModal:Z}=G(h);return ge.useEffect(()=>{!(h!=null&&h.isVisible)&&j&&Z();},[h==null?void 0:h.isVisible,j]),h==null||!h.isVisible||!j?null:(h.start(),N.start(),jsxRuntime.jsxs(u,{position:"relative",...se,...f,children:[t&&jsxRuntime.jsx(S,{onClick:Q}),Y({flow:h,handleDismiss:Q,handlePrimary:le,handleSecondary:pe,step:N})]}))}}}function Je(e){let{FlowComponent:o}=H(e);return jsxRuntime.jsx(o,{as:y,gap:5,children:({handlePrimary:t,handleSecondary:n,step:r})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(y.Title,{children:r.title}),jsxRuntime.jsx(y.Subtitle,{children:r.subtitle}),jsxRuntime.jsx(y.Media,{src:r.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxRuntime.jsxs(x.Row,{gap:3,justifyContent:"flex-end",children:[jsxRuntime.jsx(y.Secondary,{title:r.secondaryButtonTitle,onClick:n}),jsxRuntime.jsx(y.Primary,{title:r.primaryButtonTitle??"Continue",onClick:t})]})]})})}function Ge({part:e,src:o,...t}){return jsxRuntime.jsx(p,{as:"img",part:["image",e],src:o,...t})}function Kt(e){var o,t,n;if(e.includes("youtube"))return `https://www.youtube.com/embed/${(o=e.split("v=")[1])==null?void 0:o.split("&")[0]}`;if(e.includes("vimeo"))return `https://player.vimeo.com/video/${(t=e.split("vimeo.com/")[1])==null?void 0:t.split("&")[0]}`;if(e.includes("wistia"))return `https://fast.wistia.net/embed/iframe/${(n=e.split("wistia.com/medias/")[1])==null?void 0:n.split("&")[0]}`;throw new Error("Could not map videoUri to a known provider (Youtube, Vimeo, Wistia).")}function qe({part:e,src:o,...t}){let n=Kt(o);return jsxRuntime.jsx(p,{allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"gray100",borderWidth:0,part:["video",e],src:n,...t})}function L({src:e,type:o,...t}){return jsxRuntime.jsx(o==="video"?qe:Ge,{src:e,...t})}var y=ge__namespace.forwardRef(({as:e,children:o,...t},n)=>{if(t.flowId!=null)return jsxRuntime.jsx(Je,{as:e,...t});let r=e??x.Column;return jsxRuntime.jsx(r,{backgroundColor:"neutral.background",borderRadius:"md",gap:5,p:5,...t,ref:n,children:o})});y.Media=({src:e,...o})=>e==null?null:jsxRuntime.jsx(L,{borderRadius:"md",src:e,...o});y.Primary=({onClick:e,title:o,...t})=>o==null?null:jsxRuntime.jsx(g.Primary,{title:o,onClick:e,...t});y.Secondary=({onClick:e,title:o,...t})=>o==null?null:jsxRuntime.jsx(g.Secondary,{title:o,onClick:e,...t});y.Subtitle=({children:e,...o})=>e==null?null:jsxRuntime.jsx(d.Body2,{display:"block",part:"subtitle",mt:1,...o,children:e});y.Title=({children:e,...o})=>e==null?null:jsxRuntime.jsx(d.Body1,{display:"block",fontWeight:"bold",part:"title",...o,children:e});function F({children:e,...o}){return jsxRuntime.jsx(T__namespace.Root,{defaultOpen:!0,modal:!0,children:jsxRuntime.jsx(T__namespace.Portal,{children:jsxRuntime.jsxs(p,{inset:"0",position:"fixed",zIndex:"9999",children:[jsxRuntime.jsx(T__namespace.Overlay,{asChild:!0,children:jsxRuntime.jsx(p,{background:"rgb(0 0 0 / 0.5)",part:"dialog-overlay",position:"fixed",inset:"0"})}),jsxRuntime.jsx(T__namespace.Content,{asChild:!0,onOpenAutoFocus:t=>t.preventDefault(),onPointerDownOutside:t=>t.preventDefault(),children:jsxRuntime.jsx(y,{boxShadow:"md",left:"50%",maxWidth:"430px",p:8,part:"dialog-content",position:"fixed",textAlign:"center",top:"50%",transform:"translate(-50%, -50%)",...o,children:e})})]})})})}F.Close=e=>jsxRuntime.jsx(T__namespace.Close,{"aria-label":"Close",asChild:!0,children:jsxRuntime.jsx(g.Plain,{part:"close",position:"absolute",right:"-4px",top:"4px",...e,children:jsxRuntime.jsx(solid.XMarkIcon,{height:"24",fill:"currentColor"})})});F.Subtitle=({children:e,...o})=>jsxRuntime.jsx(T__namespace.Description,{asChild:!0,children:jsxRuntime.jsx(d.Body2,{mb:5,part:"subtitle",...o,children:e})});F.Media=({src:e,...o})=>e==null?null:jsxRuntime.jsx(L,{borderRadius:"md",src:e,...o});F.Primary=({onClick:e,title:o,...t})=>o==null?null:jsxRuntime.jsx(g.Primary,{title:o,onClick:e,...t});F.ProgressDots=({current:e,total:o})=>{if(o==1)return null;let t=[...Array(o)].map((n,r)=>jsxRuntime.jsx("circle",{r:4,cx:4+16*r,cy:"4px",fill:e===r?c.colors.blue500:c.colors.blue800},r));return jsxRuntime.jsx(p,{as:"svg",height:"8px",margin:"5 auto",part:"progress",viewBox:`0 0 ${16*o-8} 8`,width:16*o-8,children:t})};F.Secondary=({onClick:e,title:o,...t})=>o==null?null:jsxRuntime.jsx(g.Secondary,{title:o,onClick:e,...t});F.Title=({children:e,...o})=>jsxRuntime.jsx(T__namespace.Title,{asChild:!0,children:jsxRuntime.jsx(d.H3,{mb:1,part:"title",...o,children:e})});function Jt(e){let{FlowComponent:o}=H({...e,container:"dialog"});return jsxRuntime.jsx(o,{children:({flow:t,handlePrimary:n,handleSecondary:r,step:i})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(F.Title,{children:i.title}),jsxRuntime.jsx(F.Subtitle,{children:i.subtitle}),jsxRuntime.jsx(F.Media,{src:i.imageUri,css:{aspectRatio:"1.5",objectFit:"cover",width:"100%"}}),jsxRuntime.jsx(F.ProgressDots,{current:t.getNumberOfCompletedSteps(),total:t.getNumberOfAvailableSteps()}),jsxRuntime.jsxs(x.Row,{css:{"& > button":{flexGrow:1}},gap:3,children:[i.secondaryButtonTitle&&jsxRuntime.jsx(F.Secondary,{title:i.secondaryButtonTitle,onClick:r}),jsxRuntime.jsx(F.Primary,{title:i.primaryButtonTitle??"Continue",onClick:n})]})]})})}function Yt(e){let{FlowComponent:o}=H(e);return jsxRuntime.jsx(o,{as:y,border:"md",borderColor:"gray900",display:"flex",flexDirection:"row",gap:3,justifyContent:"space-between",children:({handleDismiss:t,handlePrimary:n,handleSecondary:r,step:i})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(x.Row,{gap:3,children:[i.imageUri&&jsxRuntime.jsx("img",{src:i.imageUri,style:{height:40,width:40,alignSelf:"center"}}),jsxRuntime.jsxs(x.Column,{children:[jsxRuntime.jsx(d.H4,{mb:1,children:i.title}),jsxRuntime.jsx(d.Body2,{children:i.subtitle})]})]}),jsxRuntime.jsxs(x.Row,{alignItems:"center",gap:3,justifyContent:"center",children:[i.secondaryButtonTitle&&jsxRuntime.jsx(g.Secondary,{title:i.secondaryButtonTitle,onClick:r}),jsxRuntime.jsx(g.Primary,{title:i.primaryButtonTitle,onClick:n}),e.dismissible&&e.container!="dialog"&&jsxRuntime.jsx(g.Plain,{part:"banner-close",onClick:t,children:jsxRuntime.jsx(solid.XMarkIcon,{height:"24",fill:"currentColor"})})]})]})})}var or=new Set(["required","min","max","minLength","maxLength","pattern"]);function tr({fieldComponent:e,control:o,fieldData:t}){t.pattern!=null&&(typeof t.pattern=="string"?t.pattern=new RegExp(t.pattern.replace(/^\/|\/$/g,"")):typeof t.pattern=="object"&&typeof t.pattern.value=="string"&&(t.pattern.value=new RegExp(t.pattern.value.replace(/^\/|\/$/g,""))));let n=Object.fromEntries(Object.entries(t).filter(([i])=>or.has(i))),r=reactHookForm.useController({name:t.id,control:o,rules:n});return jsxRuntime.jsx(e,{...r,fieldData:t})}function Ze({fieldTypes:e,step:o}){var s;let{control:t,handleSubmit:n}=reactHookForm.useForm({delayError:2e3,mode:"onChange"}),r=[];function i(a){o.complete(a);}return (s=o.fields)==null||s.forEach(a=>{e[a.type]!=null&&r.push(jsxRuntime.jsx(tr,{control:t,fieldComponent:e[a.type],fieldData:a},a.id));}),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,jsxRuntime.jsx(x.Row,{justifyContent:"flex-end",children:jsxRuntime.jsx(g.Primary,{title:o.primaryButtonTitle??"Submit",onClick:n(i)})},"form-footer")]})}function eo({error:e}){var o;return (o=e==null?void 0:e.message)!=null&&o.length?jsxRuntime.jsx(d.Caption,{color:"red500",display:"block",part:"field-error",textAlign:"end",children:e==null?void 0:e.message}):null}function oo({children:e,id:o,required:t=!1}){return jsxRuntime.jsxs(d.Body2,{as:"label",htmlFor:o,fontWeight:"demibold",part:"field-label",children:[e,t&&" *"]})}var to={marginBottom:"5"},q={px:"4",py:"2",backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",borderRadius:"md",display:"block",outline:"none",width:"100%"};function A({children:e,field:o,fieldData:t,fieldState:n}){let{id:r,label:i,placeholder:s}=t,{error:a}=n,m={id:r,...o,...s?{placeholder:s}:{},...q,"aria-invalid":!!a,value:o.value??""};return jsxRuntime.jsxs(p,{...to,part:"field",children:[jsxRuntime.jsx(oo,{id:r,required:!!t.required,children:i}),e(m),jsxRuntime.jsx(eo,{error:a})]})}var lr=()=>jsxRuntime.jsx(p,{as:"svg",color:"primary.foreground",width:"10px",height:"8px",viewBox:"0 0 10 8",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 4.34664L3.4618 6.99729L3.4459 6.98017L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),pr=ge__namespace.forwardRef(({label:e,value:o},t)=>jsxRuntime.jsxs(p,{as:"label",htmlFor:o,display:"flex",justifyContent:"space-between",part:"field-radio",px:4,py:2,borderWidth:"md",borderStyle:"solid",borderColor:"neutral.border",borderRadius:"md",children:[jsxRuntime.jsx(d.Body2,{part:"field-radio-label",children:e}),jsxRuntime.jsx(K__namespace.Item,{id:o,value:o,ref:t,asChild:!0,children:jsxRuntime.jsx(p,{as:"button",backgroundColor:"neutral.background",borderWidth:"md",borderStyle:"solid",borderColor:"neutral.border",borderRadius:"100%",padding:"0",part:"field-radio-value",position:"relative",height:"24px",width:"24px",children:jsxRuntime.jsx(p,{as:K__namespace.Indicator,alignItems:"center",bg:"primary.surface",borderWidth:"md",borderStyle:"solid",borderColor:"primary.border",borderRadius:"100%",display:"flex",height:"calc(100% + 2px)",justifyContent:"center",left:"-1px",part:"field-radio-indicator",position:"absolute",top:"-1px",width:"calc(100% + 2px)",children:jsxRuntime.jsx(lr,{})})})})]}));function ao(e){let{field:{onChange:o,value:t},fieldData:{options:n=[]}}=e,r=n.map(({label:i,value:s})=>jsxRuntime.jsx(pr,{value:s,label:i},s));return jsxRuntime.jsx(A,{...e,children:()=>jsxRuntime.jsx(K__namespace.Root,{value:t,onValueChange:o,asChild:!0,children:jsxRuntime.jsx(x.Column,{gap:2,part:"field-radio-group",children:r})})})}var cr=ge__namespace.forwardRef(({label:e,value:o},t)=>jsxRuntime.jsx(P__namespace.Item,{value:o,ref:t,asChild:!0,children:jsxRuntime.jsx(p,{"backgroundColor:hover":"blue900",borderRadius:"md",outline:"none",part:"field-select-option",px:"3",py:"2",children:jsxRuntime.jsx(P__namespace.ItemText,{asChild:!0,children:jsxRuntime.jsx(d.Body2,{part:"field-select-option-label",children:e})})})}));function po(e){let{field:{onChange:o,value:t},fieldData:{options:n=[],placeholder:r}}=e,i=n.map(({label:s,value:a})=>jsxRuntime.jsx(cr,{value:a,label:s},a));return jsxRuntime.jsx(A,{...e,children:()=>jsxRuntime.jsxs(P__namespace.Root,{value:t,onValueChange:o,children:[jsxRuntime.jsx(P__namespace.Trigger,{asChild:!0,children:jsxRuntime.jsxs(d.Body2,{...q,alignItems:"center",display:"flex",justifyContent:"space-between",part:"field-select",children:[jsxRuntime.jsx(P__namespace.Value,{placeholder:r??"Select one"}),jsxRuntime.jsx(P__namespace.Icon,{children:jsxRuntime.jsx(p,{as:outline.ChevronDownIcon,color:"gray100",display:"block",height:"24px",part:"field-select-icon",width:"24px"})})]})}),jsxRuntime.jsx(P__namespace.Portal,{children:jsxRuntime.jsx(P__namespace.Content,{position:"popper",sideOffset:4,asChild:!0,children:jsxRuntime.jsx(p,{...q,p:"1",part:"field-select-options",width:"var(--radix-popper-anchor-width)",children:jsxRuntime.jsx(P__namespace.Viewport,{children:i})})})})]})})}function co(e){return jsxRuntime.jsx(A,{...e,children:o=>jsxRuntime.jsx(d.Body2,{as:"input",part:"field-text",type:"text",...o})})}function fo(e){return jsxRuntime.jsx(A,{...e,children:o=>jsxRuntime.jsx(d.Body2,{as:"textarea",part:"field-textarea",...o})})}var ur={radio:ao,select:po,text:co,textarea:fo};function fr({fieldTypes:e={},...o}){let{FlowComponent:t}=H(o),n=Object.assign({},ur,e);return jsxRuntime.jsx(t,{children:({step:r})=>jsxRuntime.jsx(Ze,{fieldTypes:n,step:r,...o})})}function ie(){let e="DOMRect"in globalThis?new DOMRect:{height:0,width:0,x:0,y:0,bottom:0,top:0,right:0,left:0,toJSON:()=>{}},[o,t]=ge.useState(e),[n,r]=ge.useState(null),i=ge.useCallback(s=>{r(s);},[]);return ge.useLayoutEffect(()=>{if(!n)return;let s=()=>{let a=n.getBoundingClientRect();t(a);};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[n]),{node:n,rect:o,ref:i}}var hr=react.keyframes({"0%":{opacity:.5,transform:"scale(0.5)"},"50%":{opacity:0,transform:"scale(1)"},"100%":{opacity:0,transform:"scale(1)"}});function ho({style:e={},part:o="",...t}){return jsxRuntime.jsxs(p,{part:`dot-wrapper ${o}`,style:{height:"48px",position:"absolute",width:"48px",...e},...t,children:[jsxRuntime.jsx(p,{backgroundColor:"primary.surface",part:"dot-pulse",css:{animation:`2s ease-out infinite ${hr}`,borderRadius:"24px",height:"48px",left:0,position:"absolute",top:0,transformOrigin:"center center",width:"48px"}}),jsxRuntime.jsx(p,{backgroundColor:"primary.surface",part:"dot",style:{borderRadius:"12px",height:"24px",left:"12px",position:"absolute",top:"12px",width:"24px"}})]})}function bo({props:e,alignAttr:o,sideAttr:t}){let n=t??"bottom",r={},i=()=>{if(["after","before"].includes(e.align)){if(o=="start")return "before";if(o=="end")return "after"}return e.align??"after"},s="-24px",a={top:"bottom",right:"left",bottom:"top",left:"right"};r[a[n]]=s;let m=i();return ["before","end"].includes(m)?["top","bottom"].includes(n)?r.right=s:r.bottom=s:["after","start"].includes(m)?["top","bottom"].includes(n)?r.left=s:r.top=s:["top","bottom"].includes(n)?r.left=`calc(50% + ${s})`:r.top=`calc(50% + ${s})`,r}var Po={content:["align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","forceMount","hideWhenDetached","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onInteractOutside","onOpenAutoFocus","onPointerDownOutside","side","sideOffset","sticky"],root:["defaultOpen","modal","onOpenChange","open"]};function Co(e,o){let t=Object.fromEntries(Po.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n=Object.fromEntries(Po.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0));if(t.align=t.align??"after",t.side=t.side??"bottom",["before","after"].includes(t.align)){let r={after:"end",before:"start"},i=(S,k)=>["top","bottom"].includes(k)?S=="after"?"marginLeft":"marginRight":S=="after"?"marginTop":"marginBottom",s=t.alignOffset??0,a=t.style??{},m=t.side??"bottom",f=t.align;t.style={...a,[i(f,m)]:s};let u=["top","bottom"].includes(m)?o.width:o.height;t.alignOffset=(u+s)*-1,t.align=r[f];}return {contentProps:t,rootProps:n}}function C({anchor:e,children:o,className:t,spotlight:n=!1,style:r,...i}){let{node:s,rect:a,ref:m}=ie(),{node:f,rect:u,ref:S}=ie(),{contentProps:k,rootProps:he}=Co(i,a),[Y,se]=ge.useState(k.align),[h,N]=ge.useState(k.side),[Q,le]=ge.useState(0),[pe,j]=ge.useState(0);if(s!==null){let O=s.getAttribute("data-align"),ee=s.getAttribute("data-side");Y!==O&&se(O),h!==ee&&N(ee);}let Z=ge.useRef(null);if(ge.useEffect(()=>{let O=document.querySelector(e);O!=null&&(S(O),Z.current=O);},[e]),ge.useEffect(()=>{let{scrollX:O,scrollY:ee}=window;le(u.left+O),j(u.top+ee);},[u.left,u.top]),f==null)return null;let be="0";typeof window<"u"&&(be=window.getComputedStyle(f).borderRadius);let Bo=bo({props:i,alignAttr:Y,sideAttr:h});return jsxRuntime.jsxs(v__namespace.Root,{defaultOpen:!0,...he,children:[jsxRuntime.jsx(v__namespace.Anchor,{virtualRef:Z}),jsxRuntime.jsx(v__namespace.Portal,{children:jsxRuntime.jsxs("div",{className:t,css:{bottom:0,left:0,position:"absolute",right:0,top:0,zIndex:9999},children:[n&&jsxRuntime.jsx(p,{part:"tooltip-spotlight",position:"absolute",style:{borderRadius:be,boxShadow:"0 0 0 20000px rgb(0 0 0 / 0.5)",height:u.height,left:Q,top:pe,width:u.width}}),jsxRuntime.jsx(v__namespace.Content,{asChild:!0,...k,ref:m,children:jsxRuntime.jsxs(y,{boxShadow:"md",part:"tooltip-content",position:"relative",css:{maxWidth:"360px",...r},children:[jsxRuntime.jsx(ho,{style:Bo}),o]})})]})})]})}C.Close=e=>jsxRuntime.jsx(v__namespace.Close,{"aria-label":"Close",asChild:!0,children:jsxRuntime.jsx(g.Plain,{css:{top:"12px",right:"4px"},part:"close",position:"absolute",...e,children:jsxRuntime.jsx(solid.XMarkIcon,{height:"24",fill:"currentColor"})})});C.Media=({src:e,...o})=>e==null?null:jsxRuntime.jsx(L,{borderRadius:"md md 0 0",borderWidth:"0",css:{aspectRatio:"2"},margin:"-5 -5 5",src:e,...o});C.Primary=({onClick:e,title:o,...t})=>o==null?null:jsxRuntime.jsx(g.Primary,{title:o,onClick:e,...t});C.Progress=({children:e,...o})=>e==null?null:jsxRuntime.jsx(d.Body2,{fontWeight:"demibold",part:"progress",...o,children:e});C.Secondary=({onClick:e,title:o,...t})=>o==null?null:jsxRuntime.jsx(g.Secondary,{title:o,onClick:e,...t});C.Subtitle=({children:e,...o})=>e==null?null:jsxRuntime.jsx(d.Body2,{part:"subtitle",...o,children:e});C.Title=({children:e,...o})=>e==null?null:jsxRuntime.jsx(d.Body1,{fontWeight:"bold",mb:1,part:"title",...o,children:e});function To({dismissible:e=!0,flow:o,onDismiss:t,onPrimary:n,onSecondary:r,step:i,...s}){let{handleDismiss:a}=V(o,{onDismiss:t}),{handlePrimary:m,handleSecondary:f}=J(i,{onPrimary:n,onSecondary:r});return jsxRuntime.jsxs(C,{anchor:i.selector,onOpenAutoFocus:u=>u.preventDefault(),onPointerDownOutside:u=>u.preventDefault(),...s,children:[e&&jsxRuntime.jsx(C.Close,{onClick:a}),jsxRuntime.jsx(C.Media,{src:i.videoUri??i.imageUri,type:i.videoUri?"video":"image"}),jsxRuntime.jsx(C.Title,{children:i.title}),jsxRuntime.jsx(C.Subtitle,{children:i.subtitle}),jsxRuntime.jsxs(x.Row,{alignItems:"center",gap:3,justifyContent:"flex-end",part:"tooltip-footer",pt:4,children:[jsxRuntime.jsx(C.Progress,{children:`${o.getNumberOfCompletedSteps()+1}/${o.getNumberOfAvailableSteps()}`}),jsxRuntime.jsx(C.Secondary,{marginLeft:"auto",title:i.secondaryButtonTitle,onClick:f}),jsxRuntime.jsx(C.Primary,{title:i.primaryButtonTitle,onClick:m})]})]},i.id)}function Fr({flowId:e,onComplete:o,variables:t,...n}){let{flow:r}=X(e,{variables:t});V(r,{onComplete:o});let{isCurrentModal:i,removeModal:s}=G(r);if(ge.useEffect(()=>{!(r!=null&&r.isVisible)&&i&&s();},[r==null?void 0:r.isVisible,i]),r==null||r.isVisible===!1||!i)return null;r.start();let a=r.getCurrentStep();return a==null||a.start(),jsxRuntime.jsx(To,{step:a,flow:r,...n})}function Rr(){let{frigade:e}=ge.useContext(M);return {frigade:e,isLoading:e.isReady()}}
|
|
47
|
+
|
|
48
|
+
exports.Announcement = Jt;
|
|
49
|
+
exports.Banner = Yt;
|
|
50
|
+
exports.Box = p;
|
|
51
|
+
exports.Button = g;
|
|
52
|
+
exports.Card = y;
|
|
53
|
+
exports.Flex = x;
|
|
54
|
+
exports.Form = fr;
|
|
55
|
+
exports.Provider = wt;
|
|
56
|
+
exports.Text = d;
|
|
57
|
+
exports.Tooltip = C;
|
|
58
|
+
exports.Tour = Fr;
|
|
59
|
+
exports.useBoundingClientRect = ie;
|
|
60
|
+
exports.useFlow = X;
|
|
61
|
+
exports.useFlowHandlers = V;
|
|
62
|
+
exports.useFrigade = Rr;
|
|
63
|
+
exports.useModal = G;
|
|
64
|
+
exports.useStepHandlers = J;
|
|
65
|
+
//# sourceMappingURL=out.js.map
|
|
3
66
|
//# sourceMappingURL=index.cjs.map
|