@volvo-cars/react-forms
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -1,2 +0,2 @@ | ||
import{useState as V}from"react";import{jsx as F}from"react/jsx-runtime";function b({children:e,id:o,className:r=""}){return F("p",{id:o,className:`micro text-feedback-red empty:hidden ${r}`.trim(),role:"alert",children:e})}import{jsx as G}from"react/jsx-runtime";function u({children:e,id:o,className:r=""}){return G("p",{id:o,className:`micro text-secondary ${r}`.trim(),children:e})}import{useId as D}from"react";function f(e){let o=D();return{inputId:e||o+"-input",errorId:o+"-error",hintId:o+"-hint"}}import{jsx as R,jsxs as A}from"react/jsx-runtime";function q({hint:e,id:o,label:r,hidden:P,dir:g,errorMessage:t,lang:v,translate:x,slot:n,value:d,defaultValue:s,...a}){let[p,c]=V(!d&&!s);function l(i){let{validity:M}=i.currentTarget,B=i.currentTarget.required;B||(i.currentTarget.required=!0),c(M.valueMissing&&!M.badInput),B||(i.currentTarget.required=!1)}let{inputId:m,errorId:C,hintId:I}=f(o),h=a["aria-invalid"]||!!t;return A("div",{className:"v-input-floating-label",hidden:P,dir:g,lang:v,translate:x,slot:n,children:[R("label",{htmlFor:m,children:r}),R("input",{...a,type:"date",id:m,onBlur:i=>{a.onBlur?.(i),l(i)},onChange:i=>{a.onChange?.(i),l(i)},"data-blank":p?"":void 0,"aria-invalid":h?!0:void 0,"aria-errormessage":t?C:void 0,"aria-describedby":e?I:void 0}),R(b,{id:C,className:"mt-4",children:t}),e&&R(u,{id:I,className:"mt-4",children:e})]})}import{jsx as H,jsxs as w}from"react/jsx-runtime";function S({hint:e,id:o,label:r,hidden:P,dir:g,errorMessage:t,lang:v,translate:x,slot:n,value:d,defaultValue:s,...a}){let{inputId:p,errorId:c,hintId:l}=f(o),m=a["aria-invalid"]||!!t;return w("div",{className:"v-input-floating-label",hidden:P,dir:g,lang:v,translate:x,slot:n,children:[H("label",{htmlFor:p,children:r}),H("input",{placeholder:" ",...a,id:p,type:"text","aria-invalid":m?!0:void 0,"aria-errormessage":t?c:void 0,"aria-describedby":e?l:void 0}),H(b,{id:c,className:"mt-4",children:t}),e&&H(u,{id:l,className:"mt-4",children:e})]})}import{jsx as y,jsxs as L}from"react/jsx-runtime";function $({label:e,id:o,hint:r,hidden:P,dir:g,lang:t,translate:v,slot:x,errorMessage:n,...d}){let{inputId:s,hintId:a,errorId:p}=f(o),c=d["aria-invalid"]||!!n;return L("div",{className:"flex-row",hidden:P,dir:g,lang:t,translate:v,slot:x,children:[y("input",{...d,type:"checkbox",id:s,"aria-invalid":c?!0:void 0,"aria-errormessage":n?p:void 0,"aria-describedby":r?a:void 0}),L("div",{className:"flex-col stack-4 ml-8",children:[y("label",{htmlFor:s,children:e}),y(b,{id:p,children:n}),r&&y(u,{id:a,children:r})]})]})}import{useContext as K}from"react";import{createContext as z}from"react";import{jsx as E,jsxs as N}from"react/jsx-runtime";function J({legend:e,id:o,hint:r,name:P,children:g,required:t,defaultValue:v,value:x,hidden:n,dir:d,lang:s,translate:a,slot:p,onChange:c,errorMessage:l,...m}){let{inputId:C,hintId:I,errorId:h}=f(o),i=m["aria-invalid"]||!!l;return N("fieldset",{...m,hidden:n,dir:d,lang:s,translate:a,slot:p,id:C,role:"radiogroup","aria-invalid":i?!0:void 0,"aria-errormessage":l?h:void 0,"aria-describedby":r?I:void 0,"aria-required":t?!0:void 0,children:[E("legend",{className:"mb-4",children:e}),r&&E(u,{id:I,className:"mb-16",children:r}),N("div",{className:"stack-8",hidden:n,children:[E(b,{id:h,className:"mb-16",children:l}),E(T.Provider,{value:{name:P,required:t,value:x,defaultValue:v,onChange:c},children:g})]})]})}var T=z({});import{jsx as k,jsxs as U}from"react/jsx-runtime";function O({label:e,id:o,hint:r,hidden:P,dir:g,lang:t,translate:v,slot:x,value:n,...d}){let{inputId:s,hintId:a}=f(o),{name:p=d.name,onChange:c=d.onChange,value:l,defaultValue:m,...C}=K(T),I={};return typeof l<"u"?I.checked=n===l:typeof m<"u"&&n===m&&(I.defaultChecked=!0),U("div",{className:"flex-row",hidden:P,dir:g,lang:t,translate:v,slot:x,children:[k("input",{...I,...d,...C,type:"radio",id:s,onChange:c,value:n,name:p}),r?U("div",{className:"flex-col stack-4 ml-8",children:[k("label",{htmlFor:s,children:e}),k(u,{id:a,children:r})]}):k("label",{htmlFor:s,className:"ml-8",children:e})]})}export{$ as Checkbox,q as DateInput,b as ErrorMessage,u as Hint,O as Radio,J as RadioGroup,S as TextInput}; | ||
import{useState as A}from"react";import{jsx as V}from"react/jsx-runtime";function v({children:e,id:o,className:r=""}){return V("p",{id:o,className:`micro text-feedback-red empty:hidden ${r}`.trim(),role:"alert",children:e})}import{jsx as D}from"react/jsx-runtime";function u({children:e,id:o,className:r=""}){return D("p",{id:o,className:`micro text-secondary ${r}`.trim(),children:e})}import{useId as q}from"react";function c(e){let o=q();return{inputId:e||o+"-input",errorId:o+"-error",hintId:o+"-hint"}}import{jsx as E,jsxs as $}from"react/jsx-runtime";function w({hint:e,id:o,label:r,hidden:m,dir:f,errorMessage:t,lang:P,translate:g,slot:i,value:s,defaultValue:n,...a}){let[l,d]=A(!s&&!n);function x(p){let{validity:y}=p.currentTarget,R=p.currentTarget.required;R||(p.currentTarget.required=!0),d(y.valueMissing&&!y.badInput),R||(p.currentTarget.required=!1)}let{inputId:b,errorId:I,hintId:C}=c(o),h=a["aria-invalid"]||!!t;return $("div",{className:"v-input-floating-label",hidden:m,dir:f,lang:P,translate:g,slot:i,children:[E("label",{htmlFor:b,children:r}),E("input",{...a,type:"date",id:b,value:s,defaultValue:n,onBlur:p=>{a.onBlur?.(p),x(p)},onChange:p=>{a.onChange?.(p),x(p)},"data-blank":l?"":void 0,"aria-invalid":h?!0:void 0,"aria-errormessage":t?I:void 0,"aria-describedby":e?C:void 0}),E(v,{id:I,className:"mt-4",children:t}),e&&E(u,{id:C,className:"mt-4",children:e})]})}import{jsx as T,jsxs as z}from"react/jsx-runtime";function K({hint:e,id:o,label:r,hidden:m,dir:f,errorMessage:t,lang:P,translate:g,slot:i,...s}){let{inputId:n,errorId:a,hintId:l}=c(o),d=s["aria-invalid"]||!!t;return z("div",{className:"v-input-floating-label",hidden:m,dir:f,lang:P,translate:g,slot:i,children:[T("label",{htmlFor:n,children:r}),T("input",{placeholder:" ",...s,id:n,type:"text","aria-invalid":d?!0:void 0,"aria-errormessage":t?a:void 0,"aria-describedby":e?l:void 0}),T(v,{id:a,className:"mt-4",children:t}),e&&T(u,{id:l,className:"mt-4",children:e})]})}import{Children as J,isValidElement as O,useState as Q}from"react";import{jsx as k,jsxs as L}from"react/jsx-runtime";function W({hint:e,id:o,label:r,hidden:m,dir:f,errorMessage:t,lang:P,translate:g,slot:i,value:s,defaultValue:n,children:a,...l}){let d=!1;J.forEach(a,H=>{O(H)&&H.type==="option"&&H.props.value===""&&(d=!0)});let[x,b]=Q(!n),I=typeof s=="string",{inputId:C,errorId:h,hintId:p}=c(o),y=l["aria-invalid"]||!!t,R=!d&&(I?!s:x);return L("div",{className:"v-input-floating-label",hidden:m,dir:f,lang:P,translate:g,slot:i,children:[k("label",{htmlFor:C,children:r}),L("select",{...l,id:C,onChange:I||d?l.onChange:H=>{l.onChange?.(H),b(!H.target.value)},value:s,defaultValue:n,"data-blank":R?"":void 0,"aria-invalid":y?"true":void 0,"aria-errormessage":t?h:void 0,"aria-describedby":e?p:void 0,children:[!n&&!d&&k("option",{value:"",hidden:!R,disabled:!R}),a]}),k(v,{id:h,className:"mt-4",children:t}),e&&k(u,{id:p,className:"mt-4",children:e})]})}import{jsx as M,jsxs as U}from"react/jsx-runtime";function X({label:e,id:o,hint:r,hidden:m,dir:f,lang:t,translate:P,slot:g,errorMessage:i,...s}){let{inputId:n,hintId:a,errorId:l}=c(o),d=s["aria-invalid"]||!!i;return U("div",{className:"flex-row",hidden:m,dir:f,lang:t,translate:P,slot:g,children:[M("input",{...s,type:"checkbox",id:n,"aria-invalid":d?!0:void 0,"aria-errormessage":i?l:void 0,"aria-describedby":r?a:void 0}),U("div",{className:"flex-col stack-4 ml-8",children:[M("label",{htmlFor:n,children:e}),M(v,{id:l,children:i}),r&&M(u,{id:a,children:r})]})]})}import{useContext as _}from"react";import{createContext as Y}from"react";import{jsx as B,jsxs as F}from"react/jsx-runtime";function Z({legend:e,id:o,hint:r,name:m,children:f,required:t,defaultValue:P,value:g,hidden:i,dir:s,lang:n,translate:a,slot:l,onChange:d,errorMessage:x,...b}){let{inputId:I,hintId:C,errorId:h}=c(o),p=b["aria-invalid"]||!!x;return F("fieldset",{...b,hidden:i,dir:s,lang:n,translate:a,slot:l,id:I,role:"radiogroup","aria-invalid":p?!0:void 0,"aria-errormessage":x?h:void 0,"aria-describedby":r?C:void 0,"aria-required":t?!0:void 0,children:[B("legend",{className:"mb-4",children:e}),r&&B(u,{id:C,className:"mb-16",children:r}),F("div",{className:"stack-8",hidden:i,children:[B(v,{id:h,className:"mb-16",children:x}),B(N.Provider,{value:{name:m,required:t,value:g,defaultValue:P,onChange:d},children:f})]})]})}var N=Y({});import{jsx as G,jsxs as S}from"react/jsx-runtime";function j({label:e,id:o,hint:r,hidden:m,dir:f,lang:t,translate:P,slot:g,value:i,...s}){let{inputId:n,hintId:a}=c(o),{value:l,defaultValue:d,...x}=_(N),b,I;return typeof l<"u"?b=i===l:typeof d<"u"&&i===d&&(I=!0),S("div",{className:"flex-row",hidden:m,dir:f,lang:t,translate:P,slot:g,children:[G("input",{...s,...x,checked:b,defaultChecked:I,type:"radio",id:n,value:i}),r?S("div",{className:"flex-col stack-4 ml-8",children:[G("label",{htmlFor:n,children:e}),G(u,{id:a,children:r})]}):G("label",{htmlFor:n,className:"ml-8",children:e})]})}export{X as Checkbox,w as DateInput,v as ErrorMessage,u as Hint,j as Radio,Z as RadioGroup,N as RadioGroupContext,W as Select,K as TextInput}; | ||
//# sourceMappingURL=index.js.map |
@@ -5,8 +5,10 @@ export { DateInput } from './date-input'; | ||
export type { TextInputProps, TextInputControlledProps, TextInputUncontrolledProps, } from './text-input'; | ||
export { Select } from './select'; | ||
export type { SelectProps, SelectControlledProps, SelectUncontrolledProps, } from './select'; | ||
export { Checkbox } from './checkbox'; | ||
export type { CheckboxProps, CheckboxControlledProps, CheckboxUncontrolledProps, } from './checkbox'; | ||
export { Radio } from './radio'; | ||
export type { RadioProps, RadioControlledProps, RadioUncontrolledProps, } from './radio'; | ||
export { RadioGroup } from './radio-group'; | ||
export type { RadioGroupProps, RadioGroupControlledProps, RadioGroupUncontrolledProps, } from './radio-group'; | ||
export type { RadioProps } from './radio'; | ||
export { RadioGroup, RadioGroupContext } from './radio-group'; | ||
export type { RadioGroupProps, RadioGroupControlledProps, RadioGroupUncontrolledProps, RadioGroupContextValue, } from './radio-group'; | ||
export { ErrorMessage } from './error-message'; | ||
@@ -13,0 +15,0 @@ export type { ErrorMessageProps } from './error-message'; |
@@ -1,2 +0,2 @@ | ||
var T=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var O=(e,r)=>{for(var o in r)T(e,o,{get:r[o],enumerable:!0})},Q=(e,r,o,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of J(r))!K.call(e,t)&&t!==o&&T(e,t,{get:()=>r[t],enumerable:!(i=z(r,t))||i.enumerable});return e};var W=e=>Q(T({},"__esModule",{value:!0}),e);var X={};O(X,{Checkbox:()=>q,DateInput:()=>D,ErrorMessage:()=>g,Hint:()=>p,Radio:()=>$,RadioGroup:()=>S,TextInput:()=>V});module.exports=W(X);var G=require("react");var N=require("react/jsx-runtime");function g({children:e,id:r,className:o=""}){return(0,N.jsx)("p",{id:r,className:`micro text-feedback-red empty:hidden ${o}`.trim(),role:"alert",children:e})}var U=require("react/jsx-runtime");function p({children:e,id:r,className:o=""}){return(0,U.jsx)("p",{id:r,className:`micro text-secondary ${o}`.trim(),children:e})}var F=require("react");function v(e){let r=(0,F.useId)();return{inputId:e||r+"-input",errorId:r+"-error",hintId:r+"-hint"}}var H=require("react/jsx-runtime");function D({hint:e,id:r,label:o,hidden:i,dir:t,errorMessage:n,lang:x,translate:I,slot:a,value:u,defaultValue:c,...l}){let[m,f]=(0,G.useState)(!u&&!c);function d(s){let{validity:B}=s.currentTarget,L=s.currentTarget.required;L||(s.currentTarget.required=!0),f(B.valueMissing&&!B.badInput),L||(s.currentTarget.required=!1)}let{inputId:P,errorId:E,hintId:b}=v(r),k=l["aria-invalid"]||!!n;return(0,H.jsxs)("div",{className:"v-input-floating-label",hidden:i,dir:t,lang:x,translate:I,slot:a,children:[(0,H.jsx)("label",{htmlFor:P,children:o}),(0,H.jsx)("input",{...l,type:"date",id:P,onBlur:s=>{l.onBlur?.(s),d(s)},onChange:s=>{l.onChange?.(s),d(s)},"data-blank":m?"":void 0,"aria-invalid":k?!0:void 0,"aria-errormessage":n?E:void 0,"aria-describedby":e?b:void 0}),(0,H.jsx)(g,{id:E,className:"mt-4",children:n}),e&&(0,H.jsx)(p,{id:b,className:"mt-4",children:e})]})}var y=require("react/jsx-runtime");function V({hint:e,id:r,label:o,hidden:i,dir:t,errorMessage:n,lang:x,translate:I,slot:a,value:u,defaultValue:c,...l}){let{inputId:m,errorId:f,hintId:d}=v(r),P=l["aria-invalid"]||!!n;return(0,y.jsxs)("div",{className:"v-input-floating-label",hidden:i,dir:t,lang:x,translate:I,slot:a,children:[(0,y.jsx)("label",{htmlFor:m,children:o}),(0,y.jsx)("input",{placeholder:" ",...l,id:m,type:"text","aria-invalid":P?!0:void 0,"aria-errormessage":n?f:void 0,"aria-describedby":e?d:void 0}),(0,y.jsx)(g,{id:f,className:"mt-4",children:n}),e&&(0,y.jsx)(p,{id:d,className:"mt-4",children:e})]})}var C=require("react/jsx-runtime");function q({label:e,id:r,hint:o,hidden:i,dir:t,lang:n,translate:x,slot:I,errorMessage:a,...u}){let{inputId:c,hintId:l,errorId:m}=v(r),f=u["aria-invalid"]||!!a;return(0,C.jsxs)("div",{className:"flex-row",hidden:i,dir:t,lang:n,translate:x,slot:I,children:[(0,C.jsx)("input",{...u,type:"checkbox",id:c,"aria-invalid":f?!0:void 0,"aria-errormessage":a?m:void 0,"aria-describedby":o?l:void 0}),(0,C.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,C.jsx)("label",{htmlFor:c,children:e}),(0,C.jsx)(g,{id:m,children:a}),o&&(0,C.jsx)(p,{id:l,children:o})]})]})}var w=require("react");var A=require("react");var h=require("react/jsx-runtime");function S({legend:e,id:r,hint:o,name:i,children:t,required:n,defaultValue:x,value:I,hidden:a,dir:u,lang:c,translate:l,slot:m,onChange:f,errorMessage:d,...P}){let{inputId:E,hintId:b,errorId:k}=v(r),s=P["aria-invalid"]||!!d;return(0,h.jsxs)("fieldset",{...P,hidden:a,dir:u,lang:c,translate:l,slot:m,id:E,role:"radiogroup","aria-invalid":s?!0:void 0,"aria-errormessage":d?k:void 0,"aria-describedby":o?b:void 0,"aria-required":n?!0:void 0,children:[(0,h.jsx)("legend",{className:"mb-4",children:e}),o&&(0,h.jsx)(p,{id:b,className:"mb-16",children:o}),(0,h.jsxs)("div",{className:"stack-8",hidden:a,children:[(0,h.jsx)(g,{id:k,className:"mb-16",children:d}),(0,h.jsx)(M.Provider,{value:{name:i,required:n,value:I,defaultValue:x,onChange:f},children:t})]})]})}var M=(0,A.createContext)({});var R=require("react/jsx-runtime");function $({label:e,id:r,hint:o,hidden:i,dir:t,lang:n,translate:x,slot:I,value:a,...u}){let{inputId:c,hintId:l}=v(r),{name:m=u.name,onChange:f=u.onChange,value:d,defaultValue:P,...E}=(0,w.useContext)(M),b={};return typeof d<"u"?b.checked=a===d:typeof P<"u"&&a===P&&(b.defaultChecked=!0),(0,R.jsxs)("div",{className:"flex-row",hidden:i,dir:t,lang:n,translate:x,slot:I,children:[(0,R.jsx)("input",{...b,...u,...E,type:"radio",id:c,onChange:f,value:a,name:m}),o?(0,R.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,R.jsx)("label",{htmlFor:c,children:e}),(0,R.jsx)(p,{id:l,children:o})]}):(0,R.jsx)("label",{htmlFor:c,className:"ml-8",children:e})]})}0&&(module.exports={Checkbox,DateInput,ErrorMessage,Hint,Radio,RadioGroup,TextInput}); | ||
var U=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var Y=(e,r)=>{for(var o in r)U(e,o,{get:r[o],enumerable:!0})},Z=(e,r,o,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of W(r))!X.call(e,a)&&a!==o&&U(e,a,{get:()=>r[a],enumerable:!(c=Q(r,a))||c.enumerable});return e};var _=e=>Z(U({},"__esModule",{value:!0}),e);var j={};Y(j,{Checkbox:()=>$,DateInput:()=>q,ErrorMessage:()=>f,Hint:()=>m,Radio:()=>O,RadioGroup:()=>z,RadioGroupContext:()=>G,Select:()=>w,TextInput:()=>A});module.exports=_(j);var D=require("react");var F=require("react/jsx-runtime");function f({children:e,id:r,className:o=""}){return(0,F.jsx)("p",{id:r,className:`micro text-feedback-red empty:hidden ${o}`.trim(),role:"alert",children:e})}var S=require("react/jsx-runtime");function m({children:e,id:r,className:o=""}){return(0,S.jsx)("p",{id:r,className:`micro text-secondary ${o}`.trim(),children:e})}var V=require("react");function P(e){let r=(0,V.useId)();return{inputId:e||r+"-input",errorId:r+"-error",hintId:r+"-hint"}}var T=require("react/jsx-runtime");function q({hint:e,id:r,label:o,hidden:c,dir:a,errorMessage:t,lang:g,translate:v,slot:s,value:d,defaultValue:n,...l}){let[i,p]=(0,D.useState)(!d&&!n);function x(u){let{validity:L}=u.currentTarget,M=u.currentTarget.required;M||(u.currentTarget.required=!0),p(L.valueMissing&&!L.badInput),M||(u.currentTarget.required=!1)}let{inputId:b,errorId:I,hintId:C}=P(r),E=l["aria-invalid"]||!!t;return(0,T.jsxs)("div",{className:"v-input-floating-label",hidden:c,dir:a,lang:g,translate:v,slot:s,children:[(0,T.jsx)("label",{htmlFor:b,children:o}),(0,T.jsx)("input",{...l,type:"date",id:b,value:d,defaultValue:n,onBlur:u=>{l.onBlur?.(u),x(u)},onChange:u=>{l.onChange?.(u),x(u)},"data-blank":i?"":void 0,"aria-invalid":E?!0:void 0,"aria-errormessage":t?I:void 0,"aria-describedby":e?C:void 0}),(0,T.jsx)(f,{id:I,className:"mt-4",children:t}),e&&(0,T.jsx)(m,{id:C,className:"mt-4",children:e})]})}var k=require("react/jsx-runtime");function A({hint:e,id:r,label:o,hidden:c,dir:a,errorMessage:t,lang:g,translate:v,slot:s,...d}){let{inputId:n,errorId:l,hintId:i}=P(r),p=d["aria-invalid"]||!!t;return(0,k.jsxs)("div",{className:"v-input-floating-label",hidden:c,dir:a,lang:g,translate:v,slot:s,children:[(0,k.jsx)("label",{htmlFor:n,children:o}),(0,k.jsx)("input",{placeholder:" ",...d,id:n,type:"text","aria-invalid":p?!0:void 0,"aria-errormessage":t?l:void 0,"aria-describedby":e?i:void 0}),(0,k.jsx)(f,{id:l,className:"mt-4",children:t}),e&&(0,k.jsx)(m,{id:i,className:"mt-4",children:e})]})}var N=require("react");var h=require("react/jsx-runtime");function w({hint:e,id:r,label:o,hidden:c,dir:a,errorMessage:t,lang:g,translate:v,slot:s,value:d,defaultValue:n,children:l,...i}){let p=!1;N.Children.forEach(l,B=>{(0,N.isValidElement)(B)&&B.type==="option"&&B.props.value===""&&(p=!0)});let[x,b]=(0,N.useState)(!n),I=typeof d=="string",{inputId:C,errorId:E,hintId:u}=P(r),L=i["aria-invalid"]||!!t,M=!p&&(I?!d:x);return(0,h.jsxs)("div",{className:"v-input-floating-label",hidden:c,dir:a,lang:g,translate:v,slot:s,children:[(0,h.jsx)("label",{htmlFor:C,children:o}),(0,h.jsxs)("select",{...i,id:C,onChange:I||p?i.onChange:B=>{i.onChange?.(B),b(!B.target.value)},value:d,defaultValue:n,"data-blank":M?"":void 0,"aria-invalid":L?"true":void 0,"aria-errormessage":t?E:void 0,"aria-describedby":e?u:void 0,children:[!n&&!p&&(0,h.jsx)("option",{value:"",hidden:!M,disabled:!M}),l]}),(0,h.jsx)(f,{id:E,className:"mt-4",children:t}),e&&(0,h.jsx)(m,{id:u,className:"mt-4",children:e})]})}var R=require("react/jsx-runtime");function $({label:e,id:r,hint:o,hidden:c,dir:a,lang:t,translate:g,slot:v,errorMessage:s,...d}){let{inputId:n,hintId:l,errorId:i}=P(r),p=d["aria-invalid"]||!!s;return(0,R.jsxs)("div",{className:"flex-row",hidden:c,dir:a,lang:t,translate:g,slot:v,children:[(0,R.jsx)("input",{...d,type:"checkbox",id:n,"aria-invalid":p?!0:void 0,"aria-errormessage":s?i:void 0,"aria-describedby":o?l:void 0}),(0,R.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,R.jsx)("label",{htmlFor:n,children:e}),(0,R.jsx)(f,{id:i,children:s}),o&&(0,R.jsx)(m,{id:l,children:o})]})]})}var J=require("react");var K=require("react");var H=require("react/jsx-runtime");function z({legend:e,id:r,hint:o,name:c,children:a,required:t,defaultValue:g,value:v,hidden:s,dir:d,lang:n,translate:l,slot:i,onChange:p,errorMessage:x,...b}){let{inputId:I,hintId:C,errorId:E}=P(r),u=b["aria-invalid"]||!!x;return(0,H.jsxs)("fieldset",{...b,hidden:s,dir:d,lang:n,translate:l,slot:i,id:I,role:"radiogroup","aria-invalid":u?!0:void 0,"aria-errormessage":x?E:void 0,"aria-describedby":o?C:void 0,"aria-required":t?!0:void 0,children:[(0,H.jsx)("legend",{className:"mb-4",children:e}),o&&(0,H.jsx)(m,{id:C,className:"mb-16",children:o}),(0,H.jsxs)("div",{className:"stack-8",hidden:s,children:[(0,H.jsx)(f,{id:E,className:"mb-16",children:x}),(0,H.jsx)(G.Provider,{value:{name:c,required:t,value:v,defaultValue:g,onChange:p},children:a})]})]})}var G=(0,K.createContext)({});var y=require("react/jsx-runtime");function O({label:e,id:r,hint:o,hidden:c,dir:a,lang:t,translate:g,slot:v,value:s,...d}){let{inputId:n,hintId:l}=P(r),{value:i,defaultValue:p,...x}=(0,J.useContext)(G),b,I;return typeof i<"u"?b=s===i:typeof p<"u"&&s===p&&(I=!0),(0,y.jsxs)("div",{className:"flex-row",hidden:c,dir:a,lang:t,translate:g,slot:v,children:[(0,y.jsx)("input",{...d,...x,checked:b,defaultChecked:I,type:"radio",id:n,value:s}),o?(0,y.jsxs)("div",{className:"flex-col stack-4 ml-8",children:[(0,y.jsx)("label",{htmlFor:n,children:e}),(0,y.jsx)(m,{id:l,children:o})]}):(0,y.jsx)("label",{htmlFor:n,className:"ml-8",children:e})]})}0&&(module.exports={Checkbox,DateInput,ErrorMessage,Hint,Radio,RadioGroup,RadioGroupContext,Select,TextInput}); | ||
//# sourceMappingURL=index.js.map |
@@ -74,3 +74,3 @@ /// <reference types="react" /> | ||
export declare function RadioGroup({ legend, id, hint, name, children, required, defaultValue, value, hidden, dir, lang, translate, slot, onChange, errorMessage, ...props }: RadioGroupProps): JSX.Element; | ||
export declare const RadioContext: React.Context<{ | ||
export interface RadioGroupContextValue { | ||
name?: string; | ||
@@ -81,4 +81,4 @@ required?: boolean; | ||
onChange?: React.FormEventHandler<HTMLInputElement>; | ||
'aria-invalid'?: boolean; | ||
}>; | ||
} | ||
export declare const RadioGroupContext: React.Context<RadioGroupContextValue>; | ||
export {}; |
@@ -5,8 +5,2 @@ /// <reference types="react" /> | ||
/** | ||
* The name of the input to use when submitting the form. | ||
* | ||
* May be omitted if set on the parent `RadioGroup`. | ||
*/ | ||
name?: string; | ||
/** | ||
* Concise label for the radio. | ||
@@ -16,3 +10,3 @@ */ | ||
/** | ||
* The value of the radio that will be submitted with the form data. | ||
* The value that will be submitted with the form data if the radio is selected. | ||
* | ||
@@ -24,37 +18,11 @@ * @default 'on' | ||
} | ||
type ControlledProps = { | ||
/** | ||
* Whether the radio is selected. Makes the input controlled. | ||
*/ | ||
checked: boolean; | ||
/** | ||
* Fires when the radio is selected. | ||
*/ | ||
onChange: React.FormEventHandler<HTMLInputElement>; | ||
defaultChecked?: never; | ||
}; | ||
type UncontrolledProps = { | ||
/** | ||
* Whether an (uncontrolled) radio is selected by default. | ||
*/ | ||
defaultChecked?: boolean; | ||
/** | ||
* Fires when the radio is selected. | ||
*/ | ||
onChange?: React.FormEventHandler<HTMLInputElement>; | ||
checked?: never; | ||
}; | ||
export type RadioControlledProps = BaseRadioProps & ControlledProps; | ||
export type RadioUncontrolledProps = BaseRadioProps & UncontrolledProps; | ||
export type RadioProps = BaseRadioProps & (ControlledProps | UncontrolledProps); | ||
export type RadioProps = BaseRadioProps; | ||
/** | ||
* Radios allow the user to select a single option from a group. | ||
* | ||
* Radios are designed to be used with the RadioGroup component and only support validation within | ||
* a RadioGroup. | ||
* Radios are designed to be used with the RadioGroup component. | ||
* | ||
* A Radio is a controlled component if the `checked` prop is set on the Radio, or if `value` is | ||
* set on the parent RadioGroup. | ||
* A Radio is a controlled component if the `value` is set on the parent RadioGroup. | ||
*/ | ||
export declare function Radio({ label, id, hint, hidden, dir, lang, translate, slot, value, ...props }: RadioProps): JSX.Element; | ||
export {}; |
@@ -50,3 +50,3 @@ /// <reference types="react" /> | ||
export type TextInputProps = BaseTextInputProps & (ControlledProps | UncontrolledProps); | ||
export declare function TextInput({ hint, id, label, hidden, dir, errorMessage, lang, translate, slot, value, defaultValue, ...props }: TextInputProps): JSX.Element; | ||
export declare function TextInput({ hint, id, label, hidden, dir, errorMessage, lang, translate, slot, ...props }: TextInputProps): JSX.Element; | ||
export {}; |
{ | ||
"name": "@volvo-cars/react-forms", | ||
"description": "React form components", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"license": "UNLICENSED", | ||
@@ -36,3 +36,3 @@ "sideEffects": false, | ||
"devDependencies": { | ||
"@types/react": "18.0.28", | ||
"@types/react": "18.0.29", | ||
"@volvo-cars/browserslist-config": "workspace:*", | ||
@@ -39,0 +39,0 @@ "react": "18.2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
88074
17
516
0