1 line
9.5 KiB
JavaScript
1 line
9.5 KiB
JavaScript
import{Ct as e,D as t,E as n,Et as r,H as i,N as a,S as o,Tt as s,_ as c,b as l,bt as u,c as d,d as f,g as p,l as m,nt as h,v as g,w as _,x as v,y,z as b}from"./vue.runtime.esm-bundler-DQjudA8G.js";import{t as x}from"./utils-BB02OBq2.js";import{n as S}from"./lib-Cz3jviUu.js";import{S as C,m as w}from"./dist-t_U6YImb.js";import{f as T,l as E,s as D}from"./index-CcML0o3b.js";import{t as O}from"./useFormControl-CyMrrgSu.js";import{t as k}from"./createContext-BefgL9WT.js";import{t as A}from"./useForwardPropsEmits-ixfQllIc.js";import"./Teleport-CLYBkdRb.js";import{t as j}from"./Primitive-jhoGcsVx.js";import{t as M}from"./useForwardExpose-OKJAPp5E.js";import{t as N}from"./VisuallyHiddenInput-syf01z94.js";import{t as P}from"./Checkbox-DtKJOwrj.js";import{n as F,t as I}from"./RadioGroupItem-DnFkEnO6.js";import{t as L}from"./Separator-5drwYWrN.js";import{t as R}from"./Button-2mdP_ygs.js";import{i as z,n as B,o as V,r as H,s as U,t as W,u as G}from"./FormMessage-DO2c5bWz.js";import{t as K}from"./FormDescription-DwQJgDgd.js";import"./global-layout-BuXj6D-T.js";import{t as q}from"./settings-layout-DVMhlnCW.js";var[J,Y]=k(`SwitchRoot`),X=_({__name:`SwitchRoot`,props:{defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},disabled:{type:Boolean,required:!1},id:{type:String,required:!1},value:{type:String,required:!1,default:`on`},trueValue:{type:null,required:!1,default:()=>!0},falseValue:{type:null,required:!1,default:()=>!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`],setup(t,{emit:n}){let r=t,o=n,{disabled:s}=u(r),c=w(r,`modelValue`,o,{defaultValue:r.defaultValue??r.falseValue,passive:r.modelValue===void 0}),l=p(()=>c.value===r.trueValue);function f(){s.value||(c.value=l.value?r.falseValue:r.trueValue)}let{forwardRef:_,currentElement:v}=M(),x=O(v),S=p(()=>r.id&&v.value?document.querySelector(`[for="${r.id}"]`)?.innerText:void 0);return Y({checked:l,toggleCheck:f,disabled:s}),(t,n)=>(b(),g(e(j),a(t.$attrs,{id:t.id,ref:e(_),role:`switch`,type:t.as===`button`?`button`:void 0,value:t.value,"aria-label":t.$attrs[`aria-label`]||S.value,"aria-checked":l.value,"aria-required":t.required,"data-state":l.value?`checked`:`unchecked`,"data-disabled":e(s)?``:void 0,"as-child":t.asChild,as:t.as,disabled:e(s),onClick:f,onKeydown:d(m(f,[`prevent`]),[`enter`])}),{default:h(()=>[i(t.$slots,`default`,{modelValue:e(c),checked:l.value}),e(x)&&t.name?(b(),g(e(N),{key:0,type:`checkbox`,name:t.name,disabled:e(s),required:t.required,value:t.value,checked:l.value},null,8,[`name`,`disabled`,`required`,`value`,`checked`])):y(`v-if`,!0)]),_:3},16,[`id`,`type`,`value`,`aria-label`,`aria-checked`,`aria-required`,`data-state`,`data-disabled`,`as-child`,`as`,`disabled`,`onKeydown`]))}}),Z=_({__name:`SwitchThumb`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(t){let n=J();return M(),(t,r)=>(b(),g(e(j),{"data-state":e(n).checked.value?`checked`:`unchecked`,"data-disabled":e(n).disabled.value?``:void 0,"as-child":t.asChild,as:t.as},{default:h(()=>[i(t.$slots,`default`)]),_:3},8,[`data-state`,`data-disabled`,`as-child`,`as`]))}}),Q=_({__name:`Switch`,props:{defaultValue:{},modelValue:{},disabled:{type:Boolean},id:{},value:{},trueValue:{},falseValue:{},asChild:{type:Boolean},as:{},name:{},required:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(t,{emit:c}){let l=t,u=c,d=A(C(l,`class`),u);return(t,c)=>(b(),g(e(X),a({"data-slot":`switch`},e(d),{class:e(x)(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,l.class)}),{default:h(a=>[o(e(Z),{"data-slot":`switch-thumb`,class:s(e(x)(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`))},{default:h(()=>[i(t.$slots,`thumb`,r(n(a)))]),_:2},1032,[`class`])]),_:3},16,[`class`]))}}),$=T({type:D([`all`,`mentions`,`none`],{error:`You need to select a notification type.`}),mobile:E().default(!1).optional(),communication_emails:E().default(!1).optional(),social_emails:E().default(!1).optional(),marketing_emails:E().default(!1).optional(),security_emails:E()}),ee={class:`space-y-4`},te={class:`space-y-0.5`},ne={class:`space-y-0.5`},re={class:`space-y-0.5`},ie={class:`space-y-0.5`},ae={class:`space-y-1 leading-none`},oe={class:`flex justify-start`},se=_({__name:`notifications-form`,setup(n){let{handleSubmit:r}=G({validationSchema:V($),initialValues:{communication_emails:!1,marketing_emails:!1,social_emails:!0,security_emails:!0}}),i=r(e=>{S(`You submitted the following values:`,{description:t(`pre`,{class:`mt-2 w-[340px] rounded-md bg-slate-950 p-4`},t(`code`,{class:`text-white`},JSON.stringify(e,null,2)))})});return(t,n)=>(b(),l(f,null,[n[17]||=c(`div`,null,[c(`h3`,{class:`text-lg font-medium`},` Notifications `),c(`p`,{class:`text-sm text-muted-foreground`},` Configure how you receive notifications. `)],-1),o(e(L),{class:`my-4`}),c(`form`,{class:`space-y-8`,onSubmit:n[0]||=(...t)=>e(i)&&e(i)(...t)},[o(e(U),{type:`radio`,name:`type`},{default:h(({componentField:t})=>[o(e(H),{class:`space-y-3`},{default:h(()=>[o(e(B),null,{default:h(()=>[...n[1]||=[v(`Notify me about...`,-1)]]),_:1}),o(e(z),null,{default:h(()=>[o(e(F),a({class:`flex flex-col space-y-1`},t),{default:h(()=>[o(e(H),{class:`flex items-center space-y-0`},{default:h(()=>[o(e(z),null,{default:h(()=>[o(e(I),{value:`all`})]),_:1}),o(e(B),{class:`font-normal`},{default:h(()=>[...n[2]||=[v(` All new messages `,-1)]]),_:1})]),_:1}),o(e(H),{class:`flex items-center space-y-0`},{default:h(()=>[o(e(z),null,{default:h(()=>[o(e(I),{value:`mentions`})]),_:1}),o(e(B),{class:`font-normal`},{default:h(()=>[...n[3]||=[v(` Direct messages and mentions `,-1)]]),_:1})]),_:1}),o(e(H),{class:`flex items-center space-y-0`},{default:h(()=>[o(e(z),null,{default:h(()=>[o(e(I),{value:`none`})]),_:1}),o(e(B),{class:`font-normal`},{default:h(()=>[...n[4]||=[v(` Nothing `,-1)]]),_:1})]),_:1})]),_:1},16)]),_:2},1024),o(e(W))]),_:2},1024)]),_:1}),c(`div`,null,[n[13]||=c(`h3`,{class:`mb-4 text-lg font-medium`},` Email Notifications `,-1),c(`div`,ee,[o(e(U),{type:`checkbox`,name:`communication_emails`},{default:h(({handleChange:t,value:r})=>[o(e(H),{class:`flex flex-row items-center justify-between p-4 border rounded-lg`},{default:h(()=>[c(`div`,te,[o(e(B),{class:`text-base`},{default:h(()=>[...n[5]||=[v(` Communication emails `,-1)]]),_:1}),o(e(K),null,{default:h(()=>[...n[6]||=[v(` Receive emails about your account activity. `,-1)]]),_:1})]),o(e(z),null,{default:h(()=>[o(e(Q),{checked:r,"onUpdate:checked":t},null,8,[`checked`,`onUpdate:checked`])]),_:2},1024)]),_:2},1024)]),_:1}),o(e(U),{type:`checkbox`,name:`marketing_emails`},{default:h(({handleChange:t,value:r})=>[o(e(H),{class:`flex flex-row items-center justify-between p-4 border rounded-lg`},{default:h(()=>[c(`div`,ne,[o(e(B),{class:`text-base`},{default:h(()=>[...n[7]||=[v(` Marketing emails `,-1)]]),_:1}),o(e(K),null,{default:h(()=>[...n[8]||=[v(` Receive emails about new products, features, and more. `,-1)]]),_:1})]),o(e(z),null,{default:h(()=>[o(e(Q),{checked:r,"onUpdate:checked":t},null,8,[`checked`,`onUpdate:checked`])]),_:2},1024)]),_:2},1024)]),_:1}),o(e(U),{type:`checkbox`,name:`social_emails`},{default:h(({handleChange:t,value:r})=>[o(e(H),{class:`flex flex-row items-center justify-between p-4 border rounded-lg`},{default:h(()=>[c(`div`,re,[o(e(B),{class:`text-base`},{default:h(()=>[...n[9]||=[v(` Social emails `,-1)]]),_:1}),o(e(K),null,{default:h(()=>[...n[10]||=[v(` Receive emails for friend requests, follows, and more. `,-1)]]),_:1})]),o(e(z),null,{default:h(()=>[o(e(Q),{checked:r,"onUpdate:checked":t},null,8,[`checked`,`onUpdate:checked`])]),_:2},1024)]),_:2},1024)]),_:1}),o(e(U),{type:`checkbox`,name:`security_emails`},{default:h(({handleChange:t,value:r})=>[o(e(H),{class:`flex flex-row items-center justify-between p-4 border rounded-lg`},{default:h(()=>[c(`div`,ie,[o(e(B),{class:`text-base`},{default:h(()=>[...n[11]||=[v(` Security emails `,-1)]]),_:1}),o(e(K),null,{default:h(()=>[...n[12]||=[v(` Receive emails about your account activity and security. `,-1)]]),_:1})]),o(e(z),null,{default:h(()=>[o(e(Q),{checked:r,"onUpdate:checked":t},null,8,[`checked`,`onUpdate:checked`])]),_:2},1024)]),_:2},1024)]),_:1})])]),o(e(U),{type:`checkbox`,name:`mobile`},{default:h(({handleChange:t,value:r})=>[o(e(H),{class:`flex flex-row items-start space-x-3 space-y-0`},{default:h(()=>[o(e(z),null,{default:h(()=>[o(e(P),{"model-value":r,"onUpdate:modelValue":t},null,8,[`model-value`,`onUpdate:modelValue`])]),_:2},1024),c(`div`,ae,[o(e(B),null,{default:h(()=>[...n[14]||=[v(` Use different settings for my mobile devices `,-1)]]),_:1}),o(e(K),null,{default:h(()=>[...n[15]||=[v(` You can manage your mobile notifications in the `,-1),c(`a`,{href:`/examples/forms`},` mobile settings `,-1),v(` page. `,-1)]]),_:1})])]),_:2},1024)]),_:1}),c(`div`,oe,[o(e(R),{type:`submit`},{default:h(()=>[...n[16]||=[v(` Update notifications `,-1)]]),_:1})])],32)],64))}}),ce=_({__name:`notifications`,setup(e){return(e,t)=>(b(),g(q,null,{default:h(()=>[o(se)]),_:1}))}});export{ce as default}; |