foris 5.6.0 → 5.6.1-beta.39257567

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.
@@ -38,16 +38,17 @@ Alert.defaultProps = {
38
38
  export function Alert({ type, onDismiss, children }) {
39
39
  return (
40
40
  <div
41
- className={`alert ${
41
+ className={`alert alert-${type} ${
42
42
  onDismiss ? "alert-dismissible" : ""
43
- } alert-${type}`}
43
+ }`.trim()}
44
44
  >
45
- {onDismiss ? (
46
- <button type="button" className="close" onClick={onDismiss}>
47
- &times;
48
- </button>
49
- ) : (
50
- false
45
+ {onDismiss && (
46
+ <button
47
+ type="button"
48
+ className="btn-close"
49
+ onClick={onDismiss}
50
+ aria-label={_("Close")}
51
+ />
51
52
  )}
52
53
  {children}
53
54
  </div>
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2023 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.
@@ -31,24 +31,25 @@ export function Button({
31
31
  children,
32
32
  ...props
33
33
  }) {
34
- let buttonClass = className ? `btn ${className}` : "btn btn-primary ";
34
+ let buttonClass = className ? `btn ${className}` : "btn btn-primary";
35
35
  if (forisFormSize) {
36
- buttonClass = `${buttonClass} col-sm-12 col-md-3 col-lg-2`;
36
+ buttonClass = `${buttonClass} col-12 col-md-3 col-lg-2`;
37
37
  }
38
38
 
39
- const span = loading ? (
40
- <span
41
- className="spinner-border spinner-border-sm"
42
- role="status"
43
- aria-hidden="true"
44
- />
45
- ) : null;
46
-
47
39
  return (
48
- <button type="button" className={buttonClass} {...props}>
49
- {span}
50
- {span ? " " : null}
51
- {children}
40
+ <button
41
+ type="button"
42
+ className={`${buttonClass} d-inline-flex justify-content-center align-items-center`}
43
+ {...props}
44
+ >
45
+ {loading && (
46
+ <span
47
+ className="spinner-border spinner-border-sm me-1"
48
+ role="status"
49
+ aria-hidden="true"
50
+ />
51
+ )}
52
+ <span>{children}</span>
52
53
  </button>
53
54
  );
54
55
  }
@@ -24,25 +24,24 @@ CheckBox.defaultProps = {
24
24
 
25
25
  export function CheckBox({ label, helpText, disabled, ...props }) {
26
26
  const uid = useUID();
27
+
27
28
  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>
29
+ <div className="mb-3 form-check">
30
+ <input
31
+ className="form-check-input"
32
+ type="checkbox"
33
+ id={uid}
34
+ disabled={disabled}
35
+ {...props}
36
+ />
37
+ <label className="form-check-label" htmlFor={uid}>
38
+ {label}
39
+ </label>
40
+ {helpText && (
41
+ <div className="form-text">
42
+ <small>{helpText}</small>
43
+ </div>
44
+ )}
46
45
  </div>
47
46
  );
48
47
  }
@@ -27,18 +27,21 @@ export const Input = forwardRef(
27
27
  ) => {
28
28
  const uid = useUID();
29
29
 
30
- const inputClassName = `form-control ${className || ""} ${
30
+ const inputClassName = `${className || ""} ${
31
31
  error ? "is-invalid" : ""
32
32
  }`.trim();
33
33
 
34
34
  return (
35
- <div className="form-group">
36
- <label className={labelClassName} htmlFor={uid}>
35
+ <div className="mb-3">
36
+ <label
37
+ className={`form-label ${labelClassName || ""}`.trim()}
38
+ htmlFor={uid}
39
+ >
37
40
  {label}
38
41
  </label>
39
42
  <div className={`input-group ${groupClassName || ""}`.trim()}>
40
43
  <input
41
- className={inputClassName}
44
+ className={`form-control ${inputClassName}`.trim()}
42
45
  type={type}
43
46
  id={uid}
44
47
  ref={ref}
@@ -46,10 +49,12 @@ export const Input = forwardRef(
46
49
  />
47
50
  {children}
48
51
  </div>
49
- {error ? <div className="invalid-feedback">{error}</div> : null}
50
- {helpText ? (
51
- <small className="form-text text-muted">{helpText}</small>
52
- ) : null}
52
+ {error && <div className="invalid-feedback">{error}</div>}
53
+ {helpText && (
54
+ <div className="form-text">
55
+ <small>{helpText}</small>
56
+ </div>
57
+ )}
53
58
  </div>
54
59
  );
55
60
  }
@@ -92,11 +92,10 @@ export function ModalHeader({ setShown, title }) {
92
92
  <h5 className="modal-title">{title}</h5>
93
93
  <button
94
94
  type="button"
95
- className="close"
95
+ className="btn-close"
96
96
  onClick={() => setShown(false)}
97
- >
98
- <span aria-hidden="true">&times;</span>
99
- </button>
97
+ aria-label={_("Close")}
98
+ />
100
99
  </div>
101
100
  );
102
101
  }
@@ -23,7 +23,7 @@ NumberInput.propTypes = {
23
23
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
24
24
  /** Function called when value changes. */
25
25
  onChange: PropTypes.func.isRequired,
26
- /** Additional description dispaled to the right of input value. */
26
+ /** Additional description displayed to the right of input value. */
27
27
  inlineText: PropTypes.string,
28
28
  };
29
29
 
@@ -49,27 +49,27 @@ export function NumberInput({ onChange, inlineText, value, ...props }) {
49
49
 
50
50
  return (
51
51
  <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>
52
+ {inlineText && (
53
+ <span className="input-group-text">{inlineText}</span>
54
+ )}
55
+ <button
56
+ type="button"
57
+ className="btn btn-outline-secondary"
58
+ onMouseDown={() => enableIncrease(true)}
59
+ onMouseUp={() => enableIncrease(false)}
60
+ aria-label="Increase"
61
+ >
62
+ <i className="fas fa-plus" />
63
+ </button>
64
+ <button
65
+ type="button"
66
+ className="btn btn-outline-secondary"
67
+ onMouseDown={() => enableDecrease(true)}
68
+ onMouseUp={() => enableDecrease(false)}
69
+ aria-label="Decrease"
70
+ >
71
+ <i className="fas fa-minus" />
72
+ </button>
73
73
  </Input>
74
74
  );
75
75
  }
@@ -34,24 +34,20 @@ export function PasswordInput({ withEye, newPass, ...props }) {
34
34
  autoComplete={newPass ? "new-password" : "current-password"}
35
35
  {...props}
36
36
  >
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}
37
+ {withEye && (
38
+ <button
39
+ type="button"
40
+ className="input-group-text"
41
+ onClick={(e) => {
42
+ e.preventDefault();
43
+ setHidden((shouldBeHidden) => !shouldBeHidden);
44
+ }}
45
+ >
46
+ <i
47
+ className={`fa ${isHidden ? "fa-eye" : "fa-eye-slash"}`}
48
+ />
49
+ </button>
50
+ )}
55
51
  </Input>
56
52
  );
57
53
  }
@@ -17,7 +17,7 @@ RadioSet.propTypes = {
17
17
  /** Choices . */
18
18
  choices: PropTypes.arrayOf(
19
19
  PropTypes.shape({
20
- /** Choice lable . */
20
+ /** Choice label . */
21
21
  label: PropTypes.oneOfType([
22
22
  PropTypes.string,
23
23
  PropTypes.element,
@@ -64,7 +64,7 @@ export function RadioSet({
64
64
  });
65
65
 
66
66
  return (
67
- <div className="form-group">
67
+ <div className="mb-3">
68
68
  {label && (
69
69
  <label htmlFor={uid} className="d-block">
70
70
  {label}
@@ -72,7 +72,9 @@ export function RadioSet({
72
72
  )}
73
73
  {radios}
74
74
  {helpText && (
75
- <small className="form-text text-muted">{helpText}</small>
75
+ <div className="form-text">
76
+ <small>{helpText}</small>
77
+ </div>
76
78
  )}
77
79
  </div>
78
80
  );
@@ -94,24 +96,24 @@ export function Radio({ label, id, helpText, inline, ...props }) {
94
96
  return (
95
97
  <>
96
98
  <div
97
- className={`custom-control custom-radio ${
98
- inline ? "custom-control-inline" : ""
99
+ className={`mb-2 ${
100
+ inline ? "form-check form-check-inline" : ""
99
101
  }`.trim()}
100
102
  >
101
103
  <input
102
104
  id={id}
103
- className="custom-control-input"
105
+ className="form-check-input me-2"
104
106
  type="radio"
105
107
  {...props}
106
108
  />
107
- <label className="custom-control-label" htmlFor={id}>
109
+ <label className="form-check-label" htmlFor={id}>
108
110
  {label}
111
+ {helpText && (
112
+ <div className="form-text">
113
+ <small>{helpText}</small>
114
+ </div>
115
+ )}
109
116
  </label>
110
- {helpText && (
111
- <small className="form-text text-muted mt-0 mb-3">
112
- {helpText}
113
- </small>
114
- )}
115
117
  </div>
116
118
  </>
117
119
  );
@@ -30,14 +30,18 @@ export function Select({ label, choices, helpText, ...props }) {
30
30
  ));
31
31
 
32
32
  return (
33
- <div className="form-group">
34
- <label htmlFor={uid}>{label}</label>
35
- <select className="custom-select" id={uid} {...props}>
33
+ <div className="mb-3">
34
+ <label className="form-label" htmlFor={uid}>
35
+ {label}
36
+ </label>
37
+ <select className="form-select" id={uid} {...props}>
36
38
  {options}
37
39
  </select>
38
- {helpText ? (
39
- <small className="form-text text-muted">{helpText}</small>
40
- ) : null}
40
+ {helpText && (
41
+ <div className="form-text">
42
+ <small>{helpText}</small>
43
+ </div>
44
+ )}
41
45
  </div>
42
46
  );
43
47
  }
@@ -1,3 +1,11 @@
1
+ .spinner-fs-wrapper {
2
+ position: fixed;
3
+ top: 50%;
4
+ left: 50%;
5
+ transform: translate(-50%, -50%);
6
+ z-index: 1101; /* increase z-index by 1 to ensure it's on top of spinner-fs-background */
7
+ }
8
+
1
9
  .spinner-wrapper .spinner-border {
2
10
  width: 4rem;
3
11
  height: 4rem;
@@ -7,10 +15,8 @@
7
15
  .spinner-fs-background {
8
16
  background-color: rgba(2, 2, 2, 0.5);
9
17
  color: rgb(230, 230, 230);
10
- position: fixed;
11
- width: 100%;
12
- height: 100%;
13
- top: 0;
18
+ width: 100vw;
19
+ height: 100vh;
14
20
 
15
21
  display: flex;
16
22
  align-items: center;
@@ -31,3 +37,7 @@
31
37
  .spinner-fs-wrapper .spinner-text {
32
38
  margin: 1rem;
33
39
  }
40
+
41
+ .spinner-border-sm {
42
+ min-width: 16px;
43
+ }
@@ -16,7 +16,7 @@ Spinner.propTypes = {
16
16
  PropTypes.arrayOf(PropTypes.node),
17
17
  PropTypes.node,
18
18
  ]),
19
- /** Render component with full-screen mode (using apropriate `.css` styles) */
19
+ /** Render component with full-screen mode (using appropriate `.css` styles) */
20
20
  fullScreen: PropTypes.bool.isRequired,
21
21
  className: PropTypes.string,
22
22
  };
@@ -22,28 +22,30 @@ Switch.propTypes = {
22
22
 
23
23
  export function Switch({ label, helpText, switchHeading, ...props }) {
24
24
  const uid = useUID();
25
+
25
26
  return (
26
- <div className={`form-group ${switchHeading ? "switch" : ""}`.trim()}>
27
- <div
28
- className={`custom-control custom-switch ${
29
- !helpText ? "custom-control-inline" : ""
30
- } ${switchHeading ? "switch-heading" : ""}`.trim()}
31
- >
32
- <input
33
- type="checkbox"
34
- className="custom-control-input"
35
- id={uid}
36
- {...props}
37
- />
38
- <label className="custom-control-label" htmlFor={uid}>
39
- {label}
40
- </label>
41
- {helpText && (
42
- <small className="form-text text-muted mt-0 mb-3">
43
- {helpText}
44
- </small>
45
- )}
46
- </div>
27
+ <div
28
+ className={`form-check form-switch mb-3 ${
29
+ switchHeading ? "d-flex align-items-center" : null
30
+ }`.trim()}
31
+ >
32
+ <input
33
+ type="checkbox"
34
+ className={`form-check-input ${
35
+ switchHeading ? "me-2" : ""
36
+ }`.trim()}
37
+ role="switch"
38
+ id={uid}
39
+ {...props}
40
+ />
41
+ <label className="form-check-label" htmlFor={uid}>
42
+ {label}
43
+ </label>
44
+ {helpText && (
45
+ <div className="form-text">
46
+ <small>{helpText}</small>
47
+ </div>
48
+ )}
47
49
  </div>
48
50
  );
49
51
  }
@@ -58,7 +58,7 @@ export function ResetWiFiSettings({ ws, endpoint }) {
58
58
  "If a number of wireless cards doesn't match, you may try to reset the Wi-Fi settings. Note that this will remove the current Wi-Fi configuration and restore the default values."
59
59
  )}
60
60
  </p>
61
- <div className="text-right">
61
+ <div className="text-end">
62
62
  <Button
63
63
  className="btn-primary"
64
64
  forisFormSize
@@ -92,7 +92,7 @@ function DeviceForm({
92
92
  return (
93
93
  <>
94
94
  <Switch
95
- label={<h2>{_(`Wi-Fi ${deviceID + 1}`)}</h2>}
95
+ label={<h2 className="mb-0">{_(`Wi-Fi ${deviceID + 1}`)}</h2>}
96
96
  checked={formData.enabled}
97
97
  onChange={setFormValue((value) => ({
98
98
  devices: {
@@ -119,12 +119,10 @@ function DeviceForm({
119
119
  }))}
120
120
  {...props}
121
121
  >
122
- <div className="input-group-append">
123
- <WiFiQRCode
124
- SSID={formData.SSID}
125
- password={formData.password}
126
- />
127
- </div>
122
+ <WiFiQRCode
123
+ SSID={formData.SSID}
124
+ password={formData.password}
125
+ />
128
126
  </TextInput>
129
127
 
130
128
  <PasswordInput
@@ -87,7 +87,7 @@ function QRCodeModal({ shown, setShown, SSID, password }) {
87
87
  createAndDownloadPdf(SSID, password);
88
88
  }}
89
89
  >
90
- <i className="fas fa-arrow-down mr-2" />
90
+ <i className="fas fa-file-download me-2" />
91
91
  {_("Download PDF")}
92
92
  </Button>
93
93
  </ModalFooter>
Binary file
@@ -190,7 +190,7 @@ export function ForisForm({
190
190
  <Prompt message={getMessageOnLeavingPage} />
191
191
  <form onSubmit={onSubmit} ref={formReference}>
192
192
  {childrenWithFormProps}
193
- <div className="text-right">
193
+ <div className="text-end">
194
194
  <SubmitButton
195
195
  state={getSubmitButtonState()}
196
196
  disabled={submitButtonIsDisabled}
package/index.js CHANGED
@@ -69,7 +69,7 @@ export {
69
69
  withErrorMessage,
70
70
  } from "./utils/conditionalHOCs";
71
71
  export { ErrorMessage } from "./utils/ErrorMessage";
72
- export { useClickOutside } from "./utils/hooks";
72
+ export { useClickOutside, useTooltip } from "./utils/hooks";
73
73
  export { toLocaleDateString } from "./utils/datetime";
74
74
  export { displayCard } from "./utils/displayCard";
75
75
  export { isPluginInstalled } from "./utils/isPluginInstalled";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foris",
3
- "version": "5.6.0",
3
+ "version": "5.6.1-beta.39257567",
4
4
  "description": "Foris JS library is a set of components and utils for reForis application and plugins.",
5
5
  "author": "CZ.NIC, z.s.p.o.",
6
6
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "react-uid": "^2.2.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "bootstrap": "4.4.1",
25
+ "bootstrap": "^5.3.3",
26
26
  "prop-types": "15.8.1",
27
27
  "react": "16.9.0",
28
28
  "react-dom": "16.9.0",
@@ -34,11 +34,11 @@
34
34
  "@babel/plugin-transform-runtime": "^7.9.0",
35
35
  "@babel/preset-env": "^7.9.0",
36
36
  "@babel/preset-react": "^7.9.4",
37
- "@fortawesome/fontawesome-free": "^5.13.0",
37
+ "@fortawesome/fontawesome-free": "^6.5.2",
38
38
  "@testing-library/react": "^8.0.9",
39
39
  "babel-loader": "^8.1.0",
40
40
  "babel-polyfill": "^6.26.0",
41
- "bootstrap": "^4.5.0",
41
+ "bootstrap": "^5.3.3",
42
42
  "css-loader": "^5.2.4",
43
43
  "eslint": "^6.8.0",
44
44
  "eslint-config-prettier": "^6.11.0",