foris 5.3.0-beta.1bb8abd6 → 5.3.0-beta.92ed7f1e

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.
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
+ *
4
+ * This is free software, licensed under the GNU General Public License v3.
5
+ * See /LICENSE for more information.
6
+ */
7
+
8
+ import React, { useState, useRef } from "react";
9
+ import PropTypes from "prop-types";
10
+ import { Input } from "./Input";
11
+
12
+ CopyInput.propTypes = {
13
+ /** Field label. */
14
+ label: PropTypes.string.isRequired,
15
+ /** Field value. */
16
+ value: PropTypes.string,
17
+ /** Help text message. */
18
+ helpText: PropTypes.string,
19
+ /** Disable input field */
20
+ disabled: PropTypes.bool,
21
+ /** Readonly input field */
22
+ readOnly: PropTypes.bool,
23
+ };
24
+
25
+ export function CopyInput({ value, ...props }) {
26
+ const inputTextRef = useRef();
27
+ const [isCopied, setIsCopied] = useState(false);
28
+
29
+ const handleCopyClick = async () => {
30
+ // Clipboard API works only in a secure (HTTPS) context.
31
+ if (navigator.clipboard) {
32
+ await navigator.clipboard.writeText(value);
33
+ } else {
34
+ // Fallback to the "classic" copy to clipboard implementation.
35
+ inputTextRef.current.focus();
36
+ inputTextRef.current.select();
37
+ document.execCommand("copy");
38
+ inputTextRef.current.blur();
39
+ }
40
+
41
+ setIsCopied(true);
42
+ setTimeout(() => {
43
+ setIsCopied(false);
44
+ }, 1500);
45
+ };
46
+
47
+ return (
48
+ <Input type="text" value={value} ref={inputTextRef} {...props}>
49
+ <div className="input-group-append">
50
+ <button
51
+ className="btn btn-outline-secondary"
52
+ type="button"
53
+ onClick={handleCopyClick}
54
+ >
55
+ <span>{isCopied ? _("Copied!") : _("Copy")}</span>
56
+ </button>
57
+ </div>
58
+ </Input>
59
+ );
60
+ }
@@ -0,0 +1,17 @@
1
+ CopyInput Bootstrap component contains input with a label, predefined sizes, and
2
+ structure for use in ForisForm and the "Copy" button (copy to clipboard). It can
3
+ be used with `readOnly` and `disabled` parameters, please see an example.
4
+
5
+ All additional `props` are passed to the `<input type="text">` HTML component.
6
+
7
+ ```js
8
+ import React, { useState } from "react";
9
+ const [value, setValue] = useState("Text to appear in clipboard.");
10
+
11
+ <CopyInput
12
+ label="Copy me"
13
+ value={value}
14
+ helpText="Read the small text!"
15
+ readOnly
16
+ />;
17
+ ```
@@ -1,14 +1,60 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 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
- import React from "react";
8
+ import React, { forwardRef } from "react";
9
9
  import { useUID } from "react-uid";
10
10
  import PropTypes from "prop-types";
11
11
 
