@bloom-housing/ui-components 7.0.8-alpha.0 → 7.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.
@@ -1,4 +1,4 @@
1
- import React, { useContext } from "react";
1
+ import React, { useContext } from "react"
2
2
  import {
3
3
  AppearanceStyleType,
4
4
  Button,
@@ -9,47 +9,47 @@ import {
9
9
  LinkButton,
10
10
  t,
11
11
  FormSignInErrorBox,
12
- } from "../../..";
13
- import type { UseFormMethods } from "react-hook-form";
14
- import { NavigationContext } from "../../config/NavigationContext";
15
- import { AlertTypes } from "../../notifications/alertTypes";
12
+ } from "@bloom-housing/ui-components"
13
+ import type { UseFormMethods } from "react-hook-form"
14
+ import { NavigationContext } from "../../config/NavigationContext"
15
+ import { AlertTypes } from "../../notifications/alertTypes"
16
16
 
17
- export type NetworkErrorDetermineError = (status: number, error: Error) => void;
17
+ export type NetworkErrorDetermineError = (status: number, error: Error) => void
18
18
 
19
- export type NetworkStatusType = AlertTypes;
19
+ export type NetworkStatusType = AlertTypes
20
20
 
21
- export type NetworkErrorReset = () => void;
21
+ export type NetworkErrorReset = () => void
22
22
 
23
23
  export type NetworkStatusContent = {
24
- title: string;
25
- description: string;
26
- error?: boolean;
27
- } | null;
24
+ title: string
25
+ description: string
26
+ error?: boolean
27
+ } | null
28
28
 
29
29
  export type NetworkStatus = {
30
- content: NetworkStatusContent;
31
- type?: NetworkStatusType;
32
- reset: NetworkErrorReset;
33
- };
30
+ content: NetworkStatusContent
31
+ type?: NetworkStatusType
32
+ reset: NetworkErrorReset
33
+ }
34
34
 
35
35
  export type FormSignInProps = {
36
- control: FormSignInControl;
37
- onSubmit: (data: FormSignInValues) => void;
38
- networkStatus: NetworkStatus;
39
- showRegisterBtn?: boolean;
40
- };
36
+ control: FormSignInControl
37
+ onSubmit: (data: FormSignInValues) => void
38
+ networkStatus: NetworkStatus
39
+ showRegisterBtn?: boolean
40
+ }
41
41
 
42
42
  export type FormSignInControl = {
43
- errors: UseFormMethods["errors"];
44
- handleSubmit: UseFormMethods["handleSubmit"];
45
- register: UseFormMethods["register"];
46
- watch: UseFormMethods["watch"];
47
- };
43
+ errors: UseFormMethods["errors"]
44
+ handleSubmit: UseFormMethods["handleSubmit"]
45
+ register: UseFormMethods["register"]
46
+ watch: UseFormMethods["watch"]
47
+ }
48
48
 
49
49
  export type FormSignInValues = {
50
- email: string;
51
- password: string;
52
- };
50
+ email: string
51
+ password: string
52
+ }
53
53
 
