@verifiedinc-public/shared-ui-elements 9.0.0 → 9.1.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.
- package/dist/components/form/DateInput/index.d.ts +1 -0
- package/dist/components/form/DateInput/index.mjs +1 -1
- package/dist/components/form/InputMask.d.ts +1 -0
- package/dist/components/form/NewOneClickForm/react/ui/fields/input/date.field.mjs +1 -1
- package/dist/components/form/NewOneClickForm/react/ui/fields/shared.d.ts +35 -3
- package/dist/components/form/NewOneClickForm/react/ui/fields/shared.mjs +1 -1
- package/dist/components/form/NewOneClickForm/react/ui/fields/style.mjs +1 -1
- package/dist/components/form/NewOneClickForm/react/ui/form.context.d.ts +6 -0
- package/dist/components/form/OTPInput.d.ts +5 -0
- package/dist/components/form/OTPInput.mjs +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ interface DateInputProps extends Omit<TextFieldProps, 'onBlur' | 'onChange'> {
|
|
|
16
16
|
InputProps?: TextFieldProps['InputProps'] & {
|
|
17
17
|
'data-mask-me'?: boolean;
|
|
18
18
|
};
|
|
19
|
+
redactYear?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export declare const DateInput: import('react').ForwardRefExoticComponent<Omit<Readonly<DateInputProps>, "ref"> & import('react').RefAttributes<unknown>>;
|
|
21
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef as
|
|
1
|
+
"use strict";import{forwardRef as Y,useState as I,useRef as A,useMemo as N}from"react";import{TextField as P,Box as R,Stack as $,IconButton as z}from"@mui/material";import{CalendarToday as E}from"@mui/icons-material";import _ from"../../../node_modules/react-datepicker/dist/es/index.mjs";import{useOnClickOutside as W}from"../../../hooks/useOnClickOutside.mjs";import j from"../../../styles/lib/react-datepicker.css.mjs";import{masks as B}from"../../../utils/masks/index.mjs";import{InputMask as K}from"../InputMask.mjs";import{TextMaskCustom as q}from"../TextMaskCustom.mjs";import{jsxs as O,Fragment as G,jsx as n}from"react/jsx-runtime";const H=_.default??_,J=Y(function(t,s){return n($,{ref:s,sx:{position:"relative"},children:n(z,{edge:"end",size:"small",onClick:()=>{var i;t.disabled||(i=t.onFocus)==null||i.call(t)},disabled:t.disabled,children:n(E,{fontSize:"small"})})})}),L=function({value:t,onChange:s,defaultSelectedDate:i,overflow:h=!1,clickOutsideBoundaryElement:a,minDate:g,maxDate:m,disabled:D}){const[w,c]=I(!1),v=A(null),C=new Date("08/01/1989"),x=g??new Date(1900,0,1),u=m??new Date,r=e=>{if(!e||!(e instanceof Date)||isNaN(e.getTime()))return"";try{const o=e.getDate().toString().padStart(2,"0"),d=(e.getMonth()+1).toString().padStart(2,"0"),l=e.getFullYear();return d==="00"||d>"12"||o==="00"||o>"31"||l<1900||l>u.getFullYear()?"":`${d}/${o}/${l}`}catch{return""}},b=N(()=>{if(!t)return i??void 0;const e=new Date(t);return isNaN(+e)||!/^\d{2}\/\d{2}\/\d{4}$/.test(t)||e<x||e>u?C:e},[t]);return W(v,()=>{c(!1)},"mousedown",{},a),O(R,{ref:v,sx:{position:"relative","& .react-datepicker-popper":h?{transform:"translate(calc(-100% + 32px), calc(-50% + 10px))!important"}:{}},children:[n("style",{children:j}),n(H,{open:w,onFocus:()=>{c(e=>!e)},popperPlacement:"bottom-end",placeholderText:"MM/DD/YYYY",showPopperArrow:!1,showYearDropdown:!0,showMonthDropdown:!0,scrollableYearDropdown:!1,dateFormat:"MM/dd/yyyy",minDate:x,maxDate:u,selected:b,dropdownMode:"select",onSelect:e=>{const o=r(e);o&&(s?.({target:{value:o}}),c(!1))},disabled:D,customInput:n(J,{disabled:D})})]})};function V({label:t="Date",value:s,error:i,helperText:h,onChange:a,onBlur:g,disabled:m,pickerDefaultSelectedDate:D,pickerClickOutsideBoundaryElement:w,pickerInputOverflow:c=!1,inputMaskProps:v,minDate:C,maxDate:x,redactYear:u=!1,...r},b){var e;const[o,d]=I(""),l=s!==void 0,p=l?s:o,M=f=>{const k=f.target.value;l||d(k),a&&a(k)},y=O(G,{children:[!u&&n(L,{onChange:M,value:p,overflow:c,clickOutsideBoundaryElement:w,defaultSelectedDate:D,minDate:C,maxDate:x,disabled:m}),(e=r.InputProps)==null?void 0:e.endAdornment]}),S={flex:1,"& input":{boxShadow:"none!important",border:"none!important",letterSpacing:"1px"}};if(u)return n(P,{label:t,error:i,helperText:h,fullWidth:!0,...r,autoComplete:"bday",inputRef:b,value:p?.replace(/-/g,"")??"",onChange:((f,k)=>{if(!k)return;const F=p?.replace(/\//g,"")??"";if(f.target.value.replace(/\//g,"").length<F.length){a?.(""),l||d("");return}a?.(f.target.value),l||d(f.target.value)}),onBlur:g,disabled:m,placeholder:"__/__/____",inputProps:{...r.inputProps,useOnComplete:!1,unmask:!1,lazy:!0,mask:"00/00/YYYY",definitions:{Y:{mask:/[0-9•]/,displayChar:"\u2022"}},placeholderChar:"_",inputMode:"numeric",overwrite:!1,tabIndex:0},InputProps:{...r.InputProps,inputComponent:q,endAdornment:y},sx:S});const T={label:t,error:i,helperText:h,fullWidth:!0,...r,autoComplete:"bday",inputProps:{...r.inputProps,inputMode:"numeric",tabIndex:0,mask:B.DOB_MASK},InputProps:{...r.InputProps,endAdornment:y}};return n(K,{mask:B.DOB_MASK,maskPlaceholder:null,disabled:m,value:p,onBlur:g,onChange:M,...v,children:n(P,{...T,inputRef:b,fullWidth:!0,sx:S})})}const Q=Y(V);export{Q as DateInput};
|
|
@@ -20,6 +20,7 @@ export interface InputMaskProps {
|
|
|
20
20
|
onBlur?: ChangeEventHandler<HTMLInputElement>;
|
|
21
21
|
beforeMaskedStateChange?: (options: BeforeMaskedStateChangeOptions) => void;
|
|
22
22
|
maskPlaceholder?: string | null;
|
|
23
|
+
onFocus?: () => void;
|
|
23
24
|
alwaysShowMask?: boolean;
|
|
24
25
|
disabled?: boolean;
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useRef as
|
|
1
|
+
"use strict";import{useRef as S,useState as A}from"react";import{Box as I}from"@mui/material";import{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 V}from"../shared.mjs";import{FieldLabel as E}from"./label.mjs";import{ClearFieldAdornment as R}from"./clear-field-adornment.mjs";import{jsx as l}from"react/jsx-runtime";import{fieldInputTypes as j}from"../../../../core/fields/constants.mjs";import{DateInput as z}from"../../../../../DateInput/index.mjs";function L({fieldKey:s}){var o,n,m;const{options:u}=P(),{field:e,setValue:t}=O({key:s}),p=S(null),[c,d]=A(e!=null&&e.value?K(e?.value):"");if(!e||e.schema.characteristics.inputType!==j.date)return null;const a=e.schema.key===N.birthDate,r=new Date,f=1900,D=1,h=1,C=a?r.getUTCFullYear()-18:r.getUTCFullYear()+100,g=a?r.getUTCMonth()+1:12,b=a?r.getUTCDate():31,k=new Date(f,D-1,h),y=new Date(C,g-1,b),v=i=>{if(e.isDisabled)return;const T=B.safeParse(i),Y=i.replace(/[^0-9]/g,"");if(d(i),Y.length<=0)return t("");if(!T.success)return t("NaN");const[U,w,x]=i.split("/").map(Number),M=Date.UTC(x,U-1,w,12,0,0,0);t(String(M))},F=()=>{d(""),t("")};return l(I,{width:"100%",children:l(z,{inputRef:p,variant:"outlined",size:"small",autoComplete:V(e.schema.key),label:l(E,{fieldKey:s}),value:c,onChange:v,error:!(e!=null&&e.isValid),helperText:(o=e.errorMessage)!=null&&o.length?e.errorMessage:e?.description,placeholder:e.schema.characteristics.placeholder,pickerClickOutsideBoundaryElement:u.features.datePickerClickOutsideBoundaryElement,pickerDefaultSelectedDate:new Date("08/01/1989"),minDate:k,maxDate:y,disabled:e.isDisabled,redactYear:a&&((m=(n=u.features.field)==null?void 0:n.dob)==null?void 0:m.redactYear),InputProps:{"data-mask-me":!0,endAdornment:l(R,{fieldKey:s,onClick:F,disabled:e.isDisabled})}})})}export{L as DateInputField};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { FormField } from '../../../core/form';
|
|
2
|
+
import { OneClickFormOptions } from '../form.context';
|
|
2
3
|
/**
|
|
3
4
|
* Makes attributes for a field.
|
|
4
5
|
* @param field The field to make attributes for.
|
|
5
6
|
* @returns The attributes for the field.
|
|
6
7
|
*/
|
|
7
|
-
export declare const makeAttributes: ({ userPrivacyEnabled, field, fieldKey, }: {
|
|
8
|
+
export declare const makeAttributes: ({ userPrivacyEnabled, field, fieldKey, options, }: {
|
|
8
9
|
userPrivacyEnabled?: boolean;
|
|
9
10
|
field: FormField | undefined;
|
|
10
11
|
fieldKey: string;
|
|
12
|
+
options: OneClickFormOptions;
|
|
11
13
|
}) => {
|
|
12
14
|
role: string;
|
|
13
15
|
'aria-label': string | undefined;
|
|
14
16
|
'data-testid': string;
|
|
15
|
-
'data-verified-sdk-field-value':
|
|
17
|
+
'data-verified-sdk-field-value': ReturnType<typeof getFieldValue>;
|
|
16
18
|
};
|
|
17
19
|
/**
|
|
18
20
|
* Returns the autocomplete attribute value based on the type of the field.
|
|
@@ -25,4 +27,34 @@ export declare function getAutoCompleteAttributeValue(key: string): "off" | "tel
|
|
|
25
27
|
* @param field The field to get the value from.
|
|
26
28
|
* @returns The value or display value of the field.
|
|
27
29
|
*/
|
|
28
|
-
export declare const getFieldValue: (field: FormField) =>
|
|
30
|
+
export declare const getFieldValue: (field: FormField, options: OneClickFormOptions) => string | {
|
|
31
|
+
memberId: string;
|
|
32
|
+
payer: {
|
|
33
|
+
name: string;
|
|
34
|
+
verifiedId: string;
|
|
35
|
+
logoUrl?: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
id?: number | undefined;
|
|
38
|
+
} | {
|
|
39
|
+
firstName?: string | undefined;
|
|
40
|
+
lastName?: string | undefined;
|
|
41
|
+
middleName?: string | undefined;
|
|
42
|
+
} | {
|
|
43
|
+
line1?: string | undefined;
|
|
44
|
+
line2?: string | undefined;
|
|
45
|
+
city?: string | undefined;
|
|
46
|
+
state?: string | undefined;
|
|
47
|
+
country?: string | undefined;
|
|
48
|
+
zipCode?: string | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
documentNumber?: string | undefined;
|
|
51
|
+
issuanceState?: string | undefined;
|
|
52
|
+
issuanceDate?: string | undefined;
|
|
53
|
+
expirationDate?: string | undefined;
|
|
54
|
+
address?: undefined;
|
|
55
|
+
} | null | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get the display value for a field, applying feature-flag-driven
|
|
58
|
+
* transformations (e.g. year redaction for DOB).
|
|
59
|
+
*/
|
|
60
|
+
export declare const getFieldDisplayValue: (field: FormField, options: OneClickFormOptions) => string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{credentialKeys as a}from"../../../core/fields/index.mjs";import{fieldInputTypes as
|
|
1
|
+
"use strict";import{credentialKeys as a}from"../../../core/fields/index.mjs";import{fieldInputTypes as o}from"../../../core/fields/constants.mjs";const c=({userPrivacyEnabled:e,field:t,fieldKey:i,options:l})=>{const s={role:"region","aria-label":t?.schema.characteristics.label,"data-testid":t?.schema.characteristics.inputType===o.composite?`data-field-composite-${i}`:`data-field-atomic-${i}`,"data-verified-sdk-field-value":void 0};return e||(s["data-verified-sdk-field-value"]=t?d(t,l):void 0),s};function n(e){return e===a.firstName?"given-name":e===a.lastName?"family-name":e===a.phone?"tel":e===a.address?"street-address address-level2 address-level1 postal-code":e===a.line2?"address-line2":"off"}const d=(e,t)=>{if(!(typeof e.value=="object"&&e.schema.key!==a.address&&e.schema.key!==a.healthInsurance))return e.schema.key===a.state||e.schema.key===a.issuanceState||e.schema.key===a.birthDate||e.schema.key===a.expirationDate||e.schema.key===a.issuanceDate?e.value:r(e,t)},r=(e,t)=>{var i,l;const s=e.displayValue;return(l=(i=t.features.field)==null?void 0:i.dob)!=null&&l.redactYear&&e.schema.key===a.birthDate&&typeof s=="string"?s.replace(/\/\d{4}$/,"/\u2022\u2022\u2022\u2022"):s};export{n as getAutoCompleteAttributeValue,r as getFieldDisplayValue,d as getFieldValue,c as makeAttributes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Stack as l,Typography as
|
|
1
|
+
"use strict";import{Stack as l,Typography as a}from"@mui/material";import{useFormField as o}from"../../core/field.hook.mjs";import{makeAttributes as x,getFieldDisplayValue as b}from"./shared.mjs";import{useOneClickForm as c}from"../form.context.mjs";import{jsx as t,jsxs as f}from"react/jsx-runtime";function p({label:e,sx:i}){return t(l,{sx:{flexShrink:0,alignItems:"flex-start",justifyContent:"flex-start",width:100,mt:.7,...i},children:t(a,{component:"span",variant:"subtitle2",textTransform:"uppercase",color:"text.primary",sx:{position:"relative",fontSize:12,fontWeight:700,textAlign:"left",alignSelf:"flex-start",letterSpacing:1},children:e})})}function d({fieldKey:e,label:i,sx:n}){const{fieldProps:r}=o({key:e}),s=i??r.label;return t(p,{label:s,sx:n})}function g({fieldKey:e}){const{field:i}=o({key:e}),{options:n}=c();if(!i)return null;const r=b(i,n);return t(a,{"data-mask-me":!0,variant:"body1",sx:{fontSize:20,fontWeight:300,wordBreak:"break-word",textAlign:"left"},children:r||(i!=null&&i.isRequired?null:"-")})}function u({description:e}){return t(a,{variant:"body1",color:"text.secondary",sx:{fontSize:12,fontWeight:400,wordBreak:"break-word",mt:.5,mr:1.75,textAlign:"left"},children:e})}function y({fieldKey:e,description:i}){const{fieldProps:n}=o({key:e}),r=i??n.description;return r?t(u,{description:r}):null}function m({fieldKey:e,children:i,spacing:n}){const r=c(),{field:s}=o({key:e}),h=x({userPrivacyEnabled:r.options.features.enableUserPrivacy,field:s,fieldKey:e,options:r.options});return t(l,{component:"section",...h,spacing:n,style:{width:"100%"},children:i})}function k({fieldKey:e,children:i}){return t(m,{fieldKey:e,children:f(l,{direction:"row",width:"100%",children:[t(d,{fieldKey:e}),t(l,{direction:"column",children:i})]})})}function F({fieldKey:e,description:i}){return f(l,{children:[t(d,{fieldKey:e,sx:{width:"100%",mt:0}}),t(y,{fieldKey:e,description:i})]})}function w({children:e,spacing:i,sx:n}){return t(l,{spacing:i,sx:{pl:2,borderLeftWidth:1,borderLeftColor:"neutral.main",borderLeftStyle:"solid",...n},children:e})}export{y as FieldDescription,u as FieldDescriptionBase,d as FieldLabel,p as FieldLabelBase,k as FieldRow,m as FieldRowContainer,w as FieldSectionContent,F as FieldSectionTitle,g as FieldValue};
|
|
@@ -8,6 +8,12 @@ type OneClickOptionFeatures = {
|
|
|
8
8
|
editMode?: {
|
|
9
9
|
hide?: boolean;
|
|
10
10
|
};
|
|
11
|
+
field?: {
|
|
12
|
+
dob?: {
|
|
13
|
+
/** When true, masks the year portion of the DOB field as ••••. */
|
|
14
|
+
redactYear?: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
11
17
|
};
|
|
12
18
|
type OneClickOptionServicePaths = {
|
|
13
19
|
googlePlacesAutocompletePlaces?: (input: string, signal?: AbortSignal) => Promise<unknown>;
|
|
@@ -14,6 +14,11 @@ interface OTPInputProps {
|
|
|
14
14
|
* ID of the element that labels this component (for accessibility)
|
|
15
15
|
*/
|
|
16
16
|
ariaLabelledBy?: string;
|
|
17
|
+
/**
|
|
18
|
+
* When true, adds data attributes to prevent password managers and autofill apps from interacting with the inputs.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
disableAutoFillApps?: boolean;
|
|
17
22
|
}
|
|
18
23
|
export type OTPInputInstance = Readonly<{
|
|
19
24
|
focus: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef as q,useRef as b,useState as
|
|
1
|
+
"use strict";import{forwardRef as q,useRef as b,useState as F,useImperativeHandle as H,useMemo as L,useCallback as m}from"react";import{useTheme as O,FormControl as U,InputBase as G,Box as J,TextField as N,Stack as Q,Typography as V}from"@mui/material";import{v4 as X}from"uuid";import{jsx as g,jsxs as R}from"react/jsx-runtime";function Y(t,$){const i=O(),C=b(Array.from({length:6},()=>X())),[f,h]=F([]),c=b(null),a=b([]),x=b(null),[z,k]=F(!1);H($,()=>({get value(){return f.join("")},set value(e){var n;h(e.split("")),(n=t.onChange)==null||n.call(t,{target:{value:e}})},focus(){var e,n;(e=a.current[0])==null||e.click(),(n=a.current[0])==null||n.focus()},blur(){a.current.forEach(e=>e?.blur())},clear(){h([])}}),[t,f]);const P={borderColor:t.error?i.palette.error.main:i.palette.action.disabled},B={borderColor:t.error?i.palette.error.main:i.palette.text.primary},M={borderColor:t.error?i.palette.error.main:i.palette.primary.main,boxShadow:`inset 0 0 0 1px ${t.error?i.palette.error.main:i.palette.primary.main}`},K={boxSizing:"content-box",direction:"row",alignItems:"center",spacing:1.25,sx:{"& input":{textAlign:"center",fontWeight:500,height:30,[i.breakpoints.down("xs")]:{height:16,fontSize:16,pt:1,pb:1,px:1},[i.breakpoints.up("xs")]:{fontSize:28,px:1},fontSize:32,py:1.75,borderRadius:1,borderStyle:"solid",borderWidth:1,...P},...!t.disabled&&{"&:hover input":{...B}},...z&&{"& input, &:hover input":{...M}}}},y=L(()=>({inputProps:{inputMode:"numeric",pattern:"[0-9]*",autoCorrect:"off",autoCapitalize:"off",...t.disableAutoFillApps&&{"data-op-ignore":!0,"data-lpignore":!0,"data-form-type":"other","data-bwignore":!0,"data-protonpass-ignore":!0}}}),[t.disableAutoFillApps]),A=m(e=>{var n;const r=e.target.value.replace(/[^0-9]/g,"");if(r.length===6&&/^\d{6}$/.test(r)){const p=r.split("");c.current&&(c.current.value=r),(n=t.onChange)==null||n.call(t,{target:{value:r}}),a.current.forEach(v=>v?.blur()),h(p);return}const u=e.currentTarget.ownerDocument,o=a.current.findIndex(p=>p===u.activeElement),l=r.charAt(r.length-1);!l||!/^[0-9]$/.test(l)||h(p=>{var v,D;const d=[...p];if(o!==-1)d[o]=l;else{const s=d.findIndex(W=>!W);s!==-1?d[s]=l:d.length<6&&d.push(l)}const w=d.join("");if(c.current&&(c.current.value=w),w.length===6)a.current.forEach(s=>s?.blur()),(v=t.onChange)==null||v.call(t,{target:{value:w}});else{const s=o!==-1?o+1:0;s<6&&((D=a.current[s])==null||D.focus())}return d})},[t]),S=m(e=>{e.key==="Backspace"&&h(n=>{var r;const u=[...n.slice(0,-1)];c.current&&(c.current.value=u.join(""));const o=u.length;return o>=0&&o<6&&((r=a.current[o])==null||r.focus()),u})},[]),E=m(e=>{var n,r;const u=e.currentTarget.ownerDocument,o=a.current.findIndex(p=>p===u.activeElement);if(o===-1)return;let l=o;switch(e.key){case"ArrowLeft":l=Math.max(0,o-1);break;case"ArrowRight":l=Math.min(5,o+1);break;default:return}l!==o&&(e.preventDefault(),(n=a.current[l])==null||n.focus(),(r=a.current[l])==null||r.select())},[]),I=m(()=>{k(!0)},[]),T=m(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{var e;const n=(e=a.current[0])==null?void 0:e.ownerDocument;a.current.some(r=>r&&r===n?.activeElement)||k(!1)},0)},[]),j=m(e=>new Array(3).fill(void 0).map((n,r)=>g(U,{children:g(G,{inputRef:u=>a.current[r+e]=u,id:C.current[r+e],name:`otp-input-${r+e}`,autoComplete:r+e===0?t.autoComplete??"one-time-code":void 0,autoFocus:r+e===0,value:f[r+e]||"",disabled:t.disabled,onChange:A,onKeyUp:S,onKeyDown:E,onFocus:I,onBlur:T,tabIndex:r+e+1,...y,"data-testid":`otp-input-${r+e}`,inputProps:{...y.inputProps,"aria-required":"true","aria-invalid":t.error?"true":"false","aria-label":`Digit ${r+e+1} of 6`}})},C.current[r+e])),[A,I,S,E,T,f,y,t.autoComplete,t.disabled]);return R(J,{width:"100%",sx:t.sx,children:[g("div",{style:{display:"none!important",pointerEvents:"none"},children:g(N,{inputRef:c,name:t.name,type:"text",value:f.join("")||"",sx:{pointerEvents:"none",display:"none"},inputProps:{hidden:!0}})}),R(Q,{"data-testid":"otp-input-container",...K,children:[j(0),g(V,{sx:{fontWeight:"700",fontSize:32},children:"-"}),j(3)]})]})}const _=q(Y);export{_ as OTPInput};
|