@aws-amplify/ui-react 4.2.1 → 4.3.1

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{__awaiter as e}from"tslib";import{jsx as t,jsxs as o}from"react/jsx-runtime";import i from"qrcode";import*as r from"react";import{Logger as a}from"aws-amplify";import{authenticatorTextUtil as s,getTotpCodeURL as n}from"@aws-amplify/ui";import{Flex as m}from"../../../primitives/Flex/Flex.js";import{Heading as d}from"../../../primitives/Heading/Heading.js";import{useAuthenticator as l}from"@aws-amplify/ui-react-core";import{useCustomComponents as c}from"../hooks/useCustomComponents/index.js";import{useFormHandlers as p}from"../hooks/useFormHandlers/useFormHandlers.js";import{ConfirmSignInFooter as u}from"../shared/ConfirmSignInFooter.js";import{RemoteErrorMessage as f}from"../shared/RemoteErrorMessage.js";import{FormFields as g}from"../shared/FormFields.js";import{RouteContainer as h}from"../RouteContainer/RouteContainer.js";const v=new a("SetupTOTP-logger"),{getSetupTOTPText:j,getCopiedText:C,getLoadingText:y}=s,b=({className:a,variation:s})=>{var d;const{fields:j,getTotpSecretCode:H,isPending:O,user:w}=l((e=>[e.isPending])),{handleChange:S,handleSubmit:x}=p(),{components:{SetupTOTP:{Header:T=b.Header,Footer:F=b.Footer}}}=c(),[V,P]=r.useState(!0),[R,k]=r.useState(),[L,M]=r.useState("COPY"),[q,Z]=r.useState(""),{totpIssuer:D="AWSCognito",totpUsername:E=(null==w?void 0:w.username)}=null!==(d=null==j?void 0:j.QR)&&void 0!==d?d:{},I=r.useCallback((()=>e(void 0,void 0,void 0,(function*(){try{const e=yield H();Z(e);const t=n(D,E,e),o=yield i.toDataURL(t);k(o)}catch(e){v.error(e)}finally{P(!1)}}))),[H,D,E]);r.useEffect((()=>{R||I()}),[I,R]);return t(h,Object.assign({className:a,variation:s},{children:t("form",Object.assign({"data-amplify-form":"","data-amplify-authenticator-setup-totp":"",method:"post",onChange:S,onSubmit:x},{children:o(m,Object.assign({as:"fieldset",direction:"column",isDisabled:O},{children:[t(T,{}),o(m,Object.assign({direction:"column"},{children:[V?o("p",{children:[y(),"…"]}):t("img",{"data-amplify-qrcode":!0,src:R,alt:"qr code",width:"228",height:"228"}),o(m,Object.assign({"data-amplify-copy":!0},{children:[t("div",{children:q}),o(m,Object.assign({"data-amplify-copy-svg":!0,onClick:()=>{navigator.clipboard.writeText(q),M(C())}},{children:[t("div",Object.assign({"data-amplify-copy-tooltip":!0},{children:L})),t("svg",Object.assign({width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},{children:t("path",{d:"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM15 5H8C6.9 5 6.01 5.9 6.01 7L6 21C6 22.1 6.89 23 7.99 23H19C20.1 23 21 22.1 21 21V11L15 5ZM8 21V7H14V12H19V21H8Z"})}))]}))]})),t(g,{}),t(f,{})]})),t(u,{}),t(F,{})]}))}))}))};b.Header=function(){return t(d,Object.assign({level:3},{children:j()}))},b.Footer=function(){return null};export{b as SetupTOTP};
1
+ import{__awaiter as e}from"tslib";import{jsx as t,jsxs as o}from"react/jsx-runtime";import i from"qrcode";import*as r from"react";import{Logger as a}from"aws-amplify";import{authenticatorTextUtil as s,getTotpCodeURL as n}from"@aws-amplify/ui";import{Flex as m}from"../../../primitives/Flex/Flex.js";import{Heading as d}from"../../../primitives/Heading/Heading.js";import{useAuthenticator as l}from"@aws-amplify/ui-react-core";import{useCustomComponents as c}from"../hooks/useCustomComponents/index.js";import{useFormHandlers as p}from"../hooks/useFormHandlers/useFormHandlers.js";import{ConfirmSignInFooter as u}from"../shared/ConfirmSignInFooter.js";import{RemoteErrorMessage as f}from"../shared/RemoteErrorMessage.js";import{FormFields as g}from"../shared/FormFields.js";import{RouteContainer as h}from"../RouteContainer/RouteContainer.js";const j=new a("SetupTOTP-logger"),{getSetupTOTPText:v,getCopiedText:C,getLoadingText:y}=s,b=({className:a,variation:s})=>{var d;const{getTotpSecretCode:v,isPending:H,user:O,QRFields:w}=l((e=>[e.isPending])),{handleChange:S,handleSubmit:x}=p(),{components:{SetupTOTP:{Header:F=b.Header,Footer:T=b.Footer}}}=c(),[V,P]=r.useState(!0),[R,k]=r.useState(),[L,M]=r.useState("COPY"),[q,Z]=r.useState(""),{totpIssuer:D="AWSCognito",totpUsername:E=(null==O?void 0:O.username)}=null!==(d=w)&&void 0!==d?d:{},I=r.useCallback((()=>e(void 0,void 0,void 0,(function*(){try{const e=yield v();Z(e);const t=n(D,E,e),o=yield i.toDataURL(t);k(o)}catch(e){j.error(e)}finally{P(!1)}}))),[v,D,E]);r.useEffect((()=>{R||I()}),[I,R]);return t(h,Object.assign({className:a,variation:s},{children:t("form",Object.assign({"data-amplify-form":"","data-amplify-authenticator-setup-totp":"",method:"post",onChange:S,onSubmit:x},{children:o(m,Object.assign({as:"fieldset",direction:"column",isDisabled:H},{children:[t(F,{}),o(m,Object.assign({direction:"column"},{children:[V?o("p",{children:[y(),"…"]}):t("img",{"data-amplify-qrcode":!0,src:R,alt:"qr code",width:"228",height:"228"}),o(m,Object.assign({"data-amplify-copy":!0},{children:[t("div",{children:q}),o(m,Object.assign({"data-amplify-copy-svg":!0,onClick:()=>{navigator.clipboard.writeText(q),M(C())}},{children:[t("div",Object.assign({"data-amplify-copy-tooltip":!0},{children:L})),t("svg",Object.assign({width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},{children:t("path",{d:"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM15 5H8C6.9 5 6.01 5.9 6.01 7L6 21C6 22.1 6.89 23 7.99 23H19C20.1 23 21 22.1 21 21V11L15 5ZM8 21V7H14V12H19V21H8Z"})}))]}))]})),t(g,{}),t(f,{})]})),t(u,{}),t(T,{})]}))}))}))};b.Header=function(){return t(d,Object.assign({level:3},{children:v()}))},b.Footer=function(){return null};export{b as SetupTOTP};
@@ -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.1";export{o as VERSION};