@aws-amplify/ui-react 4.2.0 → 4.3.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
- import{jsx as s,Fragment as e}from"react/jsx-runtime";import*as i from"react";import{AuthenticatorProvider as o,useAuthenticator as r,useAuthenticatorInitMachine as t}from"@aws-amplify/ui-react-core";import{CustomComponentsContext as n}from"./hooks/useCustomComponents/index.js";import"../../primitives/View/View.js";import{Router as m}from"./Router/Router.js";import{SetupTOTP as a}from"./SetupTOTP/SetupTOTP.js";import{SignIn as p}from"./SignIn/SignIn.js";import{SignUp as u}from"./SignUp/SignUp.js";import{ForceNewPassword as c}from"./ForceNewPassword/ForceNewPassword.js";import"./ResetPassword/ConfirmResetPassword.js";import{ResetPassword as d}from"./ResetPassword/ResetPassword.js";import{defaultComponents as f}from"./hooks/useCustomComponents/defaultComponents.js";function g({children:o,className:a,components:p,formFields:u,hideSignUp:c,initialState:d,loginMechanisms:g,signUpAttributes:l,services:j,socialProviders:P,variation:w}){const{route:S,signOut:h,user:O}=r((({route:s,signOut:e,user:i})=>[s,e,i]));t({initialState:d,loginMechanisms:g,services:j,signUpAttributes:l,socialProviders:P,formFields:u});const v=i.useMemo((()=>({components:Object.assign(Object.assign({},f),p)})),[p]);return"authenticated"===S||"signOut"===S?o?s(e,{children:"function"==typeof o?o({signOut:h,user:O}):o}):null:s(n.Provider,Object.assign({value:v},{children:s(m,{className:a,hideSignUp:c,variation:w})}))}function l(e){return s(o,{children:s(g,Object.assign({},e))})}l.Provider=o,l.ResetPassword=d,l.SetupTOTP=a,l.SignIn=p,l.SignUp=u,l.ForceNewPassword=c;export{l as Authenticator,g as AuthenticatorInternal};
1
+ import{jsx as s,Fragment as e}from"react/jsx-runtime";import*as i from"react";import{configureComponent as o}from"@aws-amplify/ui";import{AuthenticatorProvider as r,useAuthenticator as t,useAuthenticatorInitMachine as n}from"@aws-amplify/ui-react-core";import{CustomComponentsContext as m}from"./hooks/useCustomComponents/index.js";import"../../primitives/View/View.js";import{Router as a}from"./Router/Router.js";import{SetupTOTP as p}from"./SetupTOTP/SetupTOTP.js";import{SignIn as u}from"./SignIn/SignIn.js";import{SignUp as c}from"./SignUp/SignUp.js";import{ForceNewPassword as f}from"./ForceNewPassword/ForceNewPassword.js";import"./ResetPassword/ConfirmResetPassword.js";import{ResetPassword as d}from"./ResetPassword/ResetPassword.js";import{defaultComponents as g}from"./hooks/useCustomComponents/defaultComponents.js";import{VERSION as l}from"../../version.js";function j({children:o,className:r,components:p,formFields:u,hideSignUp:c,initialState:f,loginMechanisms:d,signUpAttributes:l,services:j,socialProviders:w,variation:P}){const{route:S,signOut:v,user:h}=t((({route:s,signOut:e,user:i})=>[s,e,i]));n({initialState:f,loginMechanisms:d,services:j,signUpAttributes:l,socialProviders:w,formFields:u});const O=i.useMemo((()=>({components:Object.assign(Object.assign({},g),p)})),[p]);return"authenticated"===S||"signOut"===S?o?s(e,{children:"function"==typeof o?o({signOut:v,user:h}):o}):null:s(m.Provider,Object.assign({value:O},{children:s(a,{className:r,hideSignUp:c,variation:P})}))}function w(e){return i.useEffect((()=>{o({packageName:"@aws-amplify/ui-react",version:l})}),[]),s(r,{children:s(j,Object.assign({},e))})}w.Provider=r,w.ResetPassword=d,w.SetupTOTP=p,w.SignIn=u,w.SignUp=c,w.ForceNewPassword=f;export{w as Authenticator,j as AuthenticatorInternal};
@@ -1 +1 @@
1
- import*as e from"react";import{ARROW_UP as t,ARROW_DOWN as o,ENTER_KEY as n,ESCAPE_KEY as l}from"../shared/constants.js";import{isFunction as s}from"../shared/utils.js";import{useStableId as i}from"../utils/useStableId.js";const c=new Set([o,t,n,l]),a=({defaultValue:a="",value:u,options:r,optionFilter:d,onBlur:m,onChange:f,onClear:h,onClick:p,onSelect:g,onSubmit:b})=>{const C=void 0!==u,[I,v]=e.useState(a),k=C?u:I,[w,O]=e.useState(!1),[B,E]=e.useState(null),y=s(d),S=e.useMemo((()=>{const e=y?e=>d(e,k):e=>{const{label:t}=e;return null==t?void 0:t.toLocaleLowerCase().includes(null==k?void 0:k.toLocaleLowerCase())};return(null==r?void 0:r.filter(e))||[]}),[k,d,y,r]),T=i(),H=i(),L=i(),M=i(),V=S.findIndex((e=>e===B)),j=(null==B?void 0:B.id)||(-1!==V?`${M}-option-${V}`:void 0),x=e.useCallback((e=>{O(!1),E(null),s(m)&&m(e)}),[m]),D=e.useCallback((e=>{E(null),O(!0),C||v(e.target.value),s(f)&&f(e)}),[C,f]),F=e.useCallback((()=>{C||v(""),s(h)&&h()}),[C,h]),R=e.useCallback((e=>{O(!0),s(p)&&p(e)}),[p]);return e.useEffect((()=>{const e=document.getElementById(T),t=document.getElementById(L);if(t&&w){const{bottom:o}=t.getBoundingClientRect(),{offsetParent:n,offsetTop:l}=e;n===document.body&&o>document.documentElement.clientHeight&&window.scrollTo({top:Math.min(o-document.documentElement.clientHeight+window.scrollY+20,l),behavior:"smooth"})}}),[T,w,L]),e.useEffect((()=>{const e=document.getElementById(H),t=document.getElementById(j);if(t&&e){const{scrollTop:o,clientHeight:n}=e,{offsetHeight:l,offsetTop:s}=t,{top:i,bottom:c}=t.getBoundingClientRect();o>s&&(e.scrollTop=s),o+n<s+l&&(e.scrollTop=s+l-n),(i<0||c>document.documentElement.clientHeight)&&t.scrollIntoView({behavior:"smooth",block:"nearest"})}}),[j,H]),{activeOptionId:j,autocompleteId:T,composedValue:k,filteredOptions:S,handleOnBlur:x,handleOnClear:F,handleOnClick:R,handleOnChange:D,handleOnKeyDown:e=>{const{key:i}=e;if(c.has(i))switch(e.preventDefault(),i){case l:w?(O(!1),E(null)):F();break;case n:if(B){const{label:e}=B;C||v(e),s(g)&&g(B)}else s(b)&&b(k);O(!1),E(null);break;case o:{if(S.length<=0)return;O(!0);const e=V>=S.length-1?0:V+1;E(S[e]);break}case t:{if(S.length<=0)return;O(!0);const e=V<=0?S.length-1:V-1;E(S[e])}}},isControlled:C,isCustomFiltering:y,isMenuOpen:w,listboxId:H,menuId:L,optionBaseId:M,setActiveOption:E,setIsMenuOpen:O,setInternalValue:v}};export{a as useAutocomplete};
1
+ import*as e from"react";import{ARROW_UP as t,ARROW_DOWN as n,ENTER_KEY as o,ESCAPE_KEY as l}from"../shared/constants.js";import{isFunction as s,strHasLength as i}from"../shared/utils.js";import{useStableId as c}from"../utils/useStableId.js";const a=new Set([n,t,o,l]),u=({defaultValue:u="",value:r,options:d,optionFilter:m,onBlur:f,onChange:h,onClear:p,onClick:g,onSelect:b,onSubmit:C})=>{const I=void 0!==r,[v,k]=e.useState(u),w=I?r:v,[O,B]=e.useState(!1),[E,y]=e.useState(null),S=s(m),T=e.useMemo((()=>{const e=S?e=>m(e,w):e=>{const{label:t}=e;return null==t?void 0:t.toLocaleLowerCase().includes(null==w?void 0:w.toLocaleLowerCase())};return(null==d?void 0:d.filter(e))||[]}),[w,m,S,d]),H=c(),L=c(),M=c(),V=c(),j=T.findIndex((e=>e===E)),x=(null==E?void 0:E.id)||(-1!==j?`${V}-option-${j}`:void 0),D=e.useCallback((e=>{B(!1),y(null),s(f)&&f(e)}),[f]),F=e.useCallback((e=>{y(null),B(!0),I||k(e.target.value),s(h)&&h(e)}),[I,h]),R=e.useCallback((()=>{I||k(""),s(p)&&p()}),[I,p]),$=e.useCallback((e=>{B(!0),s(g)&&g(e)}),[g]);return e.useEffect((()=>{const e=document.getElementById(H),t=document.getElementById(M);if(t&&O&&e){const{bottom:n}=t.getBoundingClientRect(),{offsetParent:o,offsetTop:l}=e;o===document.body&&n>document.documentElement.clientHeight&&window.scrollTo({top:Math.min(n-document.documentElement.clientHeight+window.scrollY+20,l),behavior:"smooth"})}}),[H,O,M]),e.useEffect((()=>{const e=document.getElementById(L),t=i(x)?document.getElementById(x):null;if(t&&e){const{scrollTop:n,clientHeight:o}=e,{offsetHeight:l,offsetTop:s}=t,{top:i,bottom:c}=t.getBoundingClientRect();n>s&&(e.scrollTop=s),n+o<s+l&&(e.scrollTop=s+l-o),(i<0||c>document.documentElement.clientHeight)&&t.scrollIntoView({behavior:"smooth",block:"nearest"})}}),[x,L]),{activeOptionId:x,autocompleteId:H,composedValue:w,filteredOptions:T,handleOnBlur:D,handleOnClear:R,handleOnClick:$,handleOnChange:F,handleOnKeyDown:e=>{const{key:i}=e;if(a.has(i))switch(e.preventDefault(),i){case l:O?(B(!1),y(null)):R();break;case o:if(E){const{label:e}=E;I||k(e),s(b)&&b(E)}else s(C)&&C(w);B(!1),y(null);break;case n:{if(T.length<=0)return;B(!0);const e=j>=T.length-1?0:j+1;y(T[e]);break}case t:{if(T.length<=0)return;B(!0);const e=j<=0?T.length-1:j-1;y(T[e])}}},isControlled:I,isCustomFiltering:S,isMenuOpen:O,listboxId:L,menuId:M,optionBaseId:V,setActiveOption:y,setIsMenuOpen:B,setInternalValue:k}};export{u as useAutocomplete};
@@ -1 +1 @@
1
- import{isDesignToken as t,cssNameTransform as n}from"@aws-amplify/ui";import{stylePropsToThemeKeys as r}from"./constants.js";const o=t=>"string"==typeof t&&t.length>0,e=t=>"function"==typeof t,l=t=>"string"==typeof t&&0===t.length,i=t=>null==t||l(t),s=(t,n)=>{const r=n-t+1;return Array.from({length:r},((n,r)=>r+t))},f=(t,n)=>n?`${t}--${n}`:null,p=(t,n,r)=>r?`${t}--${n}`:null,u=(o,e,l)=>{if("string"!=typeof e)return e;if(e.includes(" "))return e.split(" ").map((t=>u(o,t,l))).join(" ");const i=e.split("."),s=r[o];let f=l[s];for(let t=0;t<i.length&&f;t++)f=f[i[t]];return t(f)?`var(--${n({path:[r[o],...i]})})`:e};export{f as classNameModifier,p as classNameModifierByFlag,u as getCSSVariableIfValueIsThemeKey,s as getConsecutiveIntArray,l as isEmptyString,e as isFunction,i as isNullOrEmptyString,o as strHasLength};
1
+ import{isDesignToken as t,cssNameTransform as n}from"@aws-amplify/ui";import{stylePropsToThemeKeys as r}from"./constants.js";const o=t=>"string"==typeof t&&t.length>0,e=t=>"function"==typeof t,i=t=>"string"==typeof t&&0===t.length,s=t=>null==t||i(t),f=(t,n)=>{const r=n-t+1;return Array.from({length:r},((n,r)=>r+t))},l=(t,n)=>n?`${t}--${n}`:"",p=(t,n,r)=>r?`${t}--${n}`:"",u=(o,e,i)=>{if("string"!=typeof e)return e;if(e.includes(" "))return e.split(" ").map((t=>u(o,t,i))).join(" ");const s=e.split("."),f=r[o];let l=i[f];for(let t=0;t<s.length&&l;t++)l=l[s[t]];return t(l)?`var(--${n({path:[r[o],...s]})})`:e};export{l as classNameModifier,p as classNameModifierByFlag,u as getCSSVariableIfValueIsThemeKey,f as getConsecutiveIntArray,i as isEmptyString,e as isFunction,s as isNullOrEmptyString,o as strHasLength};
@@ -0,0 +1 @@
1
+ const o="4.3.0";export{o as VERSION};