12
+ /** Base bootstrap input component. */
13
+ export const Input = forwardRef(
14
+ (
15
+ {
16
+ type,
17
+ label,
18
+ helpText,
19
+ error,
20
+ className,
21
+ children,
22
+ labelClassName,
23
+ groupClassName,
24
+ ...props
25
+ },
26
+ ref
27
+ ) => {
28
+ const uid = useUID();
29
+
30
+ const inputClassName = `form-control ${className || ""} ${
31
+ error ? "is-invalid" : ""
32
+ }`.trim();
33
+
34
+ return (
35
+ <div className="form-group">
36
+ <label className={labelClassName} htmlFor={uid}>
37
+ {label}
38
+ </label>
39
+ <div className={`input-group ${groupClassName || ""}`.trim()}>
40
+ <input
41
+ className={inputClassName}
42
+ type={type}
43
+ id={uid}
44
+ ref={ref}
45
+ {...props}
46
+ />
47
+ {children}
48
+ </div>
49
+ {error ? <div className="invalid-feedback">{error}</div> : null}
50
+ {helpText ? (
51
+ <small className="form-text text-muted">{helpText}</small>
52
+ ) : null}
53
+ </div>
54
+ );
55
+ }
56
+ );
57
+
12
58
  Input.propTypes = {
13
59
  type: PropTypes.string.isRequired,
14
60
  label: PropTypes.string.isRequired,
@@ -22,41 +68,3 @@ Input.propTypes = {
22
68
  labelClassName: PropTypes.string,
23
69
  groupClassName: PropTypes.string,
24
70
  };
25
-
26
- /** Base bootstrap input component. */
27
- export function Input({
28
- type,
29
- label,
30
- helpText,
31
- error,
32
- className,
33
- children,
34
- labelClassName,
35
- groupClassName,
36
- ...props
37
- }) {
38
- const uid = useUID();
39
- const inputClassName = `form-control ${className || ""} ${
40
- error ? "is-invalid" : ""
41
- }`.trim();
42
- return (
43
- <div className="form-group">
44
- <label className={labelClassName} htmlFor={uid}>
45
- {label}
46
- </label>
47
- <div className={`input-group ${groupClassName || ""}`.trim()}>
48
- <input
49
- className={inputClassName}
50
- type={type}
51
- id={uid}
52
- {...props}
53
- />
54
- {children}
55
- </div>
56
- {error ? <div className="invalid-feedback">{error}</div> : null}
57
- {helpText ? (
58
- <small className="form-text text-muted">{helpText}</small>
59
- ) : null}
60
- </div>
61
- );
62
- }
@@ -183,7 +183,7 @@ function DeviceForm({
183
183
  />
184
184
 
185
185
  <Select
186
- label={_("802.11n/ac mode")}
186
+ label={_("802.11n/ac/ax mode")}
187
187
  choices={getHtmodeChoices(formData)}
188
188
  value={formData.htmode}
189
189
  helpText={HELP_TEXTS.htmode}
@@ -41,7 +41,7 @@ export const HELP_TEXTS = {
41
41
  "The 2.4 GHz band is more widely supported by clients, but tends to have more interference. The 5 GHz band is a newer standard and may not be supported by all your devices. It usually has less interference, but the signal does not carry so well indoors."
42
42
  ),
43
43
  htmode: _(
44
- "Change this to adjust 802.11n/ac mode of operation. 802.11n with 40 MHz wide channels can yield higher throughput but can cause more interference in the network. If you don't know what to choose, use the default option with 20 MHz wide channel."
44
+ "Change this to adjust 802.11n/ac/ax mode of operation. 802.11n with 40 MHz wide channels can yield higher throughput but can cause more interference in the network. If you don't know what to choose, use the default option with 20 MHz wide channel."
45
45
  ),
46
46
  guest_wifi_enabled: _(
47
47
  "Enables Wi-Fi for guests, which is separated from LAN network. Devices connected to this network are allowed to access the internet, but aren't allowed to access other devices and the configuration interface of the router. Parameters of the guest network can be set in the Guest network tab."
package/foris-5.3.0.tgz CHANGED
Binary file
package/index.js CHANGED
@@ -20,6 +20,7 @@ export { API_STATE } from "./api/utils";
20
20
  export { Alert, ALERT_TYPES } from "./bootstrap/Alert";
21
21
  export { Button } from "./bootstrap/Button";
22
22
  export { CheckBox } from "./bootstrap/CheckBox";
23
+ export { CopyInput } from "./bootstrap/CopyInput";
23
24
  export { DownloadButton } from "./bootstrap/DownloadButton";
24
25
  export { DataTimeInput } from "./bootstrap/DataTimeInput";
25
26
  export { EmailInput } from "./bootstrap/EmailInput";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foris",
3
- "version": "5.3.0-beta.1bb8abd6",
3
+ "version": "5.3.0-beta.92ed7f1e",
4
4
  "description": "Set of components and utils for Foris and its plugins.",
5
5
  "author": "CZ.NIC, z.s.p.o.",
6
6
  "repository": {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2020-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2020-2022 CZ.NIC z.s.p.o. (http://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.
@@ -10,8 +10,10 @@
10
10
  const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
11
11
 
12
12
  const URL = process.env.LIGHTTPD
13
- ? `${PROTOCOL}://${window.location.host}/foris-ws`
14
- : `${PROTOCOL}://${window.location.hostname}:${9081}`;
13
+ ? `${PROTOCOL}://${window.location.host}/${
14
+ process.env.WSPATH || "foris-ws"
15
+ }`
16
+ : `${PROTOCOL}://${window.location.hostname}:9081`;
15
17
 
16
18
  const WAITING_FOR_CONNECTION_TIMEOUT = 500;
17
19