54
54
  const FormSignIn = ({
55
55
  onSubmit,
@@ -58,9 +58,9 @@ const FormSignIn = ({
58
58
  control: { errors, register, handleSubmit },
59
59
  }: FormSignInProps) => {
60
60
  const onError = () => {
61
- window.scrollTo(0, 0);
62
- };
63
- const { LinkComponent } = useContext(NavigationContext);
61
+ window.scrollTo(0, 0)
62
+ }
63
+ const { LinkComponent } = useContext(NavigationContext)
64
64
 
65
65
  return (
66
66
  <FormCard>
@@ -74,11 +74,7 @@ const FormSignIn = ({
74
74
  errorMessageId={"main-sign-in"}
75
75
  />
76
76
  <div className="form-card__group pt-0">
77
- <Form
78
- id="sign-in"
79
- className="mt-10"
80
- onSubmit={handleSubmit(onSubmit, onError)}
81
- >
77
+ <Form id="sign-in" className="mt-10" onSubmit={handleSubmit(onSubmit, onError)}>
82
78
  <Field
83
79
  caps={true}
84
80
  name="email"
@@ -109,10 +105,7 @@ const FormSignIn = ({
109
105
  />
110
106
 
111
107
  <div className="text-center mt-6">
112
- <Button
113
- styleType={AppearanceStyleType.primary}
114
- data-test-id="sign-in-button"
115
- >
108
+ <Button styleType={AppearanceStyleType.primary} data-test-id="sign-in-button">
116
109
  {t("nav.signIn")}
117
110
  </Button>
118
111
  </div>
@@ -120,17 +113,13 @@ const FormSignIn = ({
120
113
  </div>
121
114
  {showRegisterBtn && (
122
115
  <div className="form-card__group text-center border-t">
123
- <h2 className="mb-6">
124
- {t("authentication.createAccount.noAccount")}
125
- </h2>
116
+ <h2 className="mb-6">{t("authentication.createAccount.noAccount")}</h2>
126
117
 
127
- <LinkButton href="/create-account">
128
- {t("account.createAccount")}
129
- </LinkButton>
118
+ <LinkButton href="/create-account">{t("account.createAccount")}</LinkButton>
130
119
  </div>
131
120
  )}
132
121
  </FormCard>
133
- );
134
- };
122
+ )
123
+ }
135
124
 
136
- export { FormSignIn as default, FormSignIn };
125
+ export { FormSignIn as default, FormSignIn }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from "react"
2
2
  import {
3
3
  AppearanceStyleType,
4
4
  Button,
@@ -9,26 +9,26 @@ import {
9
9
  SiteAlert,
10
10
  PhoneField,
11
11
  FormSignInErrorBox,
12
- } from "../../..";
13
- import type { UseFormMethods } from "react-hook-form";
14
- import { NetworkStatus } from "./FormSignIn";
12
+ } from "@bloom-housing/ui-components"
13
+ import type { UseFormMethods } from "react-hook-form"
14
+ import { NetworkStatus } from "./FormSignIn"
15
15
 
16
16
  export type FormSignInAddPhoneProps = {
17
- control: FormSignInAddPhoneControl;
18
- onSubmit: (data: FormSignInAddPhoneValues) => void;
19
- networkError: NetworkStatus;
20
- phoneNumber: string;
21
- };
17
+ control: FormSignInAddPhoneControl
18
+ onSubmit: (data: FormSignInAddPhoneValues) => void
19
+ networkError: NetworkStatus
20
+ phoneNumber: string
21
+ }
22
22
 
23
23
  export type FormSignInAddPhoneControl = {
24
- errors: UseFormMethods["errors"];
25
- handleSubmit: UseFormMethods["handleSubmit"];
26
- control: UseFormMethods["control"];
27
- };
24
+ errors: UseFormMethods["errors"]
25
+ handleSubmit: UseFormMethods["handleSubmit"]
26
+ control: UseFormMethods["control"]
27
+ }
28
28
 
29
29
  export type FormSignInAddPhoneValues = {
30
- phoneNumber: string;
31
- };
30
+ phoneNumber: string
31
+ }
32
32
 
33
33
  const FormSignInAddPhone = ({
34
34
  onSubmit,
@@ -37,19 +37,15 @@ const FormSignInAddPhone = ({
37
37
  phoneNumber,
38
38
  }: FormSignInAddPhoneProps) => {
39
39
  const onError = () => {
40
- window.scrollTo(0, 0);
41
- };
42
- const { errors, handleSubmit } = control;
40
+ window.scrollTo(0, 0)
41
+ }
42
+ const { errors, handleSubmit } = control
43
43
  return (
44
44
  <FormCard>
45
45
  <div className="form-card__lead text-center">
46
46
  <Icon size="2xl" symbol="profile" className="form-card__header-icon" />
47
- <h2 className="form-card__title is-borderless">
48
- {t("nav.signInMFA.addNumber")}
49
- </h2>
50
- <p className="form-card__sub-title">
51
- {t("nav.signInMFA.addNumberSecondaryTitle")}
52
- </p>
47
+ <h2 className="form-card__title is-borderless">{t("nav.signInMFA.addNumber")}</h2>
48
+ <p className="form-card__sub-title">{t("nav.signInMFA.addNumberSecondaryTitle")}</p>
53
49
  </div>
54
50
  <FormSignInErrorBox
55
51
  errors={errors}
@@ -59,11 +55,7 @@ const FormSignInAddPhone = ({
59
55
 
60
56
  <SiteAlert type="notice" dismissable />
61
57
  <div className="form-card__group pt-0">
62
- <Form
63
- id="sign-in-mfa"
64
- className="mt-10"
65
- onSubmit={handleSubmit(onSubmit, onError)}
66
- >
58
+ <Form id="sign-in-mfa" className="mt-10" onSubmit={handleSubmit(onSubmit, onError)}>
67
59
  <PhoneField
68
60
  label={t("nav.signInMFA.phoneNumber")}
69
61
  caps={true}
@@ -89,7 +81,7 @@ const FormSignInAddPhone = ({
89
81
  </Form>
90
82
  </div>
91
83
  </FormCard>
92
- );
93
- };
84
+ )
85
+ }
94
86
 
95
- export { FormSignInAddPhone as default, FormSignInAddPhone };
87
+ export { FormSignInAddPhone as default, FormSignInAddPhone }
@@ -1,31 +1,25 @@
1
- import React from "react";
2
- import { t, AlertBox, SiteAlert, AlertNotice, ErrorMessage } from "../../..";
3
- import type { UseFormMethods } from "react-hook-form";
4
- import { NetworkStatus } from "./FormSignIn";
1
+ import React from "react"
2
+ import { t, AlertBox, SiteAlert, AlertNotice, ErrorMessage } from "@bloom-housing/ui-components"
3
+ import type { UseFormMethods } from "react-hook-form"
4
+ import { NetworkStatus } from "./FormSignIn"
5
5
 
6
6
  export type FormSignInErrorBoxProps = {
7
- errors: FormSignInErrorBoxControl["errors"];
8
- networkStatus: NetworkStatus;
9
- errorMessageId: string;
10
- };
7
+ errors: FormSignInErrorBoxControl["errors"]
8
+ networkStatus: NetworkStatus
9
+ errorMessageId: string
10
+ }
11
11
 
12
12
  export type FormSignInErrorBoxControl = {
13
- errors: UseFormMethods["errors"];
14
- control: UseFormMethods["control"];
15
- };
13
+ errors: UseFormMethods["errors"]
14
+ control: UseFormMethods["control"]
15
+ }
16
16
 
17
- const FormSignInErrorBox = ({
18
- networkStatus,
19
- errors,
20
- errorMessageId,
21
- }: FormSignInErrorBoxProps) => {
17
+ const FormSignInErrorBox = ({ networkStatus, errors, errorMessageId }: FormSignInErrorBoxProps) => {
22
18
  return (
23
19
  <div className="border-b">
24
20
  {Object.entries(errors).length > 0 && !networkStatus.content && (
25
21
  <AlertBox type="alert" inverted closeable>
26
- {errors.authentication
27
- ? errors.authentication.message
28
- : t("errors.errorsToResolve")}
22
+ {errors.authentication ? errors.authentication.message : t("errors.errorsToResolve")}
29
23
  </AlertBox>
30
24
  )}
31
25
 
@@ -35,11 +29,7 @@ const FormSignInErrorBox = ({
35
29
  error={!!networkStatus.content}
36
30
  className="block mt-0 leading-normal text-alert"
37
31
  >
38
- <AlertBox
39
- type={"alert"}
40
- inverted
41
- onClose={() => networkStatus.reset()}
42
- >
32
+ <AlertBox type={"alert"} inverted onClose={() => networkStatus.reset()}>
43
33
  {networkStatus.content.title}
44
34
  </AlertBox>
45
35
 
@@ -51,11 +41,7 @@ const FormSignInErrorBox = ({
51
41
 
52
42
  {networkStatus.type === "success" && (
53
43
  <>
54
- <AlertBox
55
- type="success"
56
- inverted
57
- onClose={() => networkStatus.reset()}
58
- >
44
+ <AlertBox type="success" inverted onClose={() => networkStatus.reset()}>
59
45
  {networkStatus.content?.title}
60
46
  </AlertBox>
61
47
 
@@ -67,7 +53,7 @@ const FormSignInErrorBox = ({
67
53
 
68
54
  <SiteAlert type="notice" dismissable />
69
55
  </div>
70
- );
71
- };
56
+ )
57
+ }
72
58
 
73
- export { FormSignInErrorBox as default, FormSignInErrorBox };
59
+ export { FormSignInErrorBox as default, FormSignInErrorBox }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from "react"
2
2
  import {
3
3
  AppearanceStyleType,
4
4
  Button,
@@ -9,8 +9,8 @@ import {
9
9
  t,
10
10
  SiteAlert,
11
11
  FormSignInErrorBox,
12
- } from "../../..";
13
- import { NetworkStatus, FormSignInControl } from "./FormSignIn";
12
+ } from "@bloom-housing/ui-components"
13
+ import { NetworkStatus, FormSignInControl } from "./FormSignIn"
14
14
 
15
15
  export enum RequestType {
16
16
  email = "email",
@@ -18,18 +18,18 @@ export enum RequestType {
18
18
  }
19
19
 
20
20
  export type FormSignInMFACodeProps = {
21
- control: FormSignInControl;
22
- onSubmit: (data: FormSignInMFACodeValues) => void;
23
- networkError: NetworkStatus;
24
- mfaType: RequestType;
25
- allowPhoneNumberEdit: boolean;
26
- phoneNumber: string;
27
- goBackToPhone: () => void;
28
- };
21
+ control: FormSignInControl
22
+ onSubmit: (data: FormSignInMFACodeValues) => void
23
+ networkError: NetworkStatus
24
+ mfaType: RequestType
25
+ allowPhoneNumberEdit: boolean
26
+ phoneNumber: string
27
+ goBackToPhone: () => void
28
+ }
29
29
 
30
30
  export type FormSignInMFACodeValues = {
31
- mfaCode: string;
32
- };
31
+ mfaCode: string
32
+ }
33
33
 
34
34
  const FormSignInMFACode = ({
35
35
  onSubmit,
@@ -41,10 +41,10 @@ const FormSignInMFACode = ({
41
41
  goBackToPhone,
42
42
  }: FormSignInMFACodeProps) => {
43
43
  const onError = () => {
44
- window.scrollTo(0, 0);
45
- };
44
+ window.scrollTo(0, 0)
45
+ }
46
46
 
47
- let note;
47
+ let note
48
48
  if (allowPhoneNumberEdit) {
49
49
  note = (
50
50
  <>
@@ -58,16 +58,14 @@ const FormSignInMFACode = ({
58
58
  {t("nav.signInMFA.editPhoneNumber")}{" "}
59
59
  </Button>
60
60
  </>
61
- );
61
+ )
62
62
  }
63
63
 
64
64
  return (
65
65
  <FormCard>
66
66
  <div className="form-card__lead text-center">
67
67
  <Icon size="2xl" symbol="profile" className="form-card__header-icon" />
68
- <h2 className="form-card__title is-borderless">
69
- {t("nav.signInMFA.verifyTitle")}
70
- </h2>
68
+ <h2 className="form-card__title is-borderless">{t("nav.signInMFA.verifyTitle")}</h2>
71
69
  <p className="form-card__sub-title">
72
70
  {mfaType === RequestType.sms
73
71
  ? t("nav.signInMFA.haveSentCodeToPhone")
@@ -82,11 +80,7 @@ const FormSignInMFACode = ({
82
80
 
83
81
  <SiteAlert type="notice" dismissable />
84
82
  <div className="form-card__group pt-0">
85
- <Form
86
- id="sign-in-mfa"
87
- className="mt-10"
88
- onSubmit={handleSubmit(onSubmit, onError)}
89
- >
83
+ <Form id="sign-in-mfa" className="mt-10" onSubmit={handleSubmit(onSubmit, onError)}>
90
84
  <Field
91
85
  caps={true}
92
86
  name="mfaCode"
@@ -99,17 +93,14 @@ const FormSignInMFACode = ({
99
93
  note={note}
100
94
  />
101
95
  <div className="text-center mt-10">
102
- <Button
103
- styleType={AppearanceStyleType.primary}
104
- data-test-id="verify-and-sign-in"
105
- >
96
+ <Button styleType={AppearanceStyleType.primary} data-test-id="verify-and-sign-in">
106
97
  {t("nav.signInMFA.signIn")}
107
98
  </Button>
108
99
  </div>
109
100
  </Form>
110
101
  </div>
111
102
  </FormCard>
112
- );
113
- };
103
+ )
104
+ }
114
105
 
115
- export { FormSignInMFACode as default, FormSignInMFACode };
106
+ export { FormSignInMFACode as default, FormSignInMFACode }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from "react"
2
2
  import {
3
3
  AppearanceStyleType,
4
4
  Button,
@@ -9,24 +9,24 @@ import {
9
9
  t,
10
10
  SiteAlert,
11
11
  FormSignInErrorBox,
12
- } from "../../..";
13
- import type { UseFormMethods } from "react-hook-form";
14
- import { NetworkStatus } from "./FormSignIn";
12
+ } from "@bloom-housing/ui-components"
13
+ import type { UseFormMethods } from "react-hook-form"
14
+ import { NetworkStatus } from "./FormSignIn"
15
15
 
16
16
  export type FormSignInMFAProps = {
17
- control: FormSignInMFAControl;
18
- onSubmit: (data: unknown) => void;
19
- networkError: NetworkStatus;
20
- emailOnClick: () => void;
21
- smsOnClick: () => void;
22
- };
17
+ control: FormSignInMFAControl
18
+ onSubmit: (data: unknown) => void
19
+ networkError: NetworkStatus
20
+ emailOnClick: () => void
21
+ smsOnClick: () => void
22
+ }
23
23
 
24
24
  export type FormSignInMFAControl = {
25
- errors: UseFormMethods["errors"];
26
- handleSubmit: UseFormMethods["handleSubmit"];
27
- register: UseFormMethods["register"];
28
- setValue: UseFormMethods["setValue"];
29
- };
25
+ errors: UseFormMethods["errors"]
26
+ handleSubmit: UseFormMethods["handleSubmit"]
27
+ register: UseFormMethods["register"]
28
+ setValue: UseFormMethods["setValue"]
29
+ }
30
30
 
31
31
  const FormSignInMFAType = ({
32
32
  onSubmit,
@@ -36,8 +36,8 @@ const FormSignInMFAType = ({
36
36
  smsOnClick,
37
37
  }: FormSignInMFAProps) => {
38
38
  const onError = () => {
39
- window.scrollTo(0, 0);
40
- };
39
+ window.scrollTo(0, 0)
40
+ }
41
41
 
42
42
  return (
43
43
  <FormCard>
@@ -58,11 +58,7 @@ const FormSignInMFAType = ({
58
58
 
59
59
  <SiteAlert type="notice" dismissable />
60
60
  <div className="form-card__group pt-0">
61
- <Form
62
- id="sign-in-mfa"
63
- className="mt-10"
64
- onSubmit={handleSubmit(onSubmit, onError)}
65
- >
61
+ <Form id="sign-in-mfa" className="mt-10" onSubmit={handleSubmit(onSubmit, onError)}>
66
62
  <Field
67
63
  caps={true}
68
64
  name="mfaType"
@@ -96,7 +92,7 @@ const FormSignInMFAType = ({
96
92
  </Form>
97
93
  </div>
98
94
  </FormCard>
99
- );
100
- };
95
+ )
96
+ }
101
97
 
102
- export { FormSignInMFAType as default, FormSignInMFAType };
98
+ export { FormSignInMFAType as default, FormSignInMFAType }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from "react"
2
2
  import {
3
3
  AppearanceStyleType,
4
4
  Button,
@@ -8,31 +8,29 @@ import {
8
8
  Icon,
9
9
  MarkdownSection,
10
10
  t,
11
- } from "../../..";
12
- import Markdown from "markdown-to-jsx";
13
- import { useForm } from "react-hook-form";
11
+ } from "@bloom-housing/ui-components"
12
+ import Markdown from "markdown-to-jsx"
13
+ import { useForm } from "react-hook-form"
14
14
 
15
15
  type FormTermsInValues = {
16
- agree: boolean;
17
- };
16
+ agree: boolean
17
+ }
18
18
 
19
19
  export type FormTermsProps = {
20
- onSubmit: () => void;
21
- terms?: string;
22
- };
20
+ onSubmit: () => void
21
+ terms?: string
22
+ }
23
23
 
24
24
  const FormTerms = (props: FormTermsProps) => {
25
25
  // eslint-disable-next-line @typescript-eslint/unbound-method
26
- const { handleSubmit, register, errors } = useForm<FormTermsInValues>();
26
+ const { handleSubmit, register, errors } = useForm<FormTermsInValues>()
27
27
 
28
28
  return (
29
29
  <Form id="terms" className="mt-10" onSubmit={handleSubmit(props.onSubmit)}>
30
30
  <FormCard>
31
31
  <div className="form-card__lead text-center">
32
32
  <Icon size="2xl" symbol="settings" />
33
- <h2 className="form-card__title">
34
- {t(`authentication.terms.reviewToc`)}
35
- </h2>
33
+ <h2 className="form-card__title">{t(`authentication.terms.reviewToc`)}</h2>
36
34
  <p className="field-note mt-4 text-center">
37
35
  {t(`authentication.terms.youMustAcceptToc`)}
38
36
  </p>
@@ -40,9 +38,7 @@ const FormTerms = (props: FormTermsProps) => {
40
38
  <div className="overflow-y-auto max-h-96 mt-5 pr-4 text-left">
41
39
  {props.terms && (
42
40
  <MarkdownSection padding={false} fullwidth={true}>
43
- <Markdown options={{ disableParsingRawHTML: false }}>
44
- {props.terms}
45
- </Markdown>
41
+ <Markdown options={{ disableParsingRawHTML: false }}>{props.terms}</Markdown>
46
42
  </MarkdownSection>
47
43
  )}
48
44
  </div>
@@ -67,17 +63,14 @@ const FormTerms = (props: FormTermsProps) => {
67
63
 
68
64
  <div className="form-card__pager">
69
65
  <div className="form-card__pager-row primary">
70
- <Button
71
- styleType={AppearanceStyleType.primary}
72
- data-test-id="form-submit"
73
- >
66
+ <Button styleType={AppearanceStyleType.primary} data-test-id="form-submit">
74
67
  {t("t.submit")}
75
68
  </Button>
76
69
  </div>
77
70
  </div>
78
71
  </FormCard>
79
72
  </Form>
80
- );
81
- };
73
+ )
74
+ }
82
75
 
83
- export { FormTerms as default, FormTerms };
76
+ export { FormTerms as default, FormTerms }