mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-15 13:36:35 +02:00
Compare commits
2 Commits
602e3f58dd
...
improve-in
Author | SHA1 | Date | |
---|---|---|---|
40309b4b4d | |||
8c929baeb5 |
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
* Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||||
*
|
*
|
||||||
* This is free software, licensed under the GNU General Public License v3.
|
* This is free software, licensed under the GNU General Public License v3.
|
||||||
* See /LICENSE for more information.
|
* See /LICENSE for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { useUID } from "react-uid";
|
import { useUID } from "react-uid";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
@ -36,8 +36,10 @@ export function Input({
|
|||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const uid = useUID();
|
const uid = useUID();
|
||||||
|
const [initialErrorFeedbackState, setErrorFeedbackState] = useState(false);
|
||||||
|
const errorFeedbackIsVisible = !!(initialErrorFeedbackState && error);
|
||||||
const inputClassName = `form-control ${className || ""} ${
|
const inputClassName = `form-control ${className || ""} ${
|
||||||
error ? "is-invalid" : ""
|
errorFeedbackIsVisible ? "is-invalid" : ""
|
||||||
}`.trim();
|
}`.trim();
|
||||||
return (
|
return (
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
@ -49,14 +51,17 @@ export function Input({
|
|||||||
className={inputClassName}
|
className={inputClassName}
|
||||||
type={type}
|
type={type}
|
||||||
id={uid}
|
id={uid}
|
||||||
|
onFocus={() => setErrorFeedbackState(true)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
{error ? <div className="invalid-feedback">{error}</div> : null}
|
{errorFeedbackIsVisible && (
|
||||||
{helpText ? (
|
<div className="invalid-feedback">{error}</div>
|
||||||
|
)}
|
||||||
|
{helpText && (
|
||||||
<small className="form-text text-muted">{helpText}</small>
|
<small className="form-text text-muted">{helpText}</small>
|
||||||
) : null}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
|
|||||||
- First value
|
- First value
|
||||||
+ Second value
|
+ Second value
|
||||||
|
|
||||||
@@ -479,10 +479,94 @@
|
@@ -479,10 +479,89 @@
|
||||||
Parameters of the guest network can be set in the Guest network tab.
|
Parameters of the guest network can be set in the Guest network tab.
|
||||||
|
|
||||||
</small>
|
</small>
|
||||||
@ -398,7 +398,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
|
|||||||
+ >
|
+ >
|
||||||
+ <input
|
+ <input
|
||||||
+ autocomplete=\\"new-password\\"
|
+ autocomplete=\\"new-password\\"
|
||||||
+ class=\\"form-control is-invalid\\"
|
+ class=\\"form-control\\"
|
||||||
+ id=\\"21\\"
|
+ id=\\"21\\"
|
||||||
+ required=\\"\\"
|
+ required=\\"\\"
|
||||||
+ type=\\"password\\"
|
+ type=\\"password\\"
|
||||||
@ -417,11 +417,6 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
|
|||||||
+ </button>
|
+ </button>
|
||||||
+ </div>
|
+ </div>
|
||||||
+ </div>
|
+ </div>
|
||||||
+ <div
|
|
||||||
+ class=\\"invalid-feedback\\"
|
|
||||||
+ >
|
|
||||||
+ Password must contain at least 8 symbols
|
|
||||||
+ </div>
|
|
||||||
+ <small
|
+ <small
|
||||||
+ class=\\"form-text text-muted\\"
|
+ class=\\"form-text text-muted\\"
|
||||||
+ >
|
+ >
|
||||||
@ -435,7 +430,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
|
|||||||
class=\\"form-group switch\\"
|
class=\\"form-group switch\\"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -506,10 +590,11 @@
|
@@ -506,10 +585,11 @@
|
||||||
<div
|
<div
|
||||||
class=\\"text-right\\"
|
class=\\"text-right\\"
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user