foris 5.6.1 → 6.0.0-beta.0b02bead

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 (45) hide show
  1. package/api/hooks.js +11 -3
  2. package/bootstrap/Alert.js +14 -10
  3. package/bootstrap/Button.js +7 -10
  4. package/bootstrap/CheckBox.js +22 -20
  5. package/bootstrap/CopyInput.js +7 -3
  6. package/bootstrap/DataTimeInput.js +9 -6
  7. package/bootstrap/DownloadButton.js +5 -2
  8. package/bootstrap/EmailInput.js +7 -2
  9. package/bootstrap/FileInput.js +6 -3
  10. package/bootstrap/Input.js +20 -10
  11. package/bootstrap/Modal.js +6 -6
  12. package/bootstrap/NumberInput.js +28 -25
  13. package/bootstrap/PasswordInput.js +20 -21
  14. package/bootstrap/RadioSet.js +26 -33
  15. package/bootstrap/Select.js +15 -8
  16. package/bootstrap/Spinner.css +10 -4
  17. package/bootstrap/Spinner.js +2 -1
  18. package/bootstrap/Switch.js +27 -23
  19. package/bootstrap/TextInput.js +8 -3
  20. package/bootstrap/constants.js +5 -4
  21. package/common/RebootButton.js +9 -7
  22. package/common/WiFiSettings/ResetWiFiSettings.js +11 -8
  23. package/common/WiFiSettings/WiFiForm.js +16 -16
  24. package/common/WiFiSettings/WiFiGuestForm.js +6 -5
  25. package/common/WiFiSettings/WiFiQRCode.js +6 -5
  26. package/common/WiFiSettings/WiFiSettings.js +7 -4
  27. package/context/alertContext/AlertContext.js +10 -5
  28. package/context/customizationContext/CustomizationContext.js +24 -13
  29. package/foris-6.0.0.tgz +0 -0
  30. package/form/components/ForisForm.js +16 -14
  31. package/form/components/SubmitButton.js +2 -1
  32. package/form/hooks.js +3 -2
  33. package/index.js +27 -27
  34. package/package.json +25 -26
  35. package/utils/ErrorMessage.js +5 -2
  36. package/utils/Portal.js +10 -2
  37. package/utils/conditionalHOCs.js +14 -7
  38. package/utils/datetime.js +3 -4
  39. package/utils/displayCard.js +4 -2
  40. package/utils/hooks.js +1 -1
  41. package/utils/isPluginInstalled.js +4 -2
  42. package/utils/validations.js +6 -3
  43. package/webSockets/WebSockets.js +4 -4
  44. package/webSockets/hooks.js +5 -2
  45. 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
- export { useAPIGet, useAPIPost, useAPIPatch, useAPIPut, useAPIDelete };
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
+ };
@@ -1,11 +1,12 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
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
- export function Alert({ type, onDismiss, children }) {
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
- } alert-${type}`}
44
+ }`.trim()}
44
45
  >
45
- {onDismiss ? (
46
- <button type="button" className="close" onClick={onDismiss}>
47
- &times;
48
- </button>
49
- ) : (
50
- false
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;
@@ -1,11 +1,12 @@
1
1
  /*
2
- * Copyright (C) 2019-2023 CZ.NIC z.s.p.o. (https://www.nic.cz/)
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
- export function Button({
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-sm-12 col-md-3 col-lg-2`;
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 mr-1"
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;
@@ -1,11 +1,12 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
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
- export function CheckBox({ label, helpText, disabled, ...props }) {
26
+ function CheckBox({ label, helpText, disabled, ...props }) {
26
27
  const uid = useUID();
28
+
27
29
  return (
28
- <div className="form-group">
29
- <div className="custom-control custom-checkbox ">
30
- <input
31
- className="custom-control-input"
32
- type="checkbox"
33
- id={uid}
34
- disabled={disabled}
35
- {...props}
36
- />
37
- <label className="custom-control-label" htmlFor={uid}>
38
- {label}
39
- {helpText && (
40
- <small className="form-text text-muted">
41
- {helpText}
42
- </small>
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;
@@ -1,13 +1,15 @@
1
1
  /*
2
- * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
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
- import { Input } from "./Input";
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
- export function CopyInput({ value, ...props }) {
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. (http://www.nic.cz/)
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 { Input } from "./Input";
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
- export function DataTimeInput({
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
- function renderInput(datetimeProps) {
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. (http://www.nic.cz/)
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
- export function DownloadButton({ href, className, children, ...props }) {
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;
@@ -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 { Input } from "./Input";
12
+ import Input from "./Input";
12
13
 
13
- export const EmailInput = ({ ...props }) => <Input type="email" {...props} />;
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;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
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
- import { Input } from "./Input";
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
- export function FileInput({ ...props }) {
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;
@@ -6,11 +6,12 @@
6
6
  */
7
7
 
8
8
  import React, { forwardRef } from "react";
9
- import { useUID } from "react-uid";
9
+
10
10
  import PropTypes from "prop-types";
11
+ import { useUID } from "react-uid";
11
12
 
12
13
  /** Base bootstrap input component. */
13
- export const Input = forwardRef(
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 = `form-control ${className || ""} ${
31
+ const inputClassName = `${className || ""} ${
31
32
  error ? "is-invalid" : ""
32
33
  }`.trim();
33
34
 
34
35
  return (
35
- <div className="form-group">
36
- <label className={labelClassName} htmlFor={uid}>
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 ? <div className="invalid-feedback">{error}</div> : null}
50
- {helpText ? (
51
- <small className="form-text text-muted">{helpText}</small>
52
- ) : null}
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;
@@ -1,15 +1,16 @@
1
1
  /*
2
- * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
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
- <span aria-hidden="true">&times;</span>
99
- </button>
98
+ aria-label={_("Close")}
99
+ />
100
100
  </div>
101
101
  );
102
102
  }
@@ -1,15 +1,16 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
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 dispaled to the right of input value. */
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
- export function NumberInput({ onChange, inlineText, value, ...props }) {
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
- <div className="input-group-append">
53
- {inlineText && <p className="input-group-text">{inlineText}</p>}
54
- <button
55
- type="button"
56
- className="btn btn-outline-secondary"
57
- onMouseDown={() => enableIncrease(true)}
58
- onMouseUp={() => enableIncrease(false)}
59
- aria-label="Increase"
60
- >
61
- <i className="fas fa-plus" />
62
- </button>
63
- <button
64
- type="button"
65
- className="btn btn-outline-secondary"
66
- onMouseDown={() => enableDecrease(true)}
67
- onMouseUp={() => enableDecrease(false)}
68
- aria-label="Decrease"
69
- >
70
- <i className="fas fa-minus" />
71
- </button>
72
- </div>
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-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
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 { Input } from "./Input";
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
- export function PasswordInput({ withEye, newPass, ...props }) {
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
- <div className="input-group-append">
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 ${
49
- isHidden ? "fa-eye" : "fa-eye-slash"
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;