@bloom-housing/ui-components 7.0.1-alpha.2 → 7.0.1-alpha.4
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.
- package/CHANGELOG.md +21 -0
- package/package.json +2 -2
- package/src/forms/Field.tsx +27 -6
- package/src/text/Description.tsx +12 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.0.1-alpha.4](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@7.0.1-alpha.3...@bloom-housing/ui-components@7.0.1-alpha.4) (2022-10-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* accept only numeric values in currency field ([4638808](https://github.com/bloom-housing/bloom/commit/4638808e79d758d28f1f7befd2c77e892673374e))
|
|
12
|
+
* display income currency value with commas ([343e36f](https://github.com/bloom-housing/bloom/commit/343e36f4eced424aa915c91192274c5dda65c25f))
|
|
13
|
+
* remove redundant step prop from currency field ([f02556b](https://github.com/bloom-housing/bloom/commit/f02556b73416b382a822e84781e2817c0fcb2631))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [7.0.1-alpha.3](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@7.0.1-alpha.2...@bloom-housing/ui-components@7.0.1-alpha.3) (2022-10-24)
|
|
20
|
+
|
|
21
|
+
**Note:** Version bump only for package @bloom-housing/ui-components
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
## [7.0.1-alpha.2](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@7.0.1-alpha.1...@bloom-housing/ui-components@7.0.1-alpha.2) (2022-10-20)
|
|
7
28
|
|
|
8
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloom-housing/ui-components",
|
|
3
|
-
"version": "7.0.1-alpha.
|
|
3
|
+
"version": "7.0.1-alpha.4",
|
|
4
4
|
"author": "Sean Albert <sean.albert@exygy.com>",
|
|
5
5
|
"description": "Shared user interface components for Bloom affordable housing system",
|
|
6
6
|
"homepage": "https://github.com/bloom-housing/bloom/tree/master/shared/ui-components",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"ts-jest": "^26.4.1",
|
|
114
114
|
"typesafe-actions": "^5.1.0"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "9c4fe47d6175301eec203c019b326e11e3188317"
|
|
117
117
|
}
|
package/src/forms/Field.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from "react"
|
|
1
|
+
import React, { ChangeEvent, useMemo } from "react"
|
|
2
2
|
import { ErrorMessage } from "../notifications/ErrorMessage"
|
|
3
3
|
import { UseFormMethods, RegisterOptions } from "react-hook-form"
|
|
4
4
|
|
|
@@ -57,20 +57,41 @@ const Field = (props: FieldProps) => {
|
|
|
57
57
|
if (props.bordered && (props.type === "radio" || props.type === "checkbox"))
|
|
58
58
|
controlClasses.push("field-border")
|
|
59
59
|
|
|
60
|
-
const formatValue = () => {
|
|
60
|
+
const formatValue = (focused = false) => {
|
|
61
61
|
if (props.getValues && props.setValue) {
|
|
62
62
|
const currencyValue = props.getValues(props.name)
|
|
63
63
|
const numericIncome = parseFloat(currencyValue)
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
|
|
65
|
+
if (focused && currencyValue) {
|
|
66
|
+
props.setValue(props.name, parseFloat(currencyValue.replaceAll(",", "")))
|
|
67
|
+
} else if (isNaN(numericIncome)) {
|
|
68
|
+
props.setValue(props.name, "")
|
|
69
|
+
} else {
|
|
70
|
+
props.setValue(
|
|
71
|
+
props.name,
|
|
72
|
+
numericIncome.toLocaleString("en-US", { minimumFractionDigits: 2 })
|
|
73
|
+
)
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
const filterNumbers = (e: ChangeEvent<HTMLInputElement>) => {
|
|
79
|
+
if (props.setValue) {
|
|
80
|
+
props.setValue(props.name, e.target.value.replace(/[a-z]|[A-Z]/g, "").match(/^\d*\.?\d?\d?/g))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
70
84
|
let inputProps = { ...props.inputProps }
|
|
71
|
-
if (props.type === "currency")
|
|
85
|
+
if (props.type === "currency") {
|
|
86
|
+
inputProps = {
|
|
87
|
+
...inputProps,
|
|
88
|
+
onBlur: () => formatValue(),
|
|
89
|
+
onFocus: () => formatValue(true),
|
|
90
|
+
onChange: filterNumbers,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
72
93
|
|
|
73
|
-
const type = (props.type === "currency" && "
|
|
94
|
+
const type = (props.type === "currency" && "text") || props.type || "text"
|
|
74
95
|
const isRadioOrCheckbox = ["radio", "checkbox"].includes(type)
|
|
75
96
|
|
|
76
97
|
const label = useMemo(() => {
|
package/src/text/Description.tsx
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
2
|
import "./Description.scss"
|
|
3
|
-
import Markdown from "markdown-to-jsx"
|
|
3
|
+
import Markdown, { MarkdownOptions } from "markdown-to-jsx"
|
|
4
4
|
|
|
5
5
|
export interface DescriptionProps {
|
|
6
6
|
term: string
|
|
7
7
|
description: any
|
|
8
|
+
dtClassName?: string
|
|
8
9
|
markdown?: boolean
|
|
10
|
+
markdownProps?: MarkdownOptions
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export const Description = (props: DescriptionProps) => {
|
|
14
|
+
const dtClasses = ["description__body"]
|
|
15
|
+
if (props.dtClassName) dtClasses.push(props.dtClassName)
|
|
16
|
+
|
|
12
17
|
return (
|
|
13
18
|
<>
|
|
14
19
|
<dd className="description__title">{props.term}</dd>
|
|
15
20
|
{props.markdown ? (
|
|
16
|
-
<dt className="
|
|
17
|
-
<Markdown
|
|
21
|
+
<dt className={dtClasses.join(" ")}>
|
|
22
|
+
<Markdown
|
|
23
|
+
options={{ disableParsingRawHTML: true, ...props.markdownProps }}
|
|
24
|
+
children={props.description}
|
|
25
|
+
/>
|
|
18
26
|
</dt>
|
|
19
27
|
) : (
|
|
20
|
-
<dt className="
|
|
28
|
+
<dt className={dtClasses.join(" ")}>{props.description}</dt>
|
|
21
29
|
)}
|
|
22
30
|
</>
|
|
23
31
|
)
|