@verifiedinc-public/shared-ui-elements 12.8.0 → 12.8.2

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";import{useState as k}from"react";import{Stack as x,TextField as d}from"@mui/material";import{AddressInput as I}from"../../../../../AddressInput/index.mjs";import{useFormField as N}from"../../../core/field.hook.mjs";import{RequiredLabel as v}from"../shared.mjs";import{useOneClickForm as q}from"../../form.context.mjs";import{jsxs as F,jsx as o}from"react/jsx-runtime";function D({fieldKey:h}){var n,u;const{options:m}=q(),{field:a,setValue:P}=N({key:h}),[y,b]=k({});if(!a)return null;const p=a.value;if(!p)return null;const l=p.employer,r=e=>{b(s=>s[e]?s:{...s,[e]:!0})},i=e=>{P({employer:{...l,...e}})},C=((u=(n=a.errors)==null?void 0:n.error)==null?void 0:u.issues)??[],t=e=>{var s;if(!(!a.touched&&!y[e]))return(s=C.find(z=>z.path[1]===e))==null?void 0:s.message},c=t("name"),f=t("legalName"),g=t("address");return F(x,{spacing:2,children:[o(d,{fullWidth:!0,size:"small",label:o(v,{required:a.isRequired,children:"Name"}),value:l.name??"",onChange:e=>{i({name:e.target.value}),r("name")},onBlur:()=>r("name"),error:!!c,helperText:c,disabled:a.isDisabled,InputProps:{"data-mask-me":!0},inputProps:{autoCorrect:"off"}}),o(d,{fullWidth:!0,size:"small",label:"Legal Name",value:l.legalName??"",onChange:e=>{i({legalName:e.target.value||void 0}),r("legalName")},onBlur:()=>r("legalName"),error:!!f,helperText:f,disabled:a.isDisabled,InputProps:{"data-mask-me":!0},inputProps:{autoCorrect:"off"}}),o(I,{size:"small",label:o(v,{required:a.isRequired,children:"Address"}),defaultValue:{line1:l.address.line1,city:l.address.city,state:l.address.state,zipCode:l.address.zipCode,country:l.address.country??"US"},onChange:e=>{if(typeof e=="string")return;const s={line1:e?.line1,line2:l.address.line2??"",city:e?.city,state:e?.state,zipCode:e?.zipCode,country:e?.country==="US"?"US":void 0};i({address:s}),r("address")},onBlur:()=>r("address"),error:!!g,helperText:g,disabled:a.isDisabled,InputProps:{"data-mask-me":!0},service:{googlePlacesAutocompletePlaces:m.servicePaths.googlePlacesAutocompletePlaces,googlePlacesGetPlace:m.servicePaths.googlePlacesGetPlace}}),o(d,{fullWidth:!0,size:"small",label:"Line 2",value:l.address.line2??"",onChange:e=>i({address:{...l.address,line2:e.target.value}}),disabled:a.isDisabled,InputProps:{"data-mask-me":!0},inputProps:{autoCorrect:"off"}})]})}export{D as EmployerInputField};
1
+ "use strict";import{useState as z}from"react";import{Stack as F,TextField as m,Box as I}from"@mui/material";import{AddressInput as q}from"../../../../../AddressInput/index.mjs";import{useFormField as A}from"../../../core/field.hook.mjs";import{RequiredLabel as y,toFieldValueAttribute as o}from"../shared.mjs";import{useOneClickForm as S}from"../../form.context.mjs";import{jsxs as D,jsx as d}from"react/jsx-runtime";import{addressFormat as T}from"../../../../core/formats/address.format.mjs";function B({fieldKey:P}){var p,c;const{options:n}=S(),{field:l,setValue:b}=A({key:P}),[C,k]=z({});if(!l)return null;const f=l.value;if(!f)return null;const a=f.employer,r=e=>{k(s=>s[e]?s:{...s,[e]:!0})},i=e=>{b({employer:{...a,...e}})},t=n.features.enableUserPrivacy,N=((c=(p=l.errors)==null?void 0:p.error)==null?void 0:c.issues)??[],u=e=>{var s;if(!(!l.touched&&!C[e]))return(s=N.find(x=>x.path[1]===e))==null?void 0:s.message},v=u("name"),g=u("legalName"),h=u("address");return D(F,{spacing:2,children:[d(m,{"data-testid":"data-field-atomic-employer.name","data-verified-sdk-field-value":o(a.name,t),fullWidth:!0,size:"small",label:d(y,{required:l.isRequired,children:"Name"}),value:a.name??"",onChange:e=>{i({name:e.target.value}),r("name")},onBlur:()=>r("name"),error:!!v,helperText:v,disabled:l.isDisabled,InputProps:{"data-mask-me":!0},inputProps:{autoCorrect:"off"}}),d(m,{"data-testid":"data-field-atomic-employer.legalName","data-verified-sdk-field-value":o(a.legalName,t),fullWidth:!0,size:"small",label:"Legal Name",value:a.legalName??"",onChange:e=>{i({legalName:e.target.value||void 0}),r("legalName")},onBlur:()=>r("legalName"),error:!!g,helperText:g,disabled:l.isDisabled,InputProps:{"data-mask-me":!0},inputProps:{autoCorrect:"off"}}),d(I,{"data-testid":"data-field-composite-employer.address","data-verified-sdk-field-value":o(T(a.address),t),width:"100%",children:d(q,{size:"small",label:d(y,{required:l.isRequired,children:"Address"}),defaultValue:{line1:a.address.line1,city:a.address.city,state:a.address.state,zipCode:a.address.zipCode,country:a.address.country??"US"},onChange:e=>{if(typeof e=="string")return;const s={line1:e?.line1,line2:a.address.line2??"",city:e?.city,state:e?.state,zipCode:e?.zipCode,country:e?.country==="US"?"US":void 0};i({address:s}),r("address")},onBlur:()=>r("address"),error:!!h,helperText:h,disabled:l.isDisabled,InputProps:{"data-mask-me":!0},service:{googlePlacesAutocompletePlaces:n.servicePaths.googlePlacesAutocompletePlaces,googlePlacesGetPlace:n.servicePaths.googlePlacesGetPlace}})}),d(m,{"data-testid":"data-field-atomic-employer.address.line2","data-verified-sdk-field-value":o(a.address.line2,t),fullWidth:!0,size:"small",label:"Line 2",value:a.address.line2??"",onChange:e=>i({address:{...a.address,line2:e.target.value}}),disabled:l.isDisabled,InputProps:{"data-mask-me":!0},inputProps:{autoCorrect:"off"}})]})}export{B as EmployerInputField};
@@ -1 +1 @@
1
- "use strict";import{Stack as n,MenuItem as u,Typography as d}from"@mui/material";import{useFormField as p}from"../../../core/field.hook.mjs";import{FieldSectionTitle as f,FieldSectionContent as h,FieldLabelBase as v}from"../style.mjs";import{VariantSelectField as y}from"./variantSelect.field.mjs";import{jsxs as o,jsx as e}from"react/jsx-runtime";import{addressFormat as g}from"../../../../core/formats/address.format.mjs";function s({label:a,value:t}){return o(n,{direction:"row",children:[e(v,{label:a}),e(d,{"data-mask-me":!0,variant:"body1",sx:{fontSize:20,fontWeight:300,wordBreak:"break-word",textAlign:"left"},children:t})]})}function m({item:a}){return o(n,{spacing:1.25,children:[e(s,{label:"Name",value:a.name}),a.legalName&&e(s,{label:"Legal Name",value:a.legalName}),e(s,{label:"Address",value:g(a.address)??"-"})]})}function b({fieldKey:a}){var t;const{field:i}=p({key:a});if(!i)return null;if(!i.hasVariants){const l=(t=i.value)==null?void 0:t.employer;return l?o(n,{spacing:1.25,children:[e(f,{fieldKey:a}),e(h,{spacing:1.25,children:e(m,{item:l})})]}):null}const c=i.variants??[];return e(y,{fieldKey:a,testId:`data-employer-select-${a}`,renderValue:()=>{var l;const r=(l=i.value)==null?void 0:l.employer;return r?e(m,{item:r}):null},children:c.map(l=>e(u,{value:l.id,onClick:r=>r.stopPropagation(),sx:{maxWidth:"100%",whiteSpace:"pre-wrap"},children:e(d,{variant:"body1",fontWeight:500,children:l.displayValue??"-"})},l.id))})}export{b as EmployerField};
1
+ "use strict";import{Stack as o,MenuItem as f,Typography as u}from"@mui/material";import{useFormField as p}from"../../../core/field.hook.mjs";import{useOneClickForm as v}from"../../form.context.mjs";import{toFieldValueAttribute as n}from"../shared.mjs";import{FieldSectionTitle as y,FieldSectionContent as h,FieldLabelBase as g}from"../style.mjs";import{VariantSelectField as b}from"./variantSelect.field.mjs";import{jsxs as s,jsx as a}from"react/jsx-runtime";import{addressFormat as F}from"../../../../core/formats/address.format.mjs";function m({label:e,value:i,testId:l,fieldValue:r}){return s(o,{direction:"row","data-testid":l,"data-verified-sdk-field-value":r,children:[a(g,{label:e}),a(u,{"data-mask-me":!0,variant:"body1",sx:{fontSize:20,fontWeight:300,wordBreak:"break-word",textAlign:"left"},children:i})]})}function c({item:e}){const{options:i}=v(),l=i.features.enableUserPrivacy,r=F(e.address);return s(o,{spacing:1.25,children:[a(m,{label:"Name",value:e.name,testId:"data-field-atomic-employer.name",fieldValue:n(e.name,l)}),e.legalName&&a(m,{label:"Legal Name",value:e.legalName,testId:"data-field-atomic-employer.legalName",fieldValue:n(e.legalName,l)}),a(m,{label:"Address",value:r??"-",testId:"data-field-composite-employer.address",fieldValue:n(r,l)})]})}function V({fieldKey:e}){var i;const{field:l}=p({key:e});if(!l)return null;if(!l.hasVariants){const t=(i=l.value)==null?void 0:i.employer;return t?s(o,{spacing:1.25,children:[a(y,{fieldKey:e}),a(h,{spacing:1.25,children:a(c,{item:t})})]}):null}const r=l.variants??[];return a(b,{fieldKey:e,testId:`data-employer-select-${e}`,renderValue:()=>{var t;const d=(t=l.value)==null?void 0:t.employer;return d?a(c,{item:d}):null},children:r.map(t=>a(f,{value:t.id,onClick:d=>d.stopPropagation(),sx:{maxWidth:"100%",whiteSpace:"pre-wrap"},children:a(u,{variant:"body1",fontWeight:500,children:t.displayValue??"-"})},t.id))})}export{V as EmployerField};
@@ -1,5 +1,12 @@
1
1
  import { FormField } from '../../../core/form';
