Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volvo-cars/react-forms

Package Overview
Dependencies
Maintainers
8
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volvo-cars/react-forms - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0

2

dist/esm/index.js
"use client"
import{useState as $}from"react";import{jsx as K}from"react/jsx-runtime";function v({children:e,id:a,className:o=""}){return K("p",{id:a,className:`micro text-feedback-red empty:hidden ${o}`.trim(),role:"alert",children:e})}import{jsx as O}from"react/jsx-runtime";function c({children:e,id:a,className:o=""}){return O("p",{id:a,className:`micro text-secondary ${o}`.trim(),children:e})}import{useId as _}from"react";function m(e){let a=_();return{inputId:e||a+"-input",errorId:a+"-error",hintId:a+"-hint"}}import{jsx as L,jsxs as Q}from"react/jsx-runtime";function J({hint:e,id:a,label:o,hidden:P,dir:f,errorMessage:r,lang:g,translate:x,slot:s,value:d,defaultValue:n,isValid:i,...l}){let[t,p]=$(!d&&!n);function C(u){let{validity:H}=u.currentTarget,T=u.currentTarget.required;T||(u.currentTarget.required=!0),p(H.valueMissing&&!H.badInput),T||(u.currentTarget.required=!1)}let{inputId:I,errorId:h,hintId:y}=m(a),b=l["aria-invalid"]||i===!1||!!r;return Q("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[L("label",{htmlFor:I,children:o}),L("input",{...l,type:"date",id:I,value:d,defaultValue:n,onBlur:u=>{l.onBlur?.(u),C(u)},onChange:u=>{l.onChange?.(u),C(u)},"data-blank":t?"":void 0,"aria-invalid":b?!0:void 0,"aria-errormessage":r?h:void 0,"aria-describedby":e?y:void 0}),L(v,{id:h,className:"mt-4",children:r}),e&&L(c,{id:y,className:"mt-4",children:e})]})}import{useState as W}from"react";import{jsx as M,jsxs as S}from"react/jsx-runtime";function X({hint:e,id:a,label:o,hidden:P,dir:f,errorMessage:r,lang:g,translate:x,slot:s,defaultPasswordVisible:d=!1,showPasswordLabel:n,hidePasswordLabel:i,isValid:l,...t}){let[p,C]=W(d),{inputId:I,errorId:h,hintId:y}=m(a),b=t["aria-invalid"]||!!r;return S("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[M("label",{htmlFor:I,children:o}),S("div",{className:"v-input","data-input-delegate":!0,"aria-invalid":b?!0:void 0,children:[M("input",{placeholder:" ",...t,id:I,autoCorrect:"off",spellCheck:"false",autoCapitalize:"none",className:"bg-transparent",type:p?"text":"password","aria-invalid":b?!0:void 0,"aria-errormessage":b?h:void 0,"aria-describedby":e?y:void 0}),M("button",{type:"button",className:"v-input__password-visibility-control",...n&&i?{"aria-label":p?i:n,"aria-controls":I}:{"aria-hidden":!0,tabIndex:-1},onClick:()=>C(u=>!u)})]}),M(v,{id:h,className:"mt-4",children:r}),e&&M(c,{id:y,className:"mt-4",children:e})]})}import{jsx as U,jsxs as Z}from"react/jsx-runtime";function Y(e){return U(R,{...e,type:"text"})}function R({hint:e,id:a,label:o,hidden:P,dir:f,errorMessage:r,lang:g,translate:x,slot:s,isValid:d,...n}){let{inputId:i,errorId:l,hintId:t}=m(a),p=n["aria-invalid"]||d===!1||!!r;return Z("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[U("label",{htmlFor:i,children:o}),U("input",{placeholder:" ",...n,id:i,"aria-invalid":p?!0:void 0,"aria-errormessage":r?l:void 0,"aria-describedby":e?t:void 0}),U(v,{id:l,className:"mt-4",children:r}),e&&U(c,{id:t,className:"mt-4",children:e})]})}import{jsx as ee}from"react/jsx-runtime";function j(e){return ee(R,{...e,type:"email",inputMode:"email"})}import{jsx as te}from"react/jsx-runtime";function re(e){return te(R,{...e,type:"tel"})}import{jsx as ne}from"react/jsx-runtime";function oe(e){return ne(R,{...e,type:"url",inputMode:"url"})}import{Children as ae,isValidElement as le,useState as se}from"react";import{jsx as B,jsxs as G}from"react/jsx-runtime";function ie({hint:e,id:a,label:o,hidden:P,dir:f,errorMessage:r,lang:g,translate:x,slot:s,value:d,defaultValue:n,children:i,isValid:l,...t}){let p=!1;ae.forEach(i,E=>{le(E)&&E.type==="option"&&E.props.value===""&&(p=!0)});let[C,I]=se(!n),h=typeof d=="string",{inputId:y,errorId:b,hintId:u}=m(a),H=t["aria-invalid"]||l===!1||!!r,T=!p&&(h?!d:C);return G("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[B("label",{htmlFor:y,children:o}),G("select",{...t,id:y,onChange:h||p?t.onChange:E=>{t.onChange?.(E),I(!E.target.value)},value:d,defaultValue:n,"data-blank":T?"":void 0,"aria-invalid":H?"true":void 0,"aria-errormessage":r?b:void 0,"aria-describedby":e?u:void 0,children:[!n&&!p&&B("option",{value:"",hidden:!T,disabled:!T}),i]}),B(v,{id:b,className:"mt-4",children:r}),e&&B(c,{id:u,className:"mt-4",children:e})]})}import{jsx as k,jsxs as D}from"react/jsx-runtime";function pe({label:e,id:a,hint:o,hidden:P,dir:f,lang:r,translate:g,slot:x,errorMessage:s,isValid:d,...n}){let{inputId:i,hintId:l,errorId:t}=m(a),p=n["aria-invalid"]||d===!1||!!s;return D("div",{className:"flex-row",hidden:P,dir:f,lang:r,translate:g,slot:x,children:[k("input",{...n,type:"checkbox",id:i,"aria-invalid":p?!0:void 0,"aria-errormessage":s?t:void 0,"aria-describedby":o?l:void 0}),D("div",{className:"flex-col stack-4 ml-8",children:[k("label",{htmlFor:i,children:e}),k(v,{id:t,children:s}),o&&k(c,{id:l,children:o})]})]})}import{useContext as ce}from"react";import{createContext as de}from"react";import{jsx as N,jsxs as F}from"react/jsx-runtime";function ue({legend:e,id:a,hint:o,name:P,children:f,required:r,defaultValue:g,value:x,hidden:s,dir:d,lang:n,translate:i,slot:l,errorMessage:t,onChange:p,form:C,enterKeyHint:I,readOnly:h,isValid:y,...b}){let{inputId:u,hintId:H,errorId:T}=m(a),E=b["aria-invalid"]||y===!1||!!t;return F("fieldset",{...b,hidden:s,dir:d,lang:n,translate:i,slot:l,form:C,id:u,role:"radiogroup","aria-invalid":E?!0:void 0,"aria-errormessage":t?T:void 0,"aria-describedby":o?H:void 0,"aria-required":r?!0:void 0,children:[N("legend",{className:"mb-4",children:e}),o&&N(c,{id:H,className:"mb-16",children:o}),F("div",{className:"stack-8",hidden:s,children:[N(v,{id:T,className:"mb-16",children:t}),N(q,{value:{defaultValue:g,enterKeyHint:I,form:C,name:P,onChange:p,readOnly:h,required:r,value:x},children:f})]})]})}var A=de({}),q=A.Provider;import{jsx as w,jsxs as z}from"react/jsx-runtime";function me({label:e,id:a,hint:o,hidden:P,dir:f,lang:r,translate:g,slot:x,value:s,...d}){let{inputId:n,hintId:i}=m(a),{value:l,defaultValue:t,...p}=ce(A),C,I;return typeof l<"u"?C=s===l:typeof t<"u"&&s===t&&(I=!0),z("div",{className:"flex-row",hidden:P,dir:f,lang:r,translate:g,slot:x,children:[w("input",{...d,...p,checked:C,defaultChecked:I,type:"radio",id:n,value:s}),o?z("div",{className:"flex-col stack-4 ml-8",children:[w("label",{htmlFor:n,children:e}),w(c,{id:i,children:o})]}):w("label",{htmlFor:n,className:"ml-8",children:e})]})}import{jsx as V,jsxs as fe}from"react/jsx-runtime";function Pe({hint:e,id:a,label:o,hidden:P,dir:f,errorMessage:r,lang:g,translate:x,slot:s,isValid:d,...n}){let{inputId:i,errorId:l,hintId:t}=m(a),p=n["aria-invalid"]||d===!1||!!r;return fe("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[V("label",{htmlFor:i,children:o}),V("textarea",{placeholder:" ",...n,id:i,"aria-invalid":p?!0:void 0,"aria-errormessage":r?l:void 0,"aria-describedby":e?t:void 0}),V(v,{id:l,className:"mb-4",children:r}),e&&V(c,{id:t,className:"mt-4",children:e})]})}export{pe as Checkbox,J as DateInput,j as EmailInput,v as ErrorMessage,c as Hint,X as PasswordInput,me as Radio,q as RadioContextProvider,ue as RadioGroup,ie as Select,re as TelInput,Pe as TextArea,Y as TextInput,oe as UrlInput};
import{useState as $}from"react";import{jsx as K}from"react/jsx-runtime";function v({children:e,id:a,className:r=""}){return K("p",{id:a,className:`micro text-feedback-red empty:hidden ${r}`.trim(),role:"alert",children:e})}import{jsx as O}from"react/jsx-runtime";function c({children:e,id:a,className:r=""}){return O("p",{id:a,className:`micro text-secondary ${r}`.trim(),children:e})}import{useId as _}from"react";function m(e){let a=_();return{inputId:e||a+"-input",errorId:a+"-error",hintId:a+"-hint"}}import{jsx as L,jsxs as Q}from"react/jsx-runtime";function J({hint:e,id:a,label:r,hidden:P,dir:f,errorMessage:t,lang:g,translate:x,slot:s,value:p,defaultValue:n,isValid:i,...l}){let[o,d]=$(!p&&!n);function C(u){let{validity:H}=u.currentTarget,T=u.currentTarget.required;T||(u.currentTarget.required=!0),d(H.valueMissing&&!H.badInput),T||(u.currentTarget.required=!1)}let{inputId:I,errorId:h,hintId:y}=m(a),b=l["aria-invalid"]||i===!1||!!t;return Q("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[L("label",{htmlFor:I,children:r}),L("input",{...l,type:"date",id:I,value:p,defaultValue:n,onBlur:u=>{l.onBlur?.(u),C(u)},onChange:u=>{l.onChange?.(u),C(u)},"data-blank":o?"":void 0,"aria-invalid":b?!0:void 0,"aria-errormessage":t?h:void 0,"aria-describedby":e?y:void 0}),L(v,{id:h,className:"mt-4",children:t}),e&&L(c,{id:y,className:"mt-4",children:e})]})}import{useState as W}from"react";import{jsx as M,jsxs as S}from"react/jsx-runtime";function X({hint:e,id:a,label:r,hidden:P,dir:f,errorMessage:t,lang:g,translate:x,slot:s,defaultPasswordVisible:p=!1,showPasswordLabel:n,hidePasswordLabel:i,isValid:l,...o}){let[d,C]=W(p),{inputId:I,errorId:h,hintId:y}=m(a),b=o["aria-invalid"]||!!t;return S("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[M("label",{htmlFor:I,children:r}),S("div",{className:"v-input","data-input-delegate":!0,"aria-invalid":b?!0:void 0,children:[M("input",{placeholder:" ",...o,id:I,autoCorrect:"off",spellCheck:"false",autoCapitalize:"none",className:"bg-transparent",type:d?"text":"password","aria-invalid":b?!0:void 0,"aria-errormessage":b?h:void 0,"aria-describedby":e?y:void 0}),M("button",{type:"button",className:"v-input__password-visibility-control",...n&&i?{"aria-label":d?i:n,"aria-controls":I}:{"aria-hidden":!0,tabIndex:-1},onClick:()=>C(u=>!u)})]}),M(v,{id:h,className:"mt-4",children:t}),e&&M(c,{id:y,className:"mt-4",children:e})]})}import{jsx as U,jsxs as Z}from"react/jsx-runtime";function Y(e){return U(R,{...e,type:"text"})}function R({hint:e,id:a,label:r,hidden:P,dir:f,errorMessage:t,lang:g,translate:x,slot:s,isValid:p,...n}){let{inputId:i,errorId:l,hintId:o}=m(a),d=n["aria-invalid"]||p===!1||!!t;return Z("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[U("label",{htmlFor:i,children:r}),U("input",{placeholder:" ",...n,id:i,"aria-invalid":d?!0:void 0,"aria-errormessage":t?l:void 0,"aria-describedby":e?o:void 0}),U(v,{id:l,className:"mt-4",children:t}),e&&U(c,{id:o,className:"mt-4",children:e})]})}import{jsx as ee}from"react/jsx-runtime";function j(e){return ee(R,{...e,type:"email",inputMode:"email"})}import{jsx as te}from"react/jsx-runtime";function re(e){return te(R,{...e,type:"tel"})}import{jsx as ne}from"react/jsx-runtime";function oe(e){return ne(R,{...e,type:"url",inputMode:"url"})}import{Children as ae,isValidElement as le,useState as se}from"react";import{jsx as B,jsxs as G}from"react/jsx-runtime";function ie({hint:e,id:a,label:r,hidden:P,dir:f,errorMessage:t,lang:g,translate:x,slot:s,value:p,defaultValue:n,children:i,isValid:l,...o}){let d=!1;ae.forEach(i,E=>{le(E)&&E.type==="option"&&E.props.value===""&&(d=!0)});let[C,I]=se(!n),h=typeof p=="string",{inputId:y,errorId:b,hintId:u}=m(a),H=o["aria-invalid"]||l===!1||!!t,T=h?!p:C;return G("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[B("label",{htmlFor:y,children:r}),G("select",{...o,id:y,onChange:h?o.onChange:E=>{o.onChange?.(E),I(!E.target.value)},value:p,defaultValue:n,"data-blank":T?"":void 0,"aria-invalid":H?"true":void 0,"aria-errormessage":t?b:void 0,"aria-describedby":e?u:void 0,children:[!n&&!d&&B("option",{value:"",hidden:!T,disabled:!T,children:r}),i]}),B(v,{id:b,className:"mt-4",children:t}),e&&B(c,{id:u,className:"mt-4",children:e})]})}import{jsx as k,jsxs as D}from"react/jsx-runtime";function pe({label:e,id:a,hint:r,hidden:P,dir:f,lang:t,translate:g,slot:x,errorMessage:s,isValid:p,...n}){let{inputId:i,hintId:l,errorId:o}=m(a),d=n["aria-invalid"]||p===!1||!!s;return D("div",{className:"flex-row",hidden:P,dir:f,lang:t,translate:g,slot:x,children:[k("input",{...n,type:"checkbox",id:i,"aria-invalid":d?!0:void 0,"aria-errormessage":s?o:void 0,"aria-describedby":r?l:void 0}),D("div",{className:"flex-col stack-4 ml-8",children:[k("label",{htmlFor:i,children:e}),k(v,{id:o,children:s}),r&&k(c,{id:l,children:r})]})]})}import{useContext as ce}from"react";import{createContext as de}from"react";import{jsx as N,jsxs as F}from"react/jsx-runtime";function ue({legend:e,id:a,hint:r,name:P,children:f,required:t,defaultValue:g,value:x,hidden:s,dir:p,lang:n,translate:i,slot:l,errorMessage:o,onChange:d,form:C,enterKeyHint:I,readOnly:h,isValid:y,...b}){let{inputId:u,hintId:H,errorId:T}=m(a),E=b["aria-invalid"]||y===!1||!!o;return F("fieldset",{...b,hidden:s,dir:p,lang:n,translate:i,slot:l,form:C,id:u,role:"radiogroup","aria-invalid":E?!0:void 0,"aria-errormessage":o?T:void 0,"aria-describedby":r?H:void 0,"aria-required":t?!0:void 0,children:[N("legend",{className:"mb-4",children:e}),r&&N(c,{id:H,className:"mb-16",children:r}),F("div",{className:"stack-8",hidden:s,children:[N(v,{id:T,className:"mb-16",children:o}),N(q,{value:{defaultValue:g,enterKeyHint:I,form:C,name:P,onChange:d,readOnly:h,required:t,value:x},children:f})]})]})}var A=de({}),q=A.Provider;import{jsx as w,jsxs as z}from"react/jsx-runtime";function me({label:e,id:a,hint:r,hidden:P,dir:f,lang:t,translate:g,slot:x,value:s,...p}){let{inputId:n,hintId:i}=m(a),{value:l,defaultValue:o,...d}=ce(A),C,I;return typeof l<"u"?C=s===l:typeof o<"u"&&s===o&&(I=!0),z("div",{className:"flex-row",hidden:P,dir:f,lang:t,translate:g,slot:x,children:[w("input",{...p,...d,checked:C,defaultChecked:I,type:"radio",id:n,value:s}),r?z("div",{className:"flex-col stack-4 ml-8",children:[w("label",{htmlFor:n,children:e}),w(c,{id:i,children:r})]}):w("label",{htmlFor:n,className:"ml-8",children:e})]})}import{jsx as V,jsxs as fe}from"react/jsx-runtime";function Pe({hint:e,id:a,label:r,hidden:P,dir:f,errorMessage:t,lang:g,translate:x,slot:s,isValid:p,...n}){let{inputId:i,errorId:l,hintId:o}=m(a),d=n["aria-invalid"]||p===!1||!!t;return fe("div",{className:"v-input-floating-label",hidden:P,dir:f,lang:g,translate:x,slot:s,children:[V("label",{htmlFor:i,children:r}),V("textarea",{placeholder:" ",...n,id:i,"aria-invalid":d?!0:void 0,"aria-errormessage":t?l:void 0,"aria-describedby":e?o:void 0}),V(v,{id:l,className:"mb-4",children:t}),e&&V(c,{id:o,className:"mt-4",children:e})]})}export{pe as Checkbox,J as DateInput,j as EmailInput,v as ErrorMessage,c as Hint,X as PasswordInput,me as Radio,q as RadioContextProvider,ue as RadioGroup,ie as Select,re as TelInput,Pe as TextArea,Y as TextInput,oe as UrlInput};
//# sourceMappingURL=index.js.map
"use client"
var S=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var de=(e,r)=>{for(var t in r)S(e,t,{get:r[t],enumerable:!0})},ue=(e,r,t,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of ie(r))!pe.call(e,l)&&l!==t&&S(e,l,{get:()=>r[l],enumerable:!(u=se(r,l))||u.enumerable});return e};var ce=e=>ue(S({},"__esModule",{value:!0}),e);var me={};de(me,{Checkbox:()=>re,DateInput:()=>O,EmailInput:()=>Q,ErrorMessage:()=>f,Hint:()=>m,PasswordInput:()=>$,Radio:()=>ae,RadioContextProvider:()=>D,RadioGroup:()=>oe,Select:()=>ee,TelInput:()=>X,TextArea:()=>le,TextInput:()=>J,UrlInput:()=>Z});module.exports=ce(me);var K=require("react");var F=require("react/jsx-runtime");function f({children:e,id:r,className:t=""}){return(0,F.jsx)("p",{id:r,className:`micro text-feedback-red empty:hidden ${t}`.trim(),role:"alert",children:e})}var q=require("react/jsx-runtime");function m({children:e,id:r,className:t=""}){return(0,q.jsx)("p",{id:r,className:`micro text-secondary ${t}`.trim(),children:e})}var z=require("react");function g(e){let r=(0,z.useId)();return{inputId:e||r+"-input",errorId:r+"-error",hintId:r+"-hint"}}var N=require("react/jsx-runtime");function O({hint:e,id:r,label:t,hidden:u,dir:l,errorMessage:o,lang:x,translate:v,slot:i,value:c,defaultValue:a,isValid:p,...s}){let[n,d]=(0,K.useState)(!c&&!a);function C(P){let{validity:k}=P.currentTarget,T=P.currentTarget.required;T||(P.currentTarget.required=!0),d(k.valueMissing&&!k.badInput),T||(P.currentTarget.required=!1)}let{inputId:I,errorId:h,hintId:y}=g(r),b=s["aria-invalid"]||p===!1||!!o;return(0,N.jsxs)("div",{className:"v-input-floating-label",hidden:u,dir:l,lang:x,translate:v,slot:i,children:[(0,N.jsx)("label",{htmlFor:I,children:t}),(0,N.jsx)("input",{...s,type:"date",id:I,value:c,defaultValue:a,onBlur:P=>{s.onBlur?.(P),C(P)},onChange:P=>{s.onChange?.(P),C(P)},"data-blank":n?"":void 0,"aria-invalid":b?!0:void 0,"aria-errormessage":o?h:void 0,"aria-describedby":e?y:void 0}),(0,N.jsx)(f,{id:h,className:"mt-4",children:o}),e&&(0,N.jsx)(m,{id:y,className:"mt-4",children:e})]})}var _=require("react");var E=require("react/jsx-runtime");function $({hint:e,id:r,label:t,hidden:u,dir:l,errorMessage:o,lang:x,translate:v,slot:i,defaultPasswordVisible:c=!1,showPasswordLabel:a,hidePasswordLabel:p,isValid:s,...n}){let[d,C]=(0,_.useState)(c),{inputId:I,errorId:h,hintId:y}=g(r),b=n["aria-invalid"]||!!o;return(0,E.jsxs)("div",{className:"v-input-floating-label",hidden:u,dir:l,lang:x,translate:v,slot:i,children:[(0,E.jsx)("label",{htmlFor:I,children:t}),(0,E.jsxs)("div",{className:"v-input","data-input-delegate":!0,"aria-invalid":b?!0:void 0,children:[(0,E.jsx)("input",{placeholder:" ",...n,id:I,autoCorrect:"off",spellCheck:"false",autoCapitalize:"none",className:"bg-transparent",type:d?"text":"password","aria-invalid":b?!0:void 0,"aria-errormessage":b?h:void 0,"aria-describedby":e?y:void 0}),(0,E.jsx)("button",{type:"button",className:"v-input__password-visibility-control",...a&&p?{"aria-label":d?p:a,"aria-controls":I}:{"aria-hidden":!0,tabIndex:-1},onClick:()=>C(P=>!P)})]}),(0,E.jsx)(f,{id:h,className:"mt-4",children:o}),e&&(0,E.jsx)(m,{id:y,className:"mt-4",children:e})]})}var R=require("react/jsx-runtime");function J(e){return(0,R.jsx)(w,{...e,type:"text"})}function w({hint:e,id:r,label:t,hidden:u,dir:l,errorMessage:o,lang:x,translate:v,slot:i,isValid:c,...a}){let{inputId:p,errorId:s,hintId:n}=g(r),d=a["aria-invalid"]||c===!1||!!o;return(0,R.jsxs)("div",{className:"v-input-floating-label",hidden:u,dir:l,lang:x,translate:v,slot:i,children:[(0,R.jsx)("label",{htmlFor:p,children:t}),(0,R.jsx)("input",{placeholder:" ",...a,id:p,"aria-invalid":d?!0:void 0,"aria-errormessage":o?s:void 0,"aria-describedby":e?n:void 0}),(0,R.jsx)(f,{id:s,className:"mt-4",children:o}),e&&(0,R.jsx)(m,{id:n,className:"mt-4",children:e})]})}var W=require("react/jsx-runtime");function Q(e){return(0,W.jsx)(w,{...e,type:"email",inputMode:"email"})}var Y=require("react/jsx-runtime");function X(e){return(0,Y.jsx)(w,{...e,type:"tel"})}var j=require("react/jsx-runtime");function Z(e){return(0,j.jsx)(w,{...e,type:"url",inputMode:"url"})}var A=require("react");var M=require("react/jsx-runtime");function ee({hint:e,id:r,label:t,hidden:u,dir:l,errorMessage:o,lang:x,translate:v,slot:i,value:c,defaultValue:a,children:p,isValid:s,...n}){let d=!1;A.Children.forEach(p,H=>{(0,A.isValidElement)(H)&&H.type==="option"&&H.props.value===""&&(d=!0)});let[C,I]=(0,A.useState)(!a),h=typeof c=="string",{inputId:y,errorId:b,hintId:P}=g(r),k=n["aria-invalid"]||s===!1||!!o,T=!d&&(h?!c:C);return(0,M.jsxs)("div",{className:"v-input-floating-label",hidden:u,dir:l,lang:x,translate:v,slot:i,children:[(0,M.jsx)("label",{htmlFor:y,children:t}),(0,M.jsxs)("select",{...n,id:y,onChange:h||d?n.onChange:H=>{n.onChange?.(H),I(!H.target.value)},value:c,defaultValue:a,"data-blank":T?"":void 0,"aria-invalid":k?"true":void 0,"aria-errormessage":o?b:void 0,"aria-describedby":e?P:void 0,children:[!a&&!d&&(0,M.jsx)("option",{value:"",hidden:!T,disabled:!T}),p]}),(0,M.jsx)(f,{id:b,className:"mt-4",children:o}),e&&(0,M.jsx)(m,{id:P,className:"mt-4",children:e})]})}var U=require("react/jsx-runtime");function re({label:e,id:r,hint:t,hidden:u,dir:l,lang:o,translate:x,slot:v,errorMessage:i,isValid:c,...a}){let{inputId:p,hintId:s,errorId:n}=g(r),d=a["aria-invalid"]||c===!1||!!i;return(0,U.jsxs)("div",{className:"flex-row",hidden:u,dir:l,lang:o,translate:x,slot:v,children:[(0,U.jsx)("input",{...a,type:"checkbox",id:p,"aria-invalid":d?!0:void 0,"aria-errormessage":i?n:void 0,"aria-describedby":t?s:void 0}),(0,U.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,U.jsx)("label",{htmlFor:p,children:e}),(0,U.jsx)(f,{id:n,children:i}),t&&(0,U.jsx)(m,{id:s,children:t})]})]})}var ne=require("react");var te=require("react");var L=require("react/jsx-runtime");function oe({legend:e,id:r,hint:t,name:u,children:l,required:o,defaultValue:x,value:v,hidden:i,dir:c,lang:a,translate:p,slot:s,errorMessage:n,onChange:d,form:C,enterKeyHint:I,readOnly:h,isValid:y,...b}){let{inputId:P,hintId:k,errorId:T}=g(r),H=b["aria-invalid"]||y===!1||!!n;return(0,L.jsxs)("fieldset",{...b,hidden:i,dir:c,lang:a,translate:p,slot:s,form:C,id:P,role:"radiogroup","aria-invalid":H?!0:void 0,"aria-errormessage":n?T:void 0,"aria-describedby":t?k:void 0,"aria-required":o?!0:void 0,children:[(0,L.jsx)("legend",{className:"mb-4",children:e}),t&&(0,L.jsx)(m,{id:k,className:"mb-16",children:t}),(0,L.jsxs)("div",{className:"stack-8",hidden:i,children:[(0,L.jsx)(f,{id:T,className:"mb-16",children:n}),(0,L.jsx)(D,{value:{defaultValue:x,enterKeyHint:I,form:C,name:u,onChange:d,readOnly:h,required:o,value:v},children:l})]})]})}var G=(0,te.createContext)({}),D=G.Provider;var B=require("react/jsx-runtime");function ae({label:e,id:r,hint:t,hidden:u,dir:l,lang:o,translate:x,slot:v,value:i,...c}){let{inputId:a,hintId:p}=g(r),{value:s,defaultValue:n,...d}=(0,ne.useContext)(G),C,I;return typeof s<"u"?C=i===s:typeof n<"u"&&i===n&&(I=!0),(0,B.jsxs)("div",{className:"flex-row",hidden:u,dir:l,lang:o,translate:x,slot:v,children:[(0,B.jsx)("input",{...c,...d,checked:C,defaultChecked:I,type:"radio",id:a,value:i}),t?(0,B.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,B.jsx)("label",{htmlFor:a,children:e}),(0,B.jsx)(m,{id:p,children:t})]}):(0,B.jsx)("label",{htmlFor:a,className:"ml-8",children:e})]})}var V=require("react/jsx-runtime");function le({hint:e,id:r,label:t,hidden:u,dir:l,errorMessage:o,lang:x,translate:v,slot:i,isValid:c,...a}){let{inputId:p,errorId:s,hintId:n}=g(r),d=a["aria-invalid"]||c===!1||!!o;return(0,V.jsxs)("div",{className:"v-input-floating-label",hidden:u,dir:l,lang:x,translate:v,slot:i,children:[(0,V.jsx)("label",{htmlFor:p,children:t}),(0,V.jsx)("textarea",{placeholder:" ",...a,id:p,"aria-invalid":d?!0:void 0,"aria-errormessage":o?s:void 0,"aria-describedby":e?n:void 0}),(0,V.jsx)(f,{id:s,className:"mb-4",children:o}),e&&(0,V.jsx)(m,{id:n,className:"mt-4",children:e})]})}0&&(module.exports={Checkbox,DateInput,EmailInput,ErrorMessage,Hint,PasswordInput,Radio,RadioContextProvider,RadioGroup,Select,TelInput,TextArea,TextInput,UrlInput});
var S=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var de=(e,r)=>{for(var t in r)S(e,t,{get:r[t],enumerable:!0})},ue=(e,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of ie(r))!pe.call(e,l)&&l!==t&&S(e,l,{get:()=>r[l],enumerable:!(d=se(r,l))||d.enumerable});return e};var ce=e=>ue(S({},"__esModule",{value:!0}),e);var me={};de(me,{Checkbox:()=>re,DateInput:()=>O,EmailInput:()=>Q,ErrorMessage:()=>f,Hint:()=>c,PasswordInput:()=>$,Radio:()=>ae,RadioContextProvider:()=>D,RadioGroup:()=>oe,Select:()=>ee,TelInput:()=>X,TextArea:()=>le,TextInput:()=>J,UrlInput:()=>Z});module.exports=ce(me);var K=require("react");var F=require("react/jsx-runtime");function f({children:e,id:r,className:t=""}){return(0,F.jsx)("p",{id:r,className:`micro text-feedback-red empty:hidden ${t}`.trim(),role:"alert",children:e})}var q=require("react/jsx-runtime");function c({children:e,id:r,className:t=""}){return(0,q.jsx)("p",{id:r,className:`micro text-secondary ${t}`.trim(),children:e})}var z=require("react");function g(e){let r=(0,z.useId)();return{inputId:e||r+"-input",errorId:r+"-error",hintId:r+"-hint"}}var N=require("react/jsx-runtime");function O({hint:e,id:r,label:t,hidden:d,dir:l,errorMessage:o,lang:x,translate:v,slot:i,value:u,defaultValue:a,isValid:p,...s}){let[n,m]=(0,K.useState)(!u&&!a);function C(P){let{validity:k}=P.currentTarget,T=P.currentTarget.required;T||(P.currentTarget.required=!0),m(k.valueMissing&&!k.badInput),T||(P.currentTarget.required=!1)}let{inputId:I,errorId:h,hintId:y}=g(r),b=s["aria-invalid"]||p===!1||!!o;return(0,N.jsxs)("div",{className:"v-input-floating-label",hidden:d,dir:l,lang:x,translate:v,slot:i,children:[(0,N.jsx)("label",{htmlFor:I,children:t}),(0,N.jsx)("input",{...s,type:"date",id:I,value:u,defaultValue:a,onBlur:P=>{s.onBlur?.(P),C(P)},onChange:P=>{s.onChange?.(P),C(P)},"data-blank":n?"":void 0,"aria-invalid":b?!0:void 0,"aria-errormessage":o?h:void 0,"aria-describedby":e?y:void 0}),(0,N.jsx)(f,{id:h,className:"mt-4",children:o}),e&&(0,N.jsx)(c,{id:y,className:"mt-4",children:e})]})}var _=require("react");var E=require("react/jsx-runtime");function $({hint:e,id:r,label:t,hidden:d,dir:l,errorMessage:o,lang:x,translate:v,slot:i,defaultPasswordVisible:u=!1,showPasswordLabel:a,hidePasswordLabel:p,isValid:s,...n}){let[m,C]=(0,_.useState)(u),{inputId:I,errorId:h,hintId:y}=g(r),b=n["aria-invalid"]||!!o;return(0,E.jsxs)("div",{className:"v-input-floating-label",hidden:d,dir:l,lang:x,translate:v,slot:i,children:[(0,E.jsx)("label",{htmlFor:I,children:t}),(0,E.jsxs)("div",{className:"v-input","data-input-delegate":!0,"aria-invalid":b?!0:void 0,children:[(0,E.jsx)("input",{placeholder:" ",...n,id:I,autoCorrect:"off",spellCheck:"false",autoCapitalize:"none",className:"bg-transparent",type:m?"text":"password","aria-invalid":b?!0:void 0,"aria-errormessage":b?h:void 0,"aria-describedby":e?y:void 0}),(0,E.jsx)("button",{type:"button",className:"v-input__password-visibility-control",...a&&p?{"aria-label":m?p:a,"aria-controls":I}:{"aria-hidden":!0,tabIndex:-1},onClick:()=>C(P=>!P)})]}),(0,E.jsx)(f,{id:h,className:"mt-4",children:o}),e&&(0,E.jsx)(c,{id:y,className:"mt-4",children:e})]})}var R=require("react/jsx-runtime");function J(e){return(0,R.jsx)(w,{...e,type:"text"})}function w({hint:e,id:r,label:t,hidden:d,dir:l,errorMessage:o,lang:x,translate:v,slot:i,isValid:u,...a}){let{inputId:p,errorId:s,hintId:n}=g(r),m=a["aria-invalid"]||u===!1||!!o;return(0,R.jsxs)("div",{className:"v-input-floating-label",hidden:d,dir:l,lang:x,translate:v,slot:i,children:[(0,R.jsx)("label",{htmlFor:p,children:t}),(0,R.jsx)("input",{placeholder:" ",...a,id:p,"aria-invalid":m?!0:void 0,"aria-errormessage":o?s:void 0,"aria-describedby":e?n:void 0}),(0,R.jsx)(f,{id:s,className:"mt-4",children:o}),e&&(0,R.jsx)(c,{id:n,className:"mt-4",children:e})]})}var W=require("react/jsx-runtime");function Q(e){return(0,W.jsx)(w,{...e,type:"email",inputMode:"email"})}var Y=require("react/jsx-runtime");function X(e){return(0,Y.jsx)(w,{...e,type:"tel"})}var j=require("react/jsx-runtime");function Z(e){return(0,j.jsx)(w,{...e,type:"url",inputMode:"url"})}var A=require("react");var M=require("react/jsx-runtime");function ee({hint:e,id:r,label:t,hidden:d,dir:l,errorMessage:o,lang:x,translate:v,slot:i,value:u,defaultValue:a,children:p,isValid:s,...n}){let m=!1;A.Children.forEach(p,H=>{(0,A.isValidElement)(H)&&H.type==="option"&&H.props.value===""&&(m=!0)});let[C,I]=(0,A.useState)(!a),h=typeof u=="string",{inputId:y,errorId:b,hintId:P}=g(r),k=n["aria-invalid"]||s===!1||!!o,T=h?!u:C;return(0,M.jsxs)("div",{className:"v-input-floating-label",hidden:d,dir:l,lang:x,translate:v,slot:i,children:[(0,M.jsx)("label",{htmlFor:y,children:t}),(0,M.jsxs)("select",{...n,id:y,onChange:h?n.onChange:H=>{n.onChange?.(H),I(!H.target.value)},value:u,defaultValue:a,"data-blank":T?"":void 0,"aria-invalid":k?"true":void 0,"aria-errormessage":o?b:void 0,"aria-describedby":e?P:void 0,children:[!a&&!m&&(0,M.jsx)("option",{value:"",hidden:!T,disabled:!T,children:t}),p]}),(0,M.jsx)(f,{id:b,className:"mt-4",children:o}),e&&(0,M.jsx)(c,{id:P,className:"mt-4",children:e})]})}var U=require("react/jsx-runtime");function re({label:e,id:r,hint:t,hidden:d,dir:l,lang:o,translate:x,slot:v,errorMessage:i,isValid:u,...a}){let{inputId:p,hintId:s,errorId:n}=g(r),m=a["aria-invalid"]||u===!1||!!i;return(0,U.jsxs)("div",{className:"flex-row",hidden:d,dir:l,lang:o,translate:x,slot:v,children:[(0,U.jsx)("input",{...a,type:"checkbox",id:p,"aria-invalid":m?!0:void 0,"aria-errormessage":i?n:void 0,"aria-describedby":t?s:void 0}),(0,U.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,U.jsx)("label",{htmlFor:p,children:e}),(0,U.jsx)(f,{id:n,children:i}),t&&(0,U.jsx)(c,{id:s,children:t})]})]})}var ne=require("react");var te=require("react");var L=require("react/jsx-runtime");function oe({legend:e,id:r,hint:t,name:d,children:l,required:o,defaultValue:x,value:v,hidden:i,dir:u,lang:a,translate:p,slot:s,errorMessage:n,onChange:m,form:C,enterKeyHint:I,readOnly:h,isValid:y,...b}){let{inputId:P,hintId:k,errorId:T}=g(r),H=b["aria-invalid"]||y===!1||!!n;return(0,L.jsxs)("fieldset",{...b,hidden:i,dir:u,lang:a,translate:p,slot:s,form:C,id:P,role:"radiogroup","aria-invalid":H?!0:void 0,"aria-errormessage":n?T:void 0,"aria-describedby":t?k:void 0,"aria-required":o?!0:void 0,children:[(0,L.jsx)("legend",{className:"mb-4",children:e}),t&&(0,L.jsx)(c,{id:k,className:"mb-16",children:t}),(0,L.jsxs)("div",{className:"stack-8",hidden:i,children:[(0,L.jsx)(f,{id:T,className:"mb-16",children:n}),(0,L.jsx)(D,{value:{defaultValue:x,enterKeyHint:I,form:C,name:d,onChange:m,readOnly:h,required:o,value:v},children:l})]})]})}var G=(0,te.createContext)({}),D=G.Provider;var B=require("react/jsx-runtime");function ae({label:e,id:r,hint:t,hidden:d,dir:l,lang:o,translate:x,slot:v,value:i,...u}){let{inputId:a,hintId:p}=g(r),{value:s,defaultValue:n,...m}=(0,ne.useContext)(G),C,I;return typeof s<"u"?C=i===s:typeof n<"u"&&i===n&&(I=!0),(0,B.jsxs)("div",{className:"flex-row",hidden:d,dir:l,lang:o,translate:x,slot:v,children:[(0,B.jsx)("input",{...u,...m,checked:C,defaultChecked:I,type:"radio",id:a,value:i}),t?(0,B.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,B.jsx)("label",{htmlFor:a,children:e}),(0,B.jsx)(c,{id:p,children:t})]}):(0,B.jsx)("label",{htmlFor:a,className:"ml-8",children:e})]})}var V=require("react/jsx-runtime");function le({hint:e,id:r,label:t,hidden:d,dir:l,errorMessage:o,lang:x,translate:v,slot:i,isValid:u,...a}){let{inputId:p,errorId:s,hintId:n}=g(r),m=a["aria-invalid"]||u===!1||!!o;return(0,V.jsxs)("div",{className:"v-input-floating-label",hidden:d,dir:l,lang:x,translate:v,slot:i,children:[(0,V.jsx)("label",{htmlFor:p,children:t}),(0,V.jsx)("textarea",{placeholder:" ",...a,id:p,"aria-invalid":m?!0:void 0,"aria-errormessage":o?s:void 0,"aria-describedby":e?n:void 0}),(0,V.jsx)(f,{id:s,className:"mb-4",children:o}),e&&(0,V.jsx)(c,{id:n,className:"mt-4",children:e})]})}0&&(module.exports={Checkbox,DateInput,EmailInput,ErrorMessage,Hint,PasswordInput,Radio,RadioContextProvider,RadioGroup,Select,TelInput,TextArea,TextInput,UrlInput});
//# sourceMappingURL=index.js.map

@@ -65,6 +65,9 @@ /// <reference types="react" />

/**
* Select lets the users select one option from a predefined list of 3 or more options. For fewer
* options, prefer RadioGroup.
* Select lets the users select one option from a predefined list of 3 or more options. When you have fewer
* options, consider using a RadioGroup.
*
* Review the [React docs](https://react.dev/reference/react-dom/components/select) for more details
* on using selects in React.
*/
export declare function Select({ hint, id, label, hidden, dir, errorMessage, lang, translate, slot, value, defaultValue, children, isValid, ...props }: SelectProps): JSX.Element;
export {};
{
"name": "@volvo-cars/react-forms",
"description": "React form components",
"version": "0.6.2",
"version": "0.7.0",
"license": "UNLICENSED",

@@ -6,0 +6,0 @@ "sideEffects": false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc