mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-22 19:44:21 +00:00
🔧 BREAKING: Change validity from boolean | null
to "running" | "ok" | "error" | null
This commit is contained in:
parent
069715b5c2
commit
7e7a1c4420
2 changed files with 7 additions and 14 deletions
|
@ -22,23 +22,16 @@ export function FormPair({id, label, input, validity, bluelibClassNames, customC
|
||||||
id = UUID.v4()
|
id = UUID.v4()
|
||||||
}
|
}
|
||||||
|
|
||||||
let validityClass
|
let validityClass = ""
|
||||||
// If the input is valid
|
if(validity === "running") {
|
||||||
if(validity === true) {
|
validityClass = "color-yellow"
|
||||||
|
}
|
||||||
|
else if(validity === "ok") {
|
||||||
validityClass = "color-lime"
|
validityClass = "color-lime"
|
||||||
}
|
}
|
||||||
// If the input is invalid
|
else if(validity === "error") {
|
||||||
else if(validity === false) {
|
|
||||||
validityClass = "color-red"
|
validityClass = "color-red"
|
||||||
}
|
}
|
||||||
// If the input has no validity
|
|
||||||
else if(validity === null) {
|
|
||||||
validityClass = ""
|
|
||||||
}
|
|
||||||
// If no validity has been passed
|
|
||||||
else {
|
|
||||||
validityClass = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
label = React.cloneElement(label, {
|
label = React.cloneElement(label, {
|
||||||
htmlFor: id,
|
htmlFor: id,
|
||||||
|
|
|
@ -21,4 +21,4 @@ export interface BluelibHTMLProps<Element extends HTMLElement> extends BluelibPr
|
||||||
|
|
||||||
|
|
||||||
export type InputValue = readonly string[] | string | number | undefined
|
export type InputValue = readonly string[] | string | number | undefined
|
||||||
export type Validity = boolean | null
|
export type Validity = null | "running" | "ok" | "error"
|
||||||
|
|
Loading…
Reference in a new issue