foris 5.6.1 → 6.0.0-beta.c2097961
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/api/hooks.js +11 -3
- package/bootstrap/Alert.js +14 -10
- package/bootstrap/Button.js +7 -10
- package/bootstrap/CheckBox.js +22 -20
- package/bootstrap/CopyInput.js +7 -3
- package/bootstrap/DataTimeInput.js +9 -6
- package/bootstrap/DownloadButton.js +5 -2
- package/bootstrap/EmailInput.js +7 -2
- package/bootstrap/FileInput.js +6 -3
- package/bootstrap/Input.js +20 -10
- package/bootstrap/Modal.js +6 -6
- package/bootstrap/NumberInput.js +28 -25
- package/bootstrap/PasswordInput.js +20 -21
- package/bootstrap/RadioSet.js +26 -33
- package/bootstrap/Select.js +15 -8
- package/bootstrap/Spinner.css +10 -4
- package/bootstrap/Spinner.js +2 -1
- package/bootstrap/Switch.js +26 -23
- package/bootstrap/TextInput.js +8 -3
- package/bootstrap/constants.js +5 -4
- package/common/RebootButton.js +9 -7
- package/common/WiFiSettings/ResetWiFiSettings.js +11 -8
- package/common/WiFiSettings/WiFiForm.js +16 -16
- package/common/WiFiSettings/WiFiGuestForm.js +6 -5
- package/common/WiFiSettings/WiFiQRCode.js +6 -5
- package/common/WiFiSettings/WiFiSettings.js +7 -4
- package/context/alertContext/AlertContext.js +10 -5
- package/context/customizationContext/CustomizationContext.js +24 -13
- package/foris-6.0.0.tgz +0 -0
- package/form/components/ForisForm.js +16 -14
- package/form/components/SubmitButton.js +2 -1
- package/form/hooks.js +3 -2
- package/index.js +27 -27
- package/package.json +25 -26
- package/utils/ErrorMessage.js +5 -2
- package/utils/Portal.js +10 -2
- package/utils/conditionalHOCs.js +14 -7
- package/utils/datetime.js +3 -4
- package/utils/displayCard.js +4 -2
- package/utils/hooks.js +1 -1
- package/utils/isPluginInstalled.js +4 -2
- package/utils/validations.js +6 -3
- package/webSockets/WebSockets.js +4 -4
- package/webSockets/hooks.js +5 -2
- package/foris-5.6.1.tgz +0 -0
package/api/hooks.js
CHANGED
|
@@ -111,9 +111,8 @@ const useAPIPatch = createAPIHook("PATCH");
|
|
|
111
111
|
const useAPIPut = createAPIHook("PUT");
|
|
112
112
|
const useAPIDelete = createAPIHook("DELETE");
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
export function useAPIPolling(endpoint, delay = 1000, until) {
|
|
114
|
+
/* eslint-disable default-param-last */
|
|
115
|
+
function useAPIPolling(endpoint, delay = 1000, until) {
|
|
117
116
|
// delay ms
|
|
118
117
|
const [state, setState] = useState({ state: API_STATE.INIT });
|
|
119
118
|
const [getResponse, get] = useAPIGet(endpoint);
|
|
@@ -133,3 +132,12 @@ export function useAPIPolling(endpoint, delay = 1000, until) {
|
|
|
133
132
|
|
|
134
133
|
return [state];
|
|
135
134
|
}
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
useAPIGet,
|
|
138
|
+
useAPIPost,
|
|
139
|
+
useAPIPatch,
|
|
140
|
+
useAPIPut,
|
|
141
|
+
useAPIDelete,
|
|
142
|
+
useAPIPolling,
|
|
143
|
+
};
|
package/bootstrap/Alert.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
12
|
export const ALERT_TYPES = Object.freeze({
|
|
@@ -35,21 +36,24 @@ Alert.defaultProps = {
|
|
|
35
36
|
type: ALERT_TYPES.DANGER,
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
function Alert({ type, onDismiss, children }) {
|
|
39
40
|
return (
|
|
40
41
|
<div
|
|
41
|
-
className={`alert ${
|
|
42
|
+
className={`alert alert-${type} ${
|
|
42
43
|
onDismiss ? "alert-dismissible" : ""
|
|
43
|
-
}
|
|
44
|
+
}`.trim()}
|
|
44
45
|
>
|
|
45
|
-
{onDismiss
|
|
46
|
-
<button
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
{onDismiss && (
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
className="btn-close"
|
|
50
|
+
onClick={onDismiss}
|
|
51
|
+
aria-label={_("Close")}
|
|
52
|
+
/>
|
|
51
53
|
)}
|
|
52
54
|
{children}
|
|
53
55
|
</div>
|
|
54
56
|
);
|
|
55
57
|
}
|
|
58
|
+
|
|
59
|
+
export default Alert;
|
package/bootstrap/Button.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019-
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
12
|
Button.propTypes = {
|
|
@@ -24,16 +25,10 @@ Button.propTypes = {
|
|
|
24
25
|
]).isRequired,
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
className,
|
|
29
|
-
loading,
|
|
30
|
-
forisFormSize,
|
|
31
|
-
children,
|
|
32
|
-
...props
|
|
33
|
-
}) {
|
|
28
|
+
function Button({ className, loading, forisFormSize, children, ...props }) {
|
|
34
29
|
let buttonClass = className ? `btn ${className}` : "btn btn-primary";
|
|
35
30
|
if (forisFormSize) {
|
|
36
|
-
buttonClass = `${buttonClass} col-
|
|
31
|
+
buttonClass = `${buttonClass} col-12 col-md-3 col-lg-2`;
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
return (
|
|
@@ -44,7 +39,7 @@ export function Button({
|
|
|
44
39
|
>
|
|
45
40
|
{loading && (
|
|
46
41
|
<span
|
|
47
|
-
className="spinner-border spinner-border-sm
|
|
42
|
+
className="spinner-border spinner-border-sm me-1"
|
|
48
43
|
role="status"
|
|
49
44
|
aria-hidden="true"
|
|
50
45
|
/>
|
|
@@ -53,3 +48,5 @@ export function Button({
|
|
|
53
48
|
</button>
|
|
54
49
|
);
|
|
55
50
|
}
|
|
51
|
+
|
|
52
|
+
export default Button;
|
package/bootstrap/CheckBox.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
import { useUID } from "react-uid";
|
|
11
12
|
|
|
@@ -22,27 +23,28 @@ CheckBox.defaultProps = {
|
|
|
22
23
|
disabled: false,
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
function CheckBox({ label, helpText, disabled, ...props }) {
|
|
26
27
|
const uid = useUID();
|
|
28
|
+
|
|
27
29
|
return (
|
|
28
|
-
<div className="form-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</label>
|
|
45
|
-
</div>
|
|
30
|
+
<div className="mb-3 form-check">
|
|
31
|
+
<input
|
|
32
|
+
className="form-check-input"
|
|
33
|
+
type="checkbox"
|
|
34
|
+
id={uid}
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
<label className="form-check-label" htmlFor={uid}>
|
|
39
|
+
{label}
|
|
40
|
+
</label>
|
|
41
|
+
{helpText && (
|
|
42
|
+
<div className="form-text">
|
|
43
|
+
<small>{helpText}</small>
|
|
44
|
+
</div>
|
|
45
|
+
)}
|
|
46
46
|
</div>
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
export default CheckBox;
|
package/bootstrap/CopyInput.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019-
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, { useState, useRef } from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
import Input from "./Input";
|
|
11
13
|
|
|
12
14
|
CopyInput.propTypes = {
|
|
13
15
|
/** Field label. */
|
|
@@ -22,7 +24,7 @@ CopyInput.propTypes = {
|
|
|
22
24
|
readOnly: PropTypes.bool,
|
|
23
25
|
};
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
function CopyInput({ value, ...props }) {
|
|
26
28
|
const inputTextRef = useRef();
|
|
27
29
|
const [isCopied, setIsCopied] = useState(false);
|
|
28
30
|
|
|
@@ -58,3 +60,5 @@ export function CopyInput({ value, ...props }) {
|
|
|
58
60
|
</Input>
|
|
59
61
|
);
|
|
60
62
|
}
|
|
63
|
+
|
|
64
|
+
export default CopyInput;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
+
|
|
10
|
+
import moment from "moment/moment";
|
|
9
11
|
import PropTypes from "prop-types";
|
|
10
12
|
import Datetime from "react-datetime";
|
|
11
|
-
import moment from "moment/moment";
|
|
12
13
|
import "react-datetime/css/react-datetime.css";
|
|
13
14
|
import "./DataTimeInput.css";
|
|
14
15
|
|
|
15
|
-
import
|
|
16
|
+
import Input from "./Input";
|
|
16
17
|
|
|
17
18
|
DataTimeInput.propTypes = {
|
|
18
19
|
/** Field label. */
|
|
@@ -37,7 +38,7 @@ DataTimeInput.propTypes = {
|
|
|
37
38
|
const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
38
39
|
const DEFAULT_TIME_FORMAT = "HH:mm:ss";
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
function DataTimeInput({
|
|
41
42
|
value,
|
|
42
43
|
onChange,
|
|
43
44
|
isValidDate,
|
|
@@ -46,13 +47,13 @@ export function DataTimeInput({
|
|
|
46
47
|
children,
|
|
47
48
|
...props
|
|
48
49
|
}) {
|
|
49
|
-
|
|
50
|
+
const renderInput = (datetimeProps) => {
|
|
50
51
|
return (
|
|
51
52
|
<Input {...props} {...datetimeProps}>
|
|
52
53
|
{children}
|
|
53
54
|
</Input>
|
|
54
55
|
);
|
|
55
|
-
}
|
|
56
|
+
};
|
|
56
57
|
|
|
57
58
|
return (
|
|
58
59
|
<Datetime
|
|
@@ -70,3 +71,5 @@ export function DataTimeInput({
|
|
|
70
71
|
/>
|
|
71
72
|
);
|
|
72
73
|
}
|
|
74
|
+
|
|
75
|
+
export default DataTimeInput;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
12
|
DownloadButton.propTypes = {
|
|
@@ -21,7 +22,7 @@ DownloadButton.defaultProps = {
|
|
|
21
22
|
className: "btn-primary",
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
function DownloadButton({ href, className, children, ...props }) {
|
|
25
26
|
return (
|
|
26
27
|
<a
|
|
27
28
|
href={href}
|
|
@@ -33,3 +34,5 @@ export function DownloadButton({ href, className, children, ...props }) {
|
|
|
33
34
|
</a>
|
|
34
35
|
);
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
export default DownloadButton;
|
package/bootstrap/EmailInput.js
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
|
-
import
|
|
12
|
+
import Input from "./Input";
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
function EmailInput({ ...props }) {
|
|
15
|
+
return <Input type="email" {...props} />;
|
|
16
|
+
}
|
|
14
17
|
|
|
15
18
|
EmailInput.propTypes = {
|
|
16
19
|
/** Field label. */
|
|
@@ -22,3 +25,5 @@ EmailInput.propTypes = {
|
|
|
22
25
|
/** Email value. */
|
|
23
26
|
value: PropTypes.string,
|
|
24
27
|
};
|
|
28
|
+
|
|
29
|
+
export default EmailInput;
|
package/bootstrap/FileInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import PropTypes from "prop-types";
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
import Input from "./Input";
|
|
12
13
|
|
|
13
14
|
FileInput.propTypes = {
|
|
14
15
|
/** Field label. */
|
|
@@ -23,7 +24,7 @@ FileInput.propTypes = {
|
|
|
23
24
|
multiple: PropTypes.bool,
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
function FileInput({ ...props }) {
|
|
27
28
|
return (
|
|
28
29
|
<Input
|
|
29
30
|
type="file"
|
|
@@ -34,3 +35,5 @@ export function FileInput({ ...props }) {
|
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
37
|
}
|
|
38
|
+
|
|
39
|
+
export default FileInput;
|
package/bootstrap/Input.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, { forwardRef } from "react";
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
import PropTypes from "prop-types";
|
|
11
|
+
import { useUID } from "react-uid";
|
|
11
12
|
|
|
12
13
|
/** Base bootstrap input component. */
|
|
13
|
-
|
|
14
|
+
const Input = forwardRef(
|
|
14
15
|
(
|
|
15
16
|
{
|
|
16
17
|
type,
|
|
@@ -27,18 +28,21 @@ export const Input = forwardRef(
|
|
|
27
28
|
) => {
|
|
28
29
|
const uid = useUID();
|
|
29
30
|
|
|
30
|
-
const inputClassName =
|
|
31
|
+
const inputClassName = `${className || ""} ${
|
|
31
32
|
error ? "is-invalid" : ""
|
|
32
33
|
}`.trim();
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
|
-
<div className="
|
|
36
|
-
<label
|
|
36
|
+
<div className="mb-3">
|
|
37
|
+
<label
|
|
38
|
+
className={`form-label ${labelClassName || ""}`.trim()}
|
|
39
|
+
htmlFor={uid}
|
|
40
|
+
>
|
|
37
41
|
{label}
|
|
38
42
|
</label>
|
|
39
43
|
<div className={`input-group ${groupClassName || ""}`.trim()}>
|
|
40
44
|
<input
|
|
41
|
-
className={inputClassName}
|
|
45
|
+
className={`form-control ${inputClassName}`.trim()}
|
|
42
46
|
type={type}
|
|
43
47
|
id={uid}
|
|
44
48
|
ref={ref}
|
|
@@ -46,15 +50,19 @@ export const Input = forwardRef(
|
|
|
46
50
|
/>
|
|
47
51
|
{children}
|
|
48
52
|
</div>
|
|
49
|
-
{error
|
|
50
|
-
{helpText
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
+
{error && <div className="invalid-feedback">{error}</div>}
|
|
54
|
+
{helpText && (
|
|
55
|
+
<div className="form-text">
|
|
56
|
+
<small>{helpText}</small>
|
|
57
|
+
</div>
|
|
58
|
+
)}
|
|
53
59
|
</div>
|
|
54
60
|
);
|
|
55
61
|
}
|
|
56
62
|
);
|
|
57
63
|
|
|
64
|
+
Input.displayName = "Input";
|
|
65
|
+
|
|
58
66
|
Input.propTypes = {
|
|
59
67
|
type: PropTypes.string.isRequired,
|
|
60
68
|
label: PropTypes.string.isRequired,
|
|
@@ -68,3 +76,5 @@ Input.propTypes = {
|
|
|
68
76
|
labelClassName: PropTypes.string,
|
|
69
77
|
groupClassName: PropTypes.string,
|
|
70
78
|
};
|
|
79
|
+
|
|
80
|
+
export default Input;
|
package/bootstrap/Modal.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2020 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2020-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, { useRef, useEffect } from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
|
-
import { Portal } from "../utils/Portal";
|
|
12
12
|
import { useClickOutside } from "../utils/hooks";
|
|
13
|
+
import Portal from "../utils/Portal";
|
|
13
14
|
import "./Modal.css";
|
|
14
15
|
|
|
15
16
|
Modal.propTypes = {
|
|
@@ -92,11 +93,10 @@ export function ModalHeader({ setShown, title }) {
|
|
|
92
93
|
<h5 className="modal-title">{title}</h5>
|
|
93
94
|
<button
|
|
94
95
|
type="button"
|
|
95
|
-
className="close"
|
|
96
|
+
className="btn-close"
|
|
96
97
|
onClick={() => setShown(false)}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</button>
|
|
98
|
+
aria-label={_("Close")}
|
|
99
|
+
/>
|
|
100
100
|
</div>
|
|
101
101
|
);
|
|
102
102
|
}
|
package/bootstrap/NumberInput.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
12
|
+
import Input from "./Input";
|
|
11
13
|
import { useConditionalTimeout } from "../utils/hooks";
|
|
12
|
-
import { Input } from "./Input";
|
|
13
14
|
import "./NumberInput.css";
|
|
14
15
|
|
|
15
16
|
NumberInput.propTypes = {
|
|
@@ -23,7 +24,7 @@ NumberInput.propTypes = {
|
|
|
23
24
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
24
25
|
/** Function called when value changes. */
|
|
25
26
|
onChange: PropTypes.func.isRequired,
|
|
26
|
-
/** Additional description
|
|
27
|
+
/** Additional description displayed to the right of input value. */
|
|
27
28
|
inlineText: PropTypes.string,
|
|
28
29
|
};
|
|
29
30
|
|
|
@@ -31,7 +32,7 @@ NumberInput.defaultProps = {
|
|
|
31
32
|
value: 0,
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
function NumberInput({ onChange, inlineText, value, ...props }) {
|
|
35
36
|
function updateValue(initialValue, difference) {
|
|
36
37
|
onChange({ target: { value: initialValue + difference } });
|
|
37
38
|
}
|
|
@@ -49,27 +50,29 @@ export function NumberInput({ onChange, inlineText, value, ...props }) {
|
|
|
49
50
|
|
|
50
51
|
return (
|
|
51
52
|
<Input type="number" onChange={onChange} value={value} {...props}>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</
|
|
53
|
+
{inlineText && (
|
|
54
|
+
<span className="input-group-text">{inlineText}</span>
|
|
55
|
+
)}
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
className="btn btn-outline-secondary"
|
|
59
|
+
onMouseDown={() => enableIncrease(true)}
|
|
60
|
+
onMouseUp={() => enableIncrease(false)}
|
|
61
|
+
aria-label="Increase"
|
|
62
|
+
>
|
|
63
|
+
<i className="fas fa-plus" />
|
|
64
|
+
</button>
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
className="btn btn-outline-secondary"
|
|
68
|
+
onMouseDown={() => enableDecrease(true)}
|
|
69
|
+
onMouseUp={() => enableDecrease(false)}
|
|
70
|
+
aria-label="Decrease"
|
|
71
|
+
>
|
|
72
|
+
<i className="fas fa-minus" />
|
|
73
|
+
</button>
|
|
73
74
|
</Input>
|
|
74
75
|
);
|
|
75
76
|
}
|
|
77
|
+
|
|
78
|
+
export default NumberInput;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019-
|
|
2
|
+
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
3
3
|
*
|
|
4
4
|
* This is free software, licensed under the GNU General Public License v3.
|
|
5
5
|
* See /LICENSE for more information.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, { useState } from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
|
-
import
|
|
12
|
+
import Input from "./Input";
|
|
12
13
|
|
|
13
14
|
PasswordInput.propTypes = {
|
|
14
15
|
/** Field label. */
|
|
@@ -25,7 +26,7 @@ PasswordInput.propTypes = {
|
|
|
25
26
|
newPass: PropTypes.bool,
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
function PasswordInput({ withEye, newPass, ...props }) {
|
|
29
30
|
const [isHidden, setHidden] = useState(true);
|
|
30
31
|
|
|
31
32
|
return (
|
|
@@ -34,24 +35,22 @@ export function PasswordInput({ withEye, newPass, ...props }) {
|
|
|
34
35
|
autoComplete={newPass ? "new-password" : "current-password"}
|
|
35
36
|
{...props}
|
|
36
37
|
>
|
|
37
|
-
{withEye
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/>
|
|
52
|
-
</button>
|
|
53
|
-
</div>
|
|
54
|
-
) : null}
|
|
38
|
+
{withEye && (
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className="input-group-text"
|
|
42
|
+
onClick={(e) => {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
setHidden((shouldBeHidden) => !shouldBeHidden);
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<i
|
|
48
|
+
className={`fa ${isHidden ? "fa-eye" : "fa-eye-slash"}`}
|
|
49
|
+
/>
|
|
50
|
+
</button>
|
|
51
|
+
)}
|
|
55
52
|
</Input>
|
|
56
53
|
);
|
|
57
54
|
}
|
|
55
|
+
|
|
56
|
+
export default PasswordInput;
|