@verifiedinc-public/shared-ui-elements 10.0.0 → 11.0.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=
|
|
1
|
+
"use strict";const o=/^•{4}-(\d{2})-(\d{2})$/,c=/^(\d{4})-(\d{2})-(\d{2})$/,s=e=>{const r=o.exec(e);if(r)return`${r[1]}/${r[2]}/\u2022\u2022\u2022\u2022`;const t=c.exec(e);if(t)return`${t[2]}/${t[3]}/${t[1]}`;const n=new Date(Number(e)),a=String(n.getUTCMonth()+1).padStart(2,"0"),$=String(n.getUTCDate()).padStart(2,"0"),d=n.getUTCFullYear();return`${a}/${$}/${d}`};export{s as dateFormat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useRef as
|
|
1
|
+
"use strict";import{useRef as M,useState as A}from"react";import{Box as I}from"@mui/material";import{validateTimestamp as V,USDateSchema as B}from"../../../../../../../validations/date.schema.mjs";import{formatDateMMDDYYYY as K}from"../../../../../../../utils/date.mjs";import{credentialKeys as N}from"../../../../core/fields/index.mjs";import{useFormField as O}from"../../../core/field.hook.mjs";import{useOneClickForm as P}from"../../form.context.mjs";import{getAutoCompleteAttributeValue as E}from"../shared.mjs";import{FieldLabel as R}from"./label.mjs";import{ClearFieldAdornment as j}from"./clear-field-adornment.mjs";import{jsx as o}from"react/jsx-runtime";import{fieldInputTypes as z}from"../../../../core/fields/constants.mjs";import{DateInput as L}from"../../../../../DateInput/index.mjs";function q({fieldKey:n}){var u,m,p;const{options:c}=P(),{field:e,setValue:r}=O({key:n}),C=M(null),f=/^•{4}-\d{2}-\d{2}$/.test(e?.value??""),v=V(e?.defaultValue??""),[b,d]=A(()=>{const t=e?.value;if(!t)return"";const i=/^•{4}-(\d{2})-(\d{2})$/.exec(t);if(i)return`${i[1]}/${i[2]}/1900`;const a=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);return a?`${a[2]}/${a[3]}/${a[1]}`:K(t)});if(!e||e.schema.characteristics.inputType!==z.date)return null;const l=e.schema.key===N.birthDate,s=new Date,k=1900,y=1,S=1,$=l?s.getUTCFullYear()-18:s.getUTCFullYear()+100,T=l?s.getUTCMonth()+1:12,F=l?s.getUTCDate():31,Y=new Date(k,y-1,S),x=new Date($,T-1,F),U=t=>{if(e.isDisabled)return;if(f){d(""),r("");return}const i=B.safeParse(t),a=t.replace(/[^0-9]/g,"");if(d(t),a.length<=0)return r("");if(!i.success)return r("NaN");const[D,h,g]=t.split("/").map(Number);r(v?String(Date.UTC(g,D-1,h,12,0,0,0)):`${String(g).padStart(4,"0")}-${String(D).padStart(2,"0")}-${String(h).padStart(2,"0")}`)},w=()=>{d(""),r("")};return o(I,{width:"100%",children:o(L,{inputRef:C,variant:"outlined",size:"small",autoComplete:E(e.schema.key),label:o(R,{fieldKey:n}),value:b,onChange:U,error:!(e!=null&&e.isValid),helperText:(u=e.errorMessage)!=null&&u.length?e.errorMessage:e?.description,placeholder:e.schema.characteristics.placeholder,pickerClickOutsideBoundaryElement:c.features.datePickerClickOutsideBoundaryElement,pickerDefaultSelectedDate:new Date("08/01/1989"),minDate:Y,maxDate:x,disabled:e.isDisabled,redactYear:f||l&&((p=(m=c.features.field)==null?void 0:m.dob)==null?void 0:p.redactYear),InputProps:{"data-mask-me":!0,endAdornment:o(j,{fieldKey:n,onClick:w,disabled:e.isDisabled})}})})}export{q as DateInputField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import*as
|
|
1
|
+
"use strict";import*as r from"zod";const l=r.string().refine(e=>{if(/^\d{2}\/\d{2}\/\d{4}$/.test(e)){const t=Date.parse(String(new Date(e)));return!isNaN(t)}return!1},"Date is invalid"),N=e=>r.date().refine(t=>t.getTime()<Date.now(),{message:e}),o=e=>{if(!/^-?\d+$/.test(e)||e==="NaN"||e==="")return!1;const t=parseInt(e,10);if(isNaN(t))return!1;const a=new Date(t);if(isNaN(a.getTime()))return!1;const s=a.getUTCHours(),u=a.getUTCMinutes(),f=a.getUTCSeconds(),c=a.getUTCMilliseconds();return!(s!==12||u!==0||f!==0||c!==0)},d=e=>{if(e==="NaN"||e==="")return!1;const t=parseInt(e,10);if(isNaN(t))return!1;const a=new Date(t);if(isNaN(a.getTime()))return!1;const s=Date.UTC(1900,0,1,0,0,0,0);return t>=s},g=e=>o(e),m=e=>/^-?\d+$/.test(e)?d(e):!1,D=e=>{const t=parseInt(e,10),a=new Date(t),s=new Date,u=new Date(Date.UTC(s.getUTCFullYear()-18,s.getUTCMonth(),s.getUTCDate(),23,59,59,999));return a.getTime()<=u.getTime()},T=e=>D(e),U=/^\d{4}-\d{2}-\d{2}$/,C=/^•{4}-\d{2}-\d{2}$/,n=e=>U.test(e)&&!isNaN(new Date(e).getTime()),i=e=>C.test(e),w=e=>{const t=new Date(e),a=new Date;return a.setUTCFullYear(a.getUTCFullYear()-18),t<=a},p=r.string().refine(e=>i(e)||n(e)||g(e),"").refine(e=>i(e)||n(e)||m(e),""),h=r.string().refine(e=>i(e)||n(e)||g(e),"").refine(e=>i(e)||(n(e)?Number(e.slice(0,4))>=1900:m(e)),"").refine(e=>i(e)?!0:n(e)?w(e):T(e),"Must be 18 years or older");export{l as USDateSchema,h as birthDateSchema,p as dateSchema,N as getDateSchemaWithPastValidation,T as refineAge18Plus,m as refineMinimumDate1900,g as refineTimestamp,D as validateAge18Plus,d as validateMinimumDate1900,o as validateTimestamp};
|