@wistia/vhs 2.74.0-beta.c0d7bd8d.8077d2d → 2.74.0-beta.c9f0ef33.7e9273d
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGlobalError.d.ts","sourceRoot":"","sources":["../../../src/components/FormGlobalError/FormGlobalError.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormGlobalError.d.ts","sourceRoot":"","sources":["../../../src/components/FormGlobalError/FormGlobalError.tsx"],"names":[],"mappings":"AA+EA,eAAO,MAAM,eAAe,0FA0B1B,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/vhs v2.74.0-beta.
|
|
3
|
+
* @license @wistia/vhs v2.74.0-beta.c9f0ef33.7e9273d
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2021-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1606,7 +1606,7 @@
|
|
|
1606
1606
|
`,JK=(0,mu.default)(LP)`
|
|
1607
1607
|
cursor: pointer;
|
|
1608
1608
|
text-decoration: underline;
|
|
1609
|
-
`,ZK=e=>{let t="error";return e>1&&(t+="s"),`${e} ${t} found on page`},QK=e=>{document.getElementById(`fieldset-${e}`)?.scrollIntoView({behavior:"smooth"})},eq=({errors:e={},statusError:t})=>(0,mo.jsxs)(YK,{children:[(0,mc.isNonEmptyString)(t)?(0,mo.jsx)(LP,{children:t}):null,Object.keys(e).map(r=>(0,mo.jsx)("li",{children:(0,mo.jsx)(JK,{"data-testid":`form-global-error-${r}`,onClick:
|
|
1609
|
+
`,ZK=e=>{let t="error";return e>1&&(t+="s"),`${e} ${t} found on page`},QK=e=>{document.getElementById(`fieldset-${e}`)?.scrollIntoView({behavior:"smooth"})},eq=({errors:e={},statusError:t})=>(0,mo.jsxs)(YK,{children:[(0,mc.isNonEmptyString)(t)?(0,mo.jsx)(LP,{children:t}):null,Object.keys(e).map(r=>(0,mo.jsx)("li",{children:(0,mo.jsx)(JK,{"data-testid":`form-global-error-${r}`,onClick:()=>QK(r),children:e[r]})},r))]}),hc=(0,VP.forwardRef)((e,t)=>{let r=ui(),{status:n,errors:o}=r,a=Object.keys(o).length;(0,mc.isNotNil)(n)&&n.length>0&&(a+=1);let s=(0,mc.isNotNil)(n)&&!n.success||a;return _n(s)?(0,mo.jsxs)(qK,{ref:t,children:[(0,mo.jsx)(XK,{children:ZK(a)}),(0,mo.jsx)(eq,{errors:o,statusError:n})]}):null});hc.displayName="FormGlobalError_VHS";i();i();var $P=require("react");var hu=()=>(0,$P.useContext)(gd);i();i();var zP=require("react");i();i();var rn=require("react"),p5=(e,t=0)=>{let r=(0,rn.useRef)(!1),n=(0,rn.useRef)(),o=(0,rn.useRef)(e),a=(0,rn.useCallback)(()=>r.current,[]),s=(0,rn.useCallback)(()=>{r.current=!1,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{r.current=!0,o.current()},t)},[t]),u=(0,rn.useCallback)(()=>{r.current=null,n.current&&clearTimeout(n.current)},[]);return(0,rn.useEffect)(()=>{o.current=e},[e]),(0,rn.useEffect)(()=>(s(),u),[t]),[a,u,s]};var d5=(e,t=0,r=[])=>{let[n,o,a]=p5(e,t);return(0,zP.useEffect)(a,r),[n,o]};var gc=require("react/jsx-runtime"),GP=(e,t)=>JSON.stringify(e)!==JSON.stringify(t),tq=(e,t)=>{let r={};return Object.keys(e).forEach(n=>{e[n]===null?(0,Ot.isNotUndefined)(t)&&(0,Ot.isNotUndefined)(t.fields)&&(0,Ot.isNotUndefined)(t.fields[n])&&t.fields[n]._type==="boolean"?r[n]=!1:r[n]=void 0:r[n]=e[n]}),r},m5=({children:e,className:t,formId:r,initialValues:n,onSubmit:o,scrollToFormErrorsOnSubmit:a=!0,shareFormContext:s,style:u,submitOnChange:l=!1,validate:c,validateOnBlur:p=!1,validateOnChange:d=!1,validationSchema:h,globalErrorRef:g,showGlobalError:v=!0,innerRef:m})=>{let[b,y]=(0,di.useState)(),[x,w]=(0,di.useState)(),[S,E]=(0,di.useState)(0),D=hu(),P=(W,N)=>{let V={};Object.keys(W).forEach($=>{let H=W[$],te=(0,Ot.isNotUndefined)(h)&&(0,Ot.isNotUndefined)(h.fields[$])&&h.fields[$]._type==="string";if(H==null){V[$]=null;return}if(typeof H=="number"){V[$]=H;return}H===!1&&(V[$]=!1),te&&!H&&(V[$]=null),H&&(V[$]=te?H.trim():H)}),o(V,N)},R=a&&((0,Ot.isUndefined)(b)||!b)&&((0,Ot.isUndefined)(x)||!x)&&(0,Ot.isNotUndefined)(g.current?.scrollIntoView);(0,di.useEffect)(()=>{if(((0,Ot.isUndefined)(b)||!b)&&(0,Ot.isNotUndefined)(x)&&x&&document.activeElement&&document.activeElement.blur(),R){let W=S>1?`there are ${S} errors`:"there's an error!";D({variant:"error",message:`Uh oh, ${W}`}),g.current.scrollIntoView({behavior:"smooth"})}},[S,g,b,x,R,D]);let B=tq(n,h),I=750;return(0,gc.jsx)(eE,{enableReinitialize:!0,initialValues:B,innerRef:(0,Ot.isNotNil)(m)?m:()=>{},onSubmit:P,validate:(0,Ot.isNotNil)(c)?c:()=>{},validateOnBlur:p,validateOnChange:d,validationSchema:h,children:W=>{let[N,V]=(0,di.useState)(W.values);if((0,di.useEffect)(()=>{(0,Ot.isNotUndefined)(s)&&s(W),y(W.isSubmitting),w(W.isValid),E(Object.keys(W.errors).length),l&&GP(W.values,N)&&V(W.values)},[W,N]),l){let[,]=d5(()=>{GP(n,N)&&W.submitForm()},I,[N])}return(0,gc.jsxs)(I3,{className:t,"data-testid":r,noValidate:!0,style:u,children:[v?(0,gc.jsx)(hc,{ref:g}):null,e]})}})};m5.displayName="Form_VHS";i();i();i();i();var HP=require("react/jsx-runtime"),V1=({type:e="submit",isSubmitting:t=!1,children:r,disabled:n=!1,...o})=>(0,HP.jsx)(et,{disabled:t||n,type:e,...o,children:r});V1.displayName="FormConnectorButton_VHS";var h5=require("react/jsx-runtime"),rq=e=>e.preventDefault(),g5=({buttons:e,align:t="left",...r})=>{let{isSubmitting:n}=ui();return(0,h5.jsx)(uo,{align:t,...r,children:e.map(({name:o,type:a,...s})=>(0,h5.jsx)(V1,{isSubmitting:n,type:a,...s,onMouseDown:rq,children:o},o))})};g5.displayName="FormButtons_VHS";i();i();var GF=require("react"),tv=A(require("styled-components"));i();var jP={checkbox:{component:"FormConnectorCheckboxGroup",inputType:null},custom:{component:"FormConnectorCustomField",inputType:null},email:{component:"FormConnectorInput",inputType:"email"},hidden:{component:"FormConnectorHidden",inputType:"hidden"},multiline:{component:"FormConnectorInput",inputType:null},number:{component:"FormConnectorInput",inputType:"number"},password:{component:"FormConnectorInput",inputType:"password"},phone:{component:"FormConnectorInput",inputType:"tel"},radio:{component:"FormConnectorRadioGroup",inputType:null},search:{component:"FormConnectorInput",inputType:"search"},select:{component:"FormConnectorSelect",inputType:null},text:{component:"FormConnectorInput",inputType:"text"},time:{component:"FormConnectorInput",inputType:"time"},timePosition:{component:"FormConnectorInput",inputType:"text"},url:{component:"FormConnectorInput",inputType:"url"},richTextEditor:{component:"FormConnectorRichTextEditor",inputType:null}};i();i();var L1=A(ee());var WP=require("react/jsx-runtime"),$1=({direction:e="column",disabled:t=!1,field:{name:r,value:n},form:{errors:o,setFieldValue:a},label:s,labelDescription:u,labelProps:l={},onChangeCustom:c,options:p=[]})=>{let d=(m,b)=>{a(b,m.target.checked)},h=(m,b)=>{let y=n;if((0,L1.isArray)(y))if(m.target.checked)y.push(b);else{let x=y.indexOf(b);x>-1&&y.splice(x,1)}a(b,y)},g=Array.isArray(n)&&p.length>1?h:d,v=Array.isArray(p)?p:[p];return(0,WP.jsx)(pc,{direction:e,disabled:t,error:(0,L1.isNotNil)(o)?o[r]:void 0,label:s,labelDescription:u,labelProps:l,name:r,onChange:(m,b)=>{g(m,b),c&&c(m.target.checked)},options:v,value:n})};$1.displayName="FormConnectorCheckboxGroup_VHS";i();i();var _P=A(ee());var v5=require("react/jsx-runtime"),z1=({customComponent:e,field:t,form:r,label:n="",labelDescription:o,labelProps:a={},...s})=>{let{name:u}=t,{errors:l}=r;return(0,v5.jsx)(ir,{error:(0,_P.isNotUndefined)(l)?l[u]:void 0,label:n,labelDescription:o,labelProps:a,name:u,children:(0,v5.jsx)(e,{field:t,form:r,...s})})};z1.displayName="FormConnectorCustomField_VHS";i();i();var JP=A(ee());i();i();var vu=require("react"),YP=A(require("styled-components")),vc=A(ee());i();var Rn=A(require("styled-components"));var UP=Rn.css`
|
|
1610
1610
|
border-color: ${({theme:e})=>e.color.brandBlue500};
|
|
1611
1611
|
outline: none;
|
|
1612
1612
|
`,nq=Rn.css`
|