@sprig-technologies/sprig-bundled 2.42.1 → 2.44.0

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.
@@ -0,0 +1,12 @@
1
+ "use strict";const e=require("./view-0ocXtsSZ.cjs"),T=require("./index-B0e_zgRQ.cjs"),_=t=>e.u("button",{...t,className:e.cc("ul-card-text__button",t.className),id:"ul-card-text__button"}),A=({html:t,...i})=>{const{enableCspTrustedTypes:l}=e.useConfig(n=>({enableCspTrustedTypes:n.enableCspTrustedTypes})),o=e.F(()=>T.getHtml(t,l),[l,t]);return e.u("div",{...i,dangerouslySetInnerHTML:{__html:o}})},I=()=>{const{viewDocument:t}=e.useConfig(o=>({viewDocument:o.viewDocument})),[i,l]=e.h(!1);return e.p(()=>{const o=t.querySelector(".sprig-question-body"),n=new ResizeObserver(()=>{window.requestAnimationFrame(()=>{l(!!(o&&T.isHTMLElement(o)&&o.scrollHeight>o.offsetHeight))})});return o&&n.observe(o),()=>{o&&n.disconnect()}},[t]),i},L=({plainText:t,richText:i,id:l,className:o,isHeader:n,showAsterisk:c})=>i?e.u(A,{className:o,html:i,id:l}):t?n?e.u("h1",{className:o,id:l,children:[t,c&&"*"]}):e.u("p",{className:o,id:l,children:t}):null,V=()=>e.u("svg",{fill:"none",height:"10",viewBox:"0 0 13 10",width:"13",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M11.5 1.5L4.5 8.5L1 5",stroke:"#FFFFFF",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})}),P=(t,i)=>{const l=e._(0);return()=>{if(t.current){const o=t.current;o.style.height="1px";const n=o.scrollHeight+(o.offsetHeight-o.clientHeight),c=parseInt(window.getComputedStyle(o).getPropertyValue("max-height")),s=n<=c?n:c;l.current!==s&&requestAnimationFrame(()=>{i()}),l.current=s,o.style.height=`${s}px`}}},$=({buttonText:t="View Prototype",handleClick:i})=>e.u("button",{className:"prototype-button",onClick:i,children:t},"prototype-btn"),H=({isSelected:t,id:i,divId:l,themeColor:o,disabled:n=!1})=>e.u("div",{"aria-checked":t,"aria-disabled":n,"aria-labelledby":`label-${i}`,className:"select-checkbox",id:l,role:"checkbox",style:{...t?{backgroundColor:o,borderColor:o,boxShadow:"none"}:{},...n?{opacity:.5}:{}},tabIndex:n?-1:0,children:t&&e.u(e.SvgCheckmark,{})}),j=({promptText:t,textValue:i,onTextChange:l,useMobileStyling:o})=>{const n=e._(null),{update:c}=e.useConfig(a=>({update:a.update})),s=P(n,()=>c());return e.p(()=>(s(),n.current&&n.current.focus(),()=>{c()}),[]),e.u("textarea",{"aria-label":t,"aria-multiline":"true","aria-placeholder":t,className:e.cc(e.getClasses("choice-text-input",o)),"data-gramm":"false",maxLength:5e3,name:"text",onChange:a=>{s(),a.stopPropagation(),l(a.currentTarget.value)},onClick:a=>{a.stopPropagation()},onKeyPress:a=>{a.stopPropagation()},placeholder:t,ref:n,role:"textbox",rows:1,value:i})},q="ul-select-style-element",R="ul-select-active-dynamic-style",F="ul-select-error-dynamic-style",z=(t,i,l)=>{let o=t.getElementById(q),n=!1;o||(o=t.createElement("style"),n=!0),o.tagName.toLowerCase()==="style"&&(o.id=q,l&&(o.nonce=l),o.textContent=W(i),n&&t.head.appendChild(o))},W=t=>`
2
+ .${R} {
3
+ border-color: ${t};
4
+ }
5
+ .${R} .select-radio, .${R}.select-radio {
6
+ border: 6px solid ${t};
7
+ box-shadow: none;
8
+ }
9
+ .${F} {
10
+ border-color: ${T.ERROR_BORDER_COLOR};
11
+ }
12
+ `,K=({options:t,selectItem:i,selectedOptions:l,showCheckbox:o,disabledOptions:n,dropdownFooter:c,panelRef:s})=>{const{themeColor:a}=e.useConfig(r=>({doc:r.viewDocument,themeColor:r.border}));return e.u("div",{className:"select-list",ref:s,children:[t.map(r=>{return e.u("div",{"aria-disabled":n==null?void 0:n.includes(r),className:e.cc("select-option",n!=null&&n.includes(r)?"ul-choice-disabled":""),onClick:u=>{n!=null&&n.includes(r)||(i(r),u.stopPropagation())},role:"option",style:{...n!=null&&n.includes(r)?{opacity:.5,cursor:"not-allowed"}:{}},children:[o&&e.u(H,{divId:(h=r.id,`checkbox-div-${h}`),id:r.id,isSelected:l.includes(r),themeColor:a}),r.label]},r.id);var h}),c]})},Q={"{{user_id}}":"externalUserId","{{email}}":"email"};exports.Button=_,exports.Header=({message:t,properties:i,isRequired:l})=>{const o=e._(null),n=i==null?void 0:i.captionText,c=I();return e.u("div",{className:e.cc("question-header-container","sprig-header-container",c?"sprig-border-bottom":null),ref:o,children:[e.u("div",{className:"question-header-button-container",children:e.u(L,{className:"ul-question",id:"ul-question",isHeader:!0,plainText:t,richText:i==null?void 0:i.questionHtml,showAsterisk:l})}),e.u(L,{className:"ul-caption",id:"ul-caption",plainText:n,richText:i==null?void 0:i.captionHtml})]})},exports.Html=A,exports.LongformSubmitButton=({isSubmitDisabled:t,handleSubmit:i})=>e.u("div",{className:"ul-card-longform__submit-button-container",children:e.u(_,{className:"ul-card-longform__submit-button",disabled:t,onClick:i,children:["OK ",e.u(V,{})]})}),exports.MobileEmbedView=({embeddedType:t="prototype",properties:i,children:l})=>{var y;const{handleClickEmbedButton:o,hasViewedEmbed:n,headers:c,useDesktopPrototype:s}=e.useConfig(p=>({handleClickEmbedButton:p.handleClickEmbedButton,hasViewedEmbed:p.hasViewedEmbed,headers:p.headers,useDesktopPrototype:p.useDesktopPrototype})),a=(i==null?void 0:i.conceptUrl)||((y=i==null?void 0:i.consentDocument)==null?void 0:y.url),r=window.innerWidth<T.EMBED_MOBILE_MAX_WIDTH,h=c["userleap-platform"],u=(p,C)=>{p.preventDefault(),o(C)};if((()=>{const{update:p,index:C,isConversationalUI:g,viewDocument:f}=e.useConfig(({update:b,index:m,isConversationalUI:v,viewDocument:x})=>({update:b,index:m,isConversationalUI:v,viewDocument:x})),d=T.debounce(p,100);e.p(()=>{if(g)return;const b=new ResizeObserver(d),m=f.querySelector(".ul-card__container");return m&&b.observe(m,{box:"border-box"}),()=>{b.disconnect()}},[d,p,C,g,f])})(),!s&&r&&!n&&a&&["email","link"].includes(h)){if(t==="prototype")return e.u($,{handleClick:p=>{u(p,"question.prototype.click")}});if(t==="pdf")return e.u($,{buttonText:(i==null?void 0:i.viewDocumentText)||"View Document",handleClick:p=>{u(p,"question.agreement.click")}})}return e.u(e.g,{children:l})},exports.Option=({ariaLabel:t,border:i,choiceStyle:l={},label:o,isSelected:n,value:c,text:s,id:a,isRadio:r,useMobileStyling:h,error:u,allowTextEntry:y,noneOfTheAbove:p,promptText:C,disabled:g=!1,onUserInputChanged:f})=>{const{styleNonce:d,viewDocument:b}=e.useConfig(w=>({styleNonce:w.styleNonce,viewDocument:w.viewDocument})),[m,v]=e.h(!1);z(b,i,d);const x=({isSelected:w,userText:E})=>{f&&f({id:a,selected:w,value:c,userText:E,noneOfTheAbove:p})},N=w=>{g||(w.stopPropagation(),x({isSelected:r||!n,userText:s}),v(!1))},U=()=>{m||v(!0)},O=()=>{m&&v(!1)},k={onClick:w=>N(w),onKeyPress:w=>(E=>{g||E.key!=="Enter"&&E.key!==" "||N(E)})(w)};"ontouchstart"in b.documentElement?(k.onTouchStart=O,k.onTouchCancel=O,k.onTouchEnd=O):(k.onMouseDown=U,k.onMouseLeave=O);const D=r?`radio-${a}`:`checkbox-${a}`,S=n||m?[R]:[],B=[...u?[F]:[],...S,...g?["ul-choice-disabled"]:[]],M=o?{"aria-labelledby":`label-${a}`}:{"aria-label":t};return e.u("div",{className:e.cc(e.getClasses("choice",h),...B),id:`choice-div-${a}`,style:{...l,...u?{borderColor:T.ERROR_BORDER_COLOR}:{},...g?{opacity:.5,cursor:"not-allowed"}:{}},...g?{}:k,"aria-disabled":g,children:[e.u("div",{className:e.cc("choice-label-container"),children:[r?e.u("div",{...M,className:e.cc("select-radio",...S),id:D,role:"radio",tabIndex:0}):e.u(H,{disabled:g,divId:D,id:a,isSelected:n,themeColor:i}),o&&e.u("label",{className:e.cc(e.getClasses("select-label",h)),htmlFor:D,id:`label-${a}`,children:o})]}),y&&n&&e.u("div",{className:e.cc("choice-text-entry-container",...S),children:e.u(j,{onTextChange:w=>x({isSelected:n,userText:w}),promptText:C||"Please specify",textValue:s,useMobileStyling:h})})]})},exports.QuestionBodyFooterContainer=({children:t})=>{const i=I(),{isConversationalUI:l}=e.useConfig(o=>({isConversationalUI:o.isConversationalUI}));return e.u("div",{className:e.cc("sprig-question-footer-container",i&&!l?"sprig-border-top":null),children:t})},exports.QuestionBodyWrapper=({children:t})=>e.u("div",{className:"sprig-question-body",children:t}),exports.Select=({isMultiSelect:t=!1,multiselectText:i="choices selected",onChange:l,options:o,placeholderText:n,value:c,disabledOptions:s=[],dropdownFooter:a})=>{const[r,h]=e.h(!1),u=e._(null),{viewDocument:y,update:p,isConversationalUI:C}=e.useConfig(d=>({viewDocument:d.viewDocument,update:d.update,isConversationalUI:d.isConversationalUI})),g=()=>{h(!r)};e.y(()=>{C||p()},[r,C,p]),e.y(()=>{r&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[r]),e.p(()=>{var b;const d=m=>{const v=m.target;(v==null?void 0:v.closest(".select-option.ul-choice-disabled"))||h(!1)};y.addEventListener("click",d);try{(b=window.parent)==null||b.addEventListener("click",d)}catch{window.addEventListener("click",d)}return()=>{var m;y.removeEventListener("click",d);try{(m=window.parent)==null||m.removeEventListener("click",d)}catch{window.removeEventListener("click",d)}}},[y]);const f=c.length===0?["select-button-placeholder"]:[];return e.u(e.g,{children:[e.u("button",{"aria-label":"choice dropdown button",className:e.cc("select-button",...f),onClick:d=>{d.stopPropagation(),g()},type:"button",children:[e.u("span",{children:c.length===0?n:c.length===1?c[0].label:`${c.length} ${i}`}),e.u(e.SvgCaret,{})]}),r&&e.u(K,{disabledOptions:s,dropdownFooter:a,options:o,panelRef:u,selectedOptions:c,selectItem:d=>{var v;const b=c.some(x=>x.id===d.id),m=c.some(x=>{var N;return(N=x.optionProperties)==null?void 0:N.noneOfTheAbove});(v=d.optionProperties)!=null&&v.noneOfTheAbove&&!b?l([d]):t?l(b?c.filter(x=>x.id!==d.id):m?[d]:[...c,d]):b||l([d]),t||g()},showCheckbox:t})]})},exports.getAttributedUrl=(t=void 0,i={})=>{if(!t)return t;const l=["http:","https:","itms-apps:","market:"],o=(s=>/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(s)?s:`http://${s}`)(t);if(!o)return;try{const s=new URL(o);if(!s.protocol||!l.includes(s.protocol))return}catch{return}const n=[],c=((s,a,r)=>{let h=s;for(const[u,y]of Object.entries(Q))if(h.toLowerCase().includes(u))if(a[y]){const p=new RegExp(u,"gi");h=h.replace(p,a[y])}else r.push(u);return h})(o,i,n);return n.length===0?c:((s,a)=>{if(!s.includes("?"))return s;const r=s.slice(0,s.indexOf("?")),h=s.slice(s.indexOf("?")+1).split("&").map(u=>u.split("=")).filter(u=>!a.includes(u[1]));return h.length===0?r:`${r}?${h.map(u=>u.join("=")).join("&")}`})(c,n)},exports.useAutoSize=P,exports.useSetAllResponsesRaw=t=>{const i=e._(),{setAllResponsesRaw:l}=e.useConfig(o=>({setAllResponsesRaw:o.setAllResponsesRaw}));e.p(()=>{const o=i.current;(!o||Object.keys(t).length!==Object.keys(o).length||Object.keys(t).some(n=>t[n]!==o[n]))&&(l(t),i.current=t)},[t,l])};