@bloom-housing/ui-components 4.4.1-alpha.7 → 5.0.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +949 -0
  2. package/index.ts +8 -6
  3. package/package.json +10 -3
  4. package/src/actions/Button.tsx +2 -2
  5. package/src/actions/ExpandableContent.tsx +9 -5
  6. package/src/blocks/ImageCard.tsx +3 -3
  7. package/src/blocks/StandardCard.docs.mdx +34 -0
  8. package/src/blocks/StandardCard.scss +33 -0
  9. package/src/blocks/StandardCard.tsx +37 -0
  10. package/src/config/index.ts +0 -1
  11. package/src/forms/FieldGroup.tsx +1 -1
  12. package/src/forms/HouseholdSizeField.tsx +2 -1
  13. package/src/global/tables.scss +7 -1
  14. package/src/helpers/formOptions.tsx +0 -9
  15. package/src/helpers/preferences.tsx +3 -314
  16. package/src/icons/Icon.tsx +22 -3
  17. package/src/locales/es.json +18 -0
  18. package/src/locales/general.json +23 -0
  19. package/src/{prototypes → navigation}/SideNav.scss +15 -9
  20. package/src/navigation/SideNav.tsx +39 -0
  21. package/src/notifications/ApplicationStatus.tsx +2 -2
  22. package/src/overlays/Drawer.tsx +1 -1
  23. package/src/overlays/LoadingOverlay.tsx +1 -1
  24. package/src/overlays/Modal.scss +5 -0
  25. package/src/overlays/Modal.tsx +19 -3
  26. package/src/page_components/listing/ListingsGroup.tsx +2 -2
  27. package/src/page_components/listing/listing_sidebar/ExpandableSection.tsx +34 -0
  28. package/src/page_components/listing/listing_sidebar/QuantityRowSection.tsx +1 -0
  29. package/src/page_components/sign-in/FormSignInMFACode.tsx +7 -3
  30. package/src/page_components/sign-in/FormSignInMFAType.tsx +7 -8
  31. package/src/page_components/sign-in/FormTerms.tsx +9 -27
  32. package/src/{global/vendor → tables}/AgPagination.tsx +5 -1
  33. package/src/tables/AgTable.tsx +242 -0
  34. package/src/tables/StandardTable.tsx +17 -4
  35. package/src/authentication/AuthContext.ts +0 -386
  36. package/src/authentication/RequireLogin.tsx +0 -89
  37. package/src/authentication/index.ts +0 -5
  38. package/src/authentication/timeout.tsx +0 -128
  39. package/src/authentication/token.ts +0 -17
  40. package/src/authentication/useRequireLoggedInUser.ts +0 -19
  41. package/src/config/ConfigContext.tsx +0 -36
  42. package/src/helpers/tableSummaries.tsx +0 -104
  43. package/src/notifications/index.ts +0 -4
  44. package/src/page_components/listing/UnitTables.tsx +0 -122
  45. package/src/page_components/listing/listing_sidebar/WhatToExpect.tsx +0 -22
  46. package/src/prototypes/SideNav.tsx +0 -14