2
2
  import { OneClickFormOptions } from '../form.context';
3
+ /**
4
+ * Value for the `data-verified-sdk-field-value` attribute, withheld when user privacy is enabled.
5
+ * @param value The field value to expose.
6
+ * @param userPrivacyEnabled Whether the user privacy feature is enabled.
7
+ * @returns The value to expose, or undefined.
8
+ */
9
+ export declare const toFieldValueAttribute: <T>(value: T, userPrivacyEnabled?: boolean) => T | undefined;
3
10
  /**
4
11
  * Makes attributes for a field.
5
12
  * @param field The field to make attributes for.
@@ -14,7 +21,45 @@ export declare const makeAttributes: ({ userPrivacyEnabled, field, fieldKey, opt
14
21
  role: string;
15
22
  'aria-label': string | undefined;
16
23
  'data-testid': string;
17
- 'data-verified-sdk-field-value': ReturnType<typeof getFieldValue>;
24
+ 'data-verified-sdk-field-value': string | {
25
+ memberId: string;
26
+ payer: {
27
+ name: string;
28
+ verifiedId: string;
29
+ logoUrl?: string | null | undefined;
30
+ };
31
+ id?: number | undefined;
32
+ } | {
33
+ employer: {
34
+ address: {
35
+ line1?: string | undefined;
36
+ line2?: string | undefined;
37
+ city?: string | undefined;
38
+ state?: string | undefined;
39
+ country?: "US" | undefined;
40
+ zipCode?: string | undefined;
41
+ };
42
+ name: string;
43
+ legalName?: string | undefined;
44
+ };
45
+ } | {
46
+ firstName?: string | undefined;
47
+ lastName?: string | undefined;
48
+ middleName?: string | undefined;
49
+ } | {
50
+ line1?: string | undefined;
51
+ line2?: string | undefined;
52
+ city?: string | undefined;
53
+ state?: string | undefined;
54
+ country?: string | undefined;
55
+ zipCode?: string | undefined;
56
+ } | {
57
+ documentNumber?: string | undefined;
58
+ issuanceState?: string | undefined;
59
+ issuanceDate?: string | undefined;
60
+ expirationDate?: string | undefined;
61
+ address?: undefined;
62
+ } | null | undefined;
18
63
  };
19
64
  /**
20
65
  * Returns the autocomplete attribute value based on the type of the field.
@@ -1 +1 @@
1
- "use strict";import{Typography as c}from"@mui/material";import{credentialKeys as a}from"../../../core/fields/index.mjs";import{jsx as l,Fragment as d,jsxs as m}from"react/jsx-runtime";import{fieldInputTypes as u}from"../../../core/fields/constants.mjs";const p=({userPrivacyEnabled:e,field:s,fieldKey:i,options:r})=>{const t={role:"region","aria-label":s?.schema.characteristics.label,"data-testid":s?.schema.characteristics.inputType===u.composite?`data-field-composite-${i}`:`data-field-atomic-${i}`,"data-verified-sdk-field-value":void 0};return e||(t["data-verified-sdk-field-value"]=s?o(s,r):void 0),t};function f(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 o=(e,s)=>{if(!(typeof e.value=="object"&&e.schema.key!==a.address&&e.schema.key!==a.healthInsurance&&e.schema.key!==a.employer))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:n(e,s)},n=(e,s)=>{var i,r;const t=e.displayValue;return(r=(i=s.features.field)==null?void 0:i.dob)!=null&&r.redactYear&&e.schema.key===a.birthDate&&typeof t=="string"?t.replace(/\/\d{4}$/,"/\u2022\u2022\u2022\u2022"):t};function h({children:e,required:s}){return s?m(d,{children:[e," ",l(c,{"data-asterisk":!0,component:"span",color:"error",variant:"subtitle2",sx:{fontSize:"inherit"},children:"\u273D"})]}):l(d,{children:e})}export{h as RequiredLabel,f as getAutoCompleteAttributeValue,n as getFieldDisplayValue,o as getFieldValue,p as makeAttributes};
1
+ "use strict";import{Typography as m}from"@mui/material";import{credentialKeys as s}from"../../../core/fields/index.mjs";import{jsx as l,Fragment as o,jsxs as u}from"react/jsx-runtime";import{fieldInputTypes as p}from"../../../core/fields/constants.mjs";const d=(e,a)=>a?void 0:e,h=({userPrivacyEnabled:e,field:a,fieldKey:t,options:i})=>({role:"region","aria-label":a?.schema.characteristics.label,"data-testid":a?.schema.characteristics.inputType===p.composite?`data-field-composite-${t}`:`data-field-atomic-${t}`,"data-verified-sdk-field-value":d(a?n(a,i):void 0,e)});function f(e){return e===s.firstName?"given-name":e===s.lastName?"family-name":e===s.phone?"tel":e===s.address?"street-address address-level2 address-level1 postal-code":e===s.line2?"address-line2":"off"}const n=(e,a)=>{if(!(typeof e.value=="object"&&e.schema.key!==s.address&&e.schema.key!==s.healthInsurance&&e.schema.key!==s.employer))return e.schema.key===s.state||e.schema.key===s.issuanceState||e.schema.key===s.birthDate||e.schema.key===s.expirationDate||e.schema.key===s.issuanceDate?e.value:c(e,a)},c=(e,a)=>{var t,i;const r=e.displayValue;return(i=(t=a.features.field)==null?void 0:t.dob)!=null&&i.redactYear&&e.schema.key===s.birthDate&&typeof r=="string"?r.replace(/\/\d{4}$/,"/\u2022\u2022\u2022\u2022"):r};function y({children:e,required:a}){return a?u(o,{children:[e," ",l(m,{"data-asterisk":!0,component:"span",color:"error",variant:"subtitle2",sx:{fontSize:"inherit"},children:"\u273D"})]}):l(o,{children:e})}export{y as RequiredLabel,f as getAutoCompleteAttributeValue,c as getFieldDisplayValue,n as getFieldValue,h as makeAttributes,d as toFieldValueAttribute};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "12.8.0",
3
+ "version": "12.8.2",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "sideEffects": false,