@verifiedinc-public/shared-ui-elements 12.8.3 → 12.9.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,3 +1,3 @@
1
- "use strict";import{useMemo as c}from"react";import{useFormContext as y,useController as h}from"react-hook-form";import{Autocomplete as v,TextField as C}from"@mui/material";import{prettyField as F}from"../utils/prettyField.mjs";import{buildDataFieldValue as x}from"../utils/buildDataFieldValue.mjs";import{useCredentialRequestField as b}from"../contexts/CredentialRequestFieldContext.mjs";import{DataFieldSection as g}from"./DataFieldSection.mjs";import{jsx as n}from"react/jsx-runtime";function S(){const e=b(),s=y(),p=h({name:`${e?.path}`}),a=c(()=>{const t={PhoneCredential:0,FullNameCredential:1,AddressCredential:2,BirthDateCredential:3,SsnCredential:4,SexCredential:5,EmployerCredential:6},r=e?.path??"",l=e?.index??0,o=r.split(".").slice(0,-1).join("."),m=s.getValues(o),f=new Set(m?.map((i,d)=>d!==l?i.type:null).filter(i=>i!==null)??[]);return Object.keys(t).map(i=>({label:F(i),id:i})).filter(i=>!f.has(i.id)).sort((i,d)=>t[i.id]-t[d.id])},[e,s]),u=c(()=>{var t,r;const l=(r=(t=p.field)==null?void 0:t.value)==null?void 0:r.type;return a?.find(o=>o.id===l)},[p,a]);return n(g,{title:"Field Type",description:"What type of user data this field is for",tip:n("pre",{children:`{
1
+ "use strict";import{useMemo as c}from"react";import{useFormContext as y,useController as h}from"react-hook-form";import{Autocomplete as v,TextField as C}from"@mui/material";import{prettyField as F}from"../utils/prettyField.mjs";import{buildDataFieldValue as x}from"../utils/buildDataFieldValue.mjs";import{useCredentialRequestField as b}from"../contexts/CredentialRequestFieldContext.mjs";import{DataFieldSection as g}from"./DataFieldSection.mjs";import{jsx as n}from"react/jsx-runtime";function S(){const e=b(),s=y(),p=h({name:`${e?.path}`}),a=c(()=>{const t={PhoneCredential:0,FullNameCredential:1,AddressCredential:2,BirthDateCredential:3,SsnCredential:4,SexCredential:5},o=e?.path??"",i=e?.index??0,r=o.split(".").slice(0,-1).join("."),m=s.getValues(r),f=new Set(m?.map((l,d)=>d!==i?l.type:null).filter(l=>l!==null)??[]);return Object.keys(t).map(l=>({label:F(l),id:l})).filter(l=>!f.has(l.id)).sort((l,d)=>t[l.id]-t[d.id])},[e,s]),u=c(()=>{var t,o;const i=(o=(t=p.field)==null?void 0:t.value)==null?void 0:o.type;return a?.find(r=>r.id===i)},[p,a]);return n(g,{title:"Field Type",description:"What type of user data this field is for",tip:n("pre",{children:`{
2
2
  type: string
3
- }`}),children:n(v,{value:u,onChange:(t,r)=>{if(!r)return;const l=x(r.id),o={type:l.type,mandatory:l.mandatory,description:l.description,allowUserInput:l.allowUserInput,multi:l.multi,children:l.children};e?.fieldArray.update(e?.index,o)},options:a,disablePortal:!0,renderInput:t=>n(C,{...t,label:"Type",color:"success",size:"small",className:"original",fullWidth:!0,inputProps:{...t.inputProps,"data-testid":"custom-demo-dialog-data-field-type-input"},placeholder:"Choose a type..."}),disabled:(e?.level??0)>0})},JSON.stringify(u))}export{S as DataFieldOptionType};
3
+ }`}),children:n(v,{value:u,onChange:(t,o)=>{if(!o)return;const i=x(o.id),r={type:i.type,mandatory:i.mandatory,description:i.description,allowUserInput:i.allowUserInput,multi:i.multi,children:i.children};e?.fieldArray.update(e?.index,r)},options:a,disablePortal:!0,renderInput:t=>n(C,{...t,label:"Type",color:"success",size:"small",className:"original",fullWidth:!0,inputProps:{...t.inputProps,"data-testid":"custom-demo-dialog-data-field-type-input"},placeholder:"Choose a type..."}),disabled:(e?.level??0)>0})},JSON.stringify(u))}export{S as DataFieldOptionType};
@@ -1,11 +1,16 @@
1
- import { BasePhoneInputProps } from '.';
1
+ import { PrettyPhoneInputProps } from './PrettyPhoneInput';
2
+ export interface PhoneInputProps extends PrettyPhoneInputProps {
3
+ /**
4
+ * Whether to render the phone input in a pretty way (animated gradient border). Defaults to false.
5
+ */
6
+ pretty?: boolean;
7
+ }
2
8
  /**
3
9
  * Renders a phone input component.
4
10
  *
5
11
  * @param props - The props for the phone input component.
6
12
  * @param props.pretty - Whether to render the phone input in a pretty way.
13
+ * @param props.loading - Whether to show the loading indicator. Only the pretty variant renders one.
7
14
  * @returns The phone input component.
8
15
  */