@@ -1,104 +0,0 @@
1
- import * as React from "react"
2
- import { t } from "./translator"
3
- import { UnitSummary, ListingAvailability } from "@bloom-housing/backend-core/types"
4
- import { StandardTableData } from "../tables/StandardTable"
5
-
6
- export const unitSummariesTable = (
7
- summaries: UnitSummary[],
8
- listingAvailability: ListingAvailability
9
- ): StandardTableData => {
10
- const unitSummaries = summaries?.map((unitSummary) => {
11
- const unitPluralization = unitSummary.totalAvailable == 1 ? t("t.unit") : t("t.units")
12
- const minIncome =
13
- unitSummary.minIncomeRange.min == unitSummary.minIncomeRange.max ? (
14
- <strong>{unitSummary.minIncomeRange.min}</strong>
15
- ) : (
16
- <>
17
- <strong>{unitSummary.minIncomeRange.min}</strong>
18
- {` ${t("t.to")} `}
19
- <strong>{unitSummary.minIncomeRange.max}</strong>
20
- </>
21
- )
22
-
23
- const getRent = (rentMin: string, rentMax: string, percent = false) => {
24
- const unit = percent ? `% ${t("t.income")}` : ` ${t("t.perMonth")}`
25
- return rentMin == rentMax ? (
26
- <>
27
- <strong>{rentMin}</strong>
28
- {unit}
29
- </>
30
- ) : (
31
- <>
32
- <strong>{rentMin}</strong>
33
- {` ${t("t.to")} `}
34
- <strong>{rentMax}</strong>
35
- {unit}
36
- </>
37
- )
38
- }
39
-
40
- // Use rent as percent income if available, otherwise use exact rent
41
- const rent = unitSummary.rentAsPercentIncomeRange.min
42
- ? getRent(
43
- unitSummary.rentAsPercentIncomeRange.min.toString(),
44
- unitSummary.rentAsPercentIncomeRange.max.toString(),
45
- true
46
- )
47
- : getRent(unitSummary.rentRange.min, unitSummary.rentRange.max)
48
-
49
- let availability = null
50
- if (listingAvailability === ListingAvailability.availableUnits) {
51
- availability = (
52
- <span>
53
- {unitSummary.totalAvailable > 0 ? (
54
- <>
55
- <strong>{unitSummary.totalAvailable}</strong> {unitPluralization}
56
- </>
57
- ) : (
58
- <span>
59
- <strong>{t("listings.waitlist.open")}</strong>
60
- </span>
61
- )}
62
- </span>
63
- )
64
- } else if (listingAvailability === ListingAvailability.openWaitlist) {
65
- availability = (
66
- <span>
67
- <strong>{t("listings.waitlist.open")}</strong>
68
- </span>
69
- )
70
- }
71
-
72
- return {
73
- unitType: {
74
- content: <strong>{t(`listings.unitTypes.${unitSummary.unitType?.name}`)}</strong>,
75
- },
76
- minimumIncome: {
77
- content: (
78
- <span>
79
- {minIncome}
80
- {` ${t("t.perMonth")}`}
81
- </span>
82
- ),
83
- },
84
- rent: { content: <span>{rent}</span> },
85
- availability: {
86
- content: availability,
87
- },
88
- }
89
- })
90
-
91
- return unitSummaries
92
- }
93
-
94
- export const getSummariesTable = (
95
- summaries: UnitSummary[],
96
- listingAvailability: ListingAvailability
97
- ): StandardTableData => {
98
- let unitSummaries: StandardTableData = []
99
-
100
- if (summaries?.length > 0) {
101
- unitSummaries = unitSummariesTable(summaries, listingAvailability)
102
- }
103
- return unitSummaries
104
- }
@@ -1,4 +0,0 @@
1
- export { AlertBox } from "./AlertBox"
2
- export { AlertNotice } from "./AlertNotice"
3
- export { SiteAlert, setSiteAlertMessage } from "./SiteAlert"
4
- export type { AlertTypes } from "./alertTypes"
@@ -1,122 +0,0 @@
1
- import React from "react"
2
- import { MinMax, UnitSummary, Unit } from "@bloom-housing/backend-core/types"
3
-
4
- import { StandardTable, StandardTableData } from "../../tables/StandardTable"
5
- import { t } from "../../helpers/translator"
6
- import { numberOrdinal } from "../../helpers/numberOrdinal"
7
- import { ContentAccordion } from "./ContentAccordion"
8
-
9
- const formatRange = (range: MinMax, ordinalize?: boolean) => {
10
- let min: string | number = range.min
11
- let max: string | number = range.max
12
-
13
- if (ordinalize) {
14
- min = numberOrdinal(min)
15
- max = numberOrdinal(max)
16
- }
17
-
18
- if (min == max) {
19
- return min
20
- } else {
21
- return `${min} - ${max}`
22
- }
23
- }
24
-
25
- const unitsLabel = (units: Unit[]): string => {
26
- const label = units.length > 1 ? t("t.units") : t("t.unit")
27
- return `${units.length} ${label}`
28
- }
29
-
30
- interface UnitTablesProps {
31
- units: Unit[]
32
- unitSummaries: UnitSummary[]
33
- disableAccordion?: boolean
34
- }
35
-
36
- const UnitTables = (props: UnitTablesProps) => {
37
- const unitSummaries = props.unitSummaries || []
38
-
39
- const unitsHeaders = {
40
- number: "t.unit",
41
- sqFeet: "t.area",
42
- numBathrooms: "listings.bath",
43
- floor: "t.floor",
44
- }
45
-
46
- return (
47
- <>
48
- {unitSummaries.map((unitSummary: UnitSummary, index) => {
49
- const units = props.units.filter(
50
- (unit: Unit) => unit.unitType?.name == unitSummary.unitType.name
51
- )
52
- const unitsFormatted = [] as StandardTableData
53
- let floorSection: React.ReactNode
54
- units.forEach((unit: Unit) => {
55
- unitsFormatted.push({
56
- number: { content: unit.number },
57
- sqFeet: {
58
- content: (
59
- <>
60
- {unit.sqFeet ? (
61
- <>
62
- <strong>{parseInt(unit.sqFeet)}</strong> {t("t.sqFeet")}
63
- </>
64
- ) : (
65
- <></>
66
- )}
67
- </>
68
- ),
69
- },
70
- numBathrooms: { content: <strong>{unit.numBathrooms}</strong> },
71
- floor: { content: <strong>{unit.floor}</strong> },
72
- })
73
- })
74
-
75
- let areaRangeSection: React.ReactNode
76
- if (unitSummary.areaRange?.min || unitSummary.areaRange?.max) {
77
- areaRangeSection = `, ${formatRange(unitSummary.areaRange)} ${t("t.squareFeet")}`
78
- }
79
-
80
- if (unitSummary.floorRange && unitSummary.floorRange.min) {
81
- floorSection = `, ${formatRange(unitSummary.floorRange, true)}
82
- ${
83
- unitSummary.floorRange.max > unitSummary.floorRange.min
84
- ? t("t.floors")
85
- : t("t.floor")
86
- }`
87
- }
88
-
89
- const getBarContent = () => {
90
- return (
91
- <h3 className={"toggle-header-content"}>
92
- <strong>{t("listings.unitTypes." + unitSummary.unitType.name)}</strong>:&nbsp;
93
- {unitsLabel(units)}
94
- {areaRangeSection}
95
- {floorSection}
96
- </h3>
97
- )
98
- }
99
-
100
- const getExpandableContent = () => {
101
- return (
102
- <div className="unit-table">
103
- <StandardTable headers={unitsHeaders} data={unitsFormatted} />
104
- </div>
105
- )
106
- }
107
-
108
- return (
109
- <ContentAccordion
110
- customBarContent={getBarContent()}
111
- customExpandedContent={getExpandableContent()}
112
- disableAccordion={props.disableAccordion}
113
- accordionTheme={"blue"}
114
- key={index}
115
- />
116
- )
117
- })}
118
- </>
119
- )
120
- }
121
-
122
- export { UnitTables as default, UnitTables }
@@ -1,22 +0,0 @@
1
- import * as React from "react"
2
- import { t } from "../../../helpers/translator"
3
- import { Listing } from "@bloom-housing/backend-core/types"
4
-
5
- interface WhatToExpectProps {
6
- listing: Listing
7
- }
8
-
9
- const WhatToExpect = (props: WhatToExpectProps) => {
10
- const listing = props.listing
11
-
12
- return (
13
- <section className="aside-block">
14
- <h4 className="text-caps-underline">{t("whatToExpect.label")}</h4>
15
- <p className="text-tiny text-gray-800">
16
- {listing.whatToExpect ? listing.whatToExpect : t("whatToExpect.default")}
17
- </p>
18
- </section>
19
- )
20
- }
21
-
22
- export { WhatToExpect as default, WhatToExpect }
@@ -1,14 +0,0 @@
1
- import * as React from "react"
2
- import "./SideNav.scss"
3
-
4
- export interface SideNavProps {
5
- children: React.ReactNode[]
6
- }
7
-
8
- const SideNav = (props: SideNavProps) => (
9
- <nav className="side-nav" aria-label="Secondary navigation">
10
- <ul>{props.children}</ul>
11
- </nav>
12
- )
13
-
14
- export { SideNav as default, SideNav }