9
- export declare function PhoneInput(props: Readonly<BasePhoneInputProps & {
10
- pretty?: boolean;
11
- }>): import("react").JSX.Element;
16
+ export declare function PhoneInput({ pretty, loading, ...props }: Readonly<PhoneInputProps>): React.JSX.Element;
@@ -1 +1 @@
1
- "use strict";import{jsx as o}from"react/jsx-runtime";import{PrettyPhoneInput as t}from"./PrettyPhoneInput.mjs";import{BasePhoneInput as n}from"./BasePhoneInput.mjs";function e(r){return r.pretty?o(t,{...r}):o(n,{...r})}export{e as PhoneInput};
1
+ "use strict";import{BasePhoneInput as e}from"./BasePhoneInput.mjs";import{PrettyPhoneInput as p}from"./PrettyPhoneInput.mjs";import{jsx as r}from"react/jsx-runtime";function a({pretty:t=!1,loading:n,...o}){return t?r(p,{...o,loading:n}):r(e,{...o})}export{a as PhoneInput};
@@ -1,2 +1,16 @@
1
1
  import { BasePhoneInputProps } from './BasePhoneInput';
2
- export declare function PrettyPhoneInput(props: Readonly<BasePhoneInputProps>): React.JSX.Element;
2
+ export interface PrettyPhoneInputProps extends BasePhoneInputProps {
3
+ /**
4
+ * Whether the input is waiting on something (e.g. a lookup triggered by the typed number).
5
+ * The beam lapping the border speeds up while true so it reads as a loading indicator. Defaults to false.
6
+ */
7
+ loading?: boolean;
8
+ }
9
+ /**
10
+ * Renders the phone input wrapped in a gradient border with a beam of light lapping it at a constant
11
+ * speed: slowly while idle, quickly while loading.
12
+ *
13
+ * @param loading - Whether to show the loading indicator (the beam laps the border quickly). Defaults to false.
14
+ * @param props - Every other prop is forwarded to `BasePhoneInput`.
15
+ */
16
+ export declare function PrettyPhoneInput({ loading, ...props }: Readonly<PrettyPhoneInputProps>): React.JSX.Element;
@@ -1,64 +1,32 @@
1
- "use strict";import{useTheme as g,keyframes as n,Box as p}from"@mui/material";import{alpha as c,darken as l}from"../../utils/color/index.mjs";import{BasePhoneInput as b}from"./BasePhoneInput.mjs";import{jsx as a}from"react/jsx-runtime";function m(t){const o=g(),e=t.error?o.palette.error.main:o.palette.primary.main,r=c(l(e,10),.4),i=o.palette.background.paper,d=n`
2
- 0% {
3
- transform: rotate(0deg);
4
- }
5
- 20% {
6
- transform: rotate(80deg);
7
- }
8
- 25% {
9
- transform: rotate(90deg);
10
- }
11
- 45% {
12
- transform: rotate(170deg);
13
- }
14
- 50% {
15
- transform: rotate(180deg);
16
- }
17
- 70% {
18
- transform: rotate(260deg);
19
- }
20
- 75% {
21
- transform: rotate(270deg);
22
- }
23
- 95% {
24
- transform: rotate(350deg);
25
- }
26
- 100% {
27
- transform: rotate(360deg);
28
- }
29
- `,u=n`
30
- 0% {
31
- background-size: 100% 100%;
32
- }
33
- 50% {
34
- background-size: 110% 110%;
35
- }
36
- 100% {
37
- background-size: 100% 100%;
38
- }
39
- `,s=n`
40
- 0% {
41
- background-position: 0% 0%;
42
- }
43
- 25% {
44
- background-position: 100% 100%;
45
- }
46
- 50% {
47
- background-position: 100% 100%;
48
- }
49
- 75% {
50
- background-position: 100% 100%;
51
- }
52
- 100% {
53
- background-position: 0% 0%;
54
- }
55
- `;return a(p,{width:"100%",sx:{position:"relative",zIndex:0,"& label.MuiFormLabel-root":{background:i},"& .MuiOutlinedInput-root":{position:"relative",overflow:"hidden","&::before":{content:'""',position:"absolute",width:"calc(100% + 8px)",aspectRatio:1,left:-4,zIndex:-1,background:`conic-gradient(
56
- from 45deg,
57
- ${e} 0deg,
58
- ${e} 60deg,
59
- ${r} 95deg,
60
- rgba(255,255,255,1) 105deg,
61
- ${r} 115deg,
62
- ${e} 150deg,
63
- ${e} 360deg
64
- )`,animation:`${d} 8s linear infinite, ${u} 3s linear infinite, ${s} 12s linear infinite`,backgroundOrigin:"border-box",backgroundPosition:"center",backgroundSize:"100% 100%"}},"& .MuiOutlinedInput-notchedOutline":{border:"none",zIndex:-1,m:.25,top:0,"&::before":{content:'""',position:"absolute",inset:0,backgroundColor:i,zIndex:-1},"& legend":{display:"none"}},"& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}},children:a(b,{...t})})}export{m as PrettyPhoneInput};
1
+ "use strict";import{useRef as v,useState as C,useEffect as g}from"react";import{useTheme as R,Box as T,keyframes as h}from"@mui/material";import{alpha as j,darken as B}from"../../utils/color/index.mjs";import{BasePhoneInput as E}from"./BasePhoneInput.mjs";import{jsx as y}from"react/jsx-runtime";const V=8,q=.8,m="--ppi-progress",O=160,I=36,w={start:-O/2,"start-shoulder":-I/2,core:0,"end-shoulder":I/2,end:O/2},A=h`
2
+ from {
3
+ ${m}: 0;
4
+ }
5
+ to {
6
+ ${m}: 1;
7
+ }
8
+ `,D=h`
9
+ from {
10
+ transform: rotate(0deg);
11
+ }
12
+ to {
13
+ transform: rotate(360deg);
14
+ }
15
+ `,x=new WeakSet;function F(e){const o=e.ownerDocument,n=o.defaultView;if(!n||typeof n.CSS>"u"||typeof n.CSS.registerProperty!="function")return!1;if(x.has(o))return!0;try{n.CSS.registerProperty({name:m,syntax:"<number>",inherits:!1,initialValue:"0"})}catch(t){if(t.name!=="InvalidModificationError")return!1}return x.add(o),!0}function L(e){const o=w[e],n=`var(--ppi-d-${e})`,t="var(--ppi-p)",d={[`--ppi-d-${e}`]:`calc(var(${m}) * ${t} ${o<0?"-":"+"} ${Math.abs(o)})`,[`--ppi-x-${e}`]:`clamp(-1 * var(--ppi-a), abs(mod(${n} + ${t} * 0.75, ${t}) - ${t} / 2) - ${t} / 4, var(--ppi-a))`,[`--ppi-y-${e}`]:`clamp(-1 * var(--ppi-b), ${t} / 4 - abs(mod(${n}, ${t}) - ${t} / 2), var(--ppi-b))`,[`--ppi-t-${e}`]:`atan2(var(--ppi-x-${e}), -1 * var(--ppi-y-${e}))`};return e!=="start"&&(d[`--ppi-s-${e}`]=`mod(var(--ppi-t-${e}) - var(--ppi-t-start), 360deg)`),d}const G={"--ppi-a":"calc(var(--ppi-w) / 2)","--ppi-b":"calc(var(--ppi-h) / 2)","--ppi-p":"calc(4 * (var(--ppi-a) + var(--ppi-b)))",...Object.assign({},...Object.keys(w).map(L))};function N({loading:e=!1,...o}){const n=R(),t=v(null),[d,S]=C(!1),a=e?q:V,$=v(a),i=o.error?n.palette.error.main:n.palette.primary.main,c=j(B(i,10),.4),b=n.palette.background.paper;g(()=>{const r=t.current;r&&S(F(r))},[]),g(()=>{const r=t.current,u=r?.querySelector(".MuiOutlinedInput-root"),p=r?.ownerDocument.defaultView;if(!r||!u||!p||typeof p.ResizeObserver>"u")return;const s=new p.ResizeObserver(()=>{const{width:l,height:f}=u.getBoundingClientRect();r.style.setProperty("--ppi-w",String(l)),r.style.setProperty("--ppi-h",String(f))});return s.observe(u),()=>{s.disconnect()}},[]),g(()=>{var r;const u=$.current;$.current=a;const p=(r=t.current)==null?void 0:r.querySelector(".MuiOutlinedInput-root");if(!(u===a||!p||typeof p.getAnimations!="function"))for(const s of p.getAnimations({subtree:!0})){const l=s.effect;if(l?.pseudoElement!=="::before"||typeof s.currentTime!="number")continue;const f=u*1e3,z=s.currentTime%f/f;s.currentTime=z*a*1e3}},[a]);const k=`conic-gradient(
16
+ from var(--ppi-t-start),
17
+ ${i} 0deg,
18
+ ${c} var(--ppi-s-start-shoulder),
19
+ rgba(255,255,255,1) var(--ppi-s-core),
20
+ ${c} var(--ppi-s-end-shoulder),
21
+ ${i} var(--ppi-s-end),
22
+ ${i} 360deg
23
+ )`,M=`conic-gradient(
24
+ from 45deg,
25
+ ${i} 0deg,
26
+ ${i} 60deg,
27
+ ${c} 95deg,
28
+ rgba(255,255,255,1) 105deg,
29
+ ${c} 115deg,
30
+ ${i} 150deg,
31
+ ${i} 360deg
32
+ )`,P=d?{...G,background:k,animation:`${A} ${a}s linear infinite`}:{background:M,animation:`${D} ${a}s linear infinite`};return y(T,{ref:t,width:"100%","aria-busy":e||void 0,sx:{position:"relative",zIndex:0,"--ppi-w":"320","--ppi-h":"56","& label.MuiFormLabel-root":{background:b},"& .MuiOutlinedInput-root":{position:"relative",overflow:"hidden","&::before":{content:'""',position:"absolute",width:"calc(100% + 8px)",aspectRatio:1,left:-4,zIndex:-1,backgroundOrigin:"border-box",backgroundPosition:"center",backgroundSize:"100% 100%",...P}},"& .MuiOutlinedInput-notchedOutline":{border:"none",zIndex:-1,m:.25,top:0,"&::before":{content:'""',position:"absolute",inset:0,backgroundColor:b,zIndex:-1},"& legend":{display:"none"}},"& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}},children:y(E,{...o})})}export{N as PrettyPhoneInput};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "12.8.3",
3
+ "version": "12.9.0",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "sideEffects": false,