foris 6.7.1 → 6.7.2-beta.9da7bf6b

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.
@@ -4,7 +4,7 @@ using in foris forms.
4
4
  All additional `props` are passed to the `<input type="checkbox">` HTML
5
5
  component.
6
6
 
7
- ```js
7
+ ```jsx
8
8
  import { useState } from "react";
9
9
  const [value, setValue] = useState(false);
10
10
 
@@ -4,7 +4,7 @@ be used with `readOnly` and `disabled` parameters, please see an example.
4
4
 
5
5
  All additional `props` are passed to the `<input type="text">` HTML component.
6
6
 
7
- ```js
7
+ ```jsx
8
8
  import React, { useState } from "react";
9
9
  const [value, setValue] = useState("Text to appear in clipboard.");
10
10
 
@@ -4,7 +4,7 @@ Adopted from `react-datetime/DateTime` datatime picker component. It uses
4
4
  It requires `ForisTranslations.locale` to be defined in order to use right
5
5
  locale.
6
6
 
7
- ```js
7
+ ```jsx
8
8
  ForisTranslations = { locale: "en" };
9
9
 
10
10
  import { useState, useEffect } from "react";
@@ -5,6 +5,6 @@ Firefox. See
5
5
  [related issue](https://bugzilla.mozilla.org/show_bug.cgi?id=858538) for more
6
6
  details.
7
7
 
8
- ```js
8
+ ```jsx
9
9
  <DownloadButton href="example.zip">Download</DownloadButton>
10
10
  ```
@@ -4,10 +4,12 @@ checking. It's only meaningful using inside `<form>`.
4
4
 
5
5
  All additional `props` are passed to the `<input type="email">` HTML component.
6
6
 
7
- ```js
7
+ ```jsx
8
8
  import { useState } from "react";
9
9
  import Button from "./Button";
10
+
10
11
  const [email, setEmail] = useState("Wrong email");
12
+
11
13
  <form onSubmit={(e) => e.preventDefault()}>
12
14
  <EmailInput
13
15
  value={email}
@@ -3,7 +3,7 @@ structure for using in foris forms.
3
3
 
4
4
  All additional `props` are passed to the `<input type="file">` HTML component.
5
5
 
6
- ```js
6
+ ```jsx
7
7
  import { useState } from "react";
8
8
 
9
9
  const [files, setFiles] = useState([]);
@@ -23,7 +23,7 @@ const label = files.length === 1 ? files[0].name : "Choose file";
23
23
 
24
24
  ### FileInput with multiple files
25
25
 
26
- ```js
26
+ ```jsx
27
27
  import { useState } from "react";
28
28
 
29
29
  const [files, setFiles] = useState([]);
@@ -6,9 +6,9 @@ the page since modals are rendered in portals.
6
6
  Modals also have three optional sizes, which can be defined through the `size`
7
7
  prop:
8
8
 
9
- - small - `sm`
10
- - large - `lg`
11
- - extra-large - `xl`
9
+ - small - `sm`
10
+ - large - `lg`
11
+ - extra-large - `xl`
12
12
 
13
13
  For more details please visit Bootstrap
14
14
  <a href="https://getbootstrap.com/docs/4.5/components/modal/#optional-sizes" target="_blank">
@@ -18,7 +18,7 @@ documentation</a>.
18
18
  <div id="modal-container" />
19
19
  ```
20
20
 
21
- ```js
21
+ ```jsx
22
22
  import { ModalHeader, ModalBody, ModalFooter } from "./Modal";
23
23
 
24
24
  import { useState } from "react";
@@ -3,8 +3,9 @@ structure for using in foris forms.
3
3
 
4
4
  All additional `props` are passed to the `<input type="number">` HTML component.
5
5
 
6
- ```js
6
+ ```jsx
7
7
  import { useState } from "react";
8
+
8
9
  const [value, setValue] = useState(42);
9
10
 
10
11
  <NumberInput
@@ -4,7 +4,7 @@ for using in foris forms. Can be used with "eye" button, see example.
4
4
  All additional `props` are passed to the `<input type="password">` HTML
5
5
  component.
6
6
 
7
- ```js
7
+ ```jsx
8
8
  import { useState } from "react";
9
9
  const [value, setValue] = useState("secret");
10
10
 
@@ -5,8 +5,9 @@ All additional `props` are passed to the `<input type="number">` HTML component.
5
5
 
6
6
  Unless `helpText` is set for one of the options they are displayed inline.
7
7
 
8
- ```js
8
+ ```jsx
9
9
  import { useState } from "react";
10
+
10
11
  const CHOICES = [
11
12
  { value: "one", label: "1" },
12
13
  { value: "two", label: "2" },
@@ -3,8 +3,9 @@ and structure for using in foris forms.
3
3
 
4
4
  All additional `props` are passed to the `<select>` HTML component.
5
5
 
6
- ```js
6
+ ```jsx
7
7
  import { useState } from "react";
8
+
8
9
  const CHOICES = {
9
10
  apple: "Apple",
10
11
  banana: "Banana",
@@ -1,5 +1,5 @@
1
1
  Spiner Bootstrap component.
2
2
 
3
- ```js
3
+ ```jsx
4
4
  <Spinner>You can put text inside or any component you wish.</Spinner>
5
5
  ```
@@ -1,5 +1,5 @@
1
1
  Switch example:
2
2
 
3
- ```js
3
+ ```jsx
4
4
  <Switch label="Enable Switch" helpText="Toggle that switch!" />
5
5
  ```
@@ -3,8 +3,9 @@ using in foris forms.
3
3
 
4
4
  All additional `props` are passed to the `<input type="text">` HTML component.
5
5
 
6
- ```js
6
+ ```jsx
7
7
  import { useState } from "react";
8
+
8
9
  const [value, setValue] = useState("Bla bla");
9
10
 
10
11
  <TextInput
@@ -2,7 +2,7 @@ ThreeDotsMenu Bootstrap component is a dropdown menu that appears when the user
2
2
  clicks on three dots. It is used to display a list of actions that can be
3
3
  performed on a particular item.
4
4
 
5
- ```js
5
+ ```jsx
6
6
  import { useState } from "react";
7
7
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8
8
  import { faEdit, faTrash } from "@fortawesome/free-solid-svg-icons";
@@ -4,132 +4,14 @@ Rich Table is a table component based on
4
4
  [Tanstack React Table](https://tanstack.com/table/). It adds some features to
5
5
  the table component, such as:
6
6
 
7
- - **Pagination**: The table can be paginated.
8
- - **Sorting**: The table can be sorted by columns.
9
- - **Row Expansion**: The table rows can be expanded. (To be implemented)
7
+ - **Pagination**: The table can be paginated.
8
+ - **Sorting**: The table can be sorted by columns.
9
+ - **Row Expansion**: The table rows can be expanded. (To be implemented)
10
10
 
11
11
  ### Example
12
12
 
13
- ```js
14
- import RichTable from "./RichTable";
15
-
16
- const columns = [
17
- {
18
- header: "Name",
19
- accessorKey: "name",
20
- },
21
- {
22
- header: "Surname",
23
- accessorKey: "surname",
24
- },
25
- {
26
- header: "Age",
27
- accessorKey: "age",
28
- },
29
- {
30
- header: "Phone",
31
- accessorKey: "phone",
32
- },
33
- ];
34
-
35
- const data = [
36
- {
37
- name: "John",
38
- surname: "Coltrane",
39
- age: 30,
40
- phone: "123456789",
41
- },
42
- {
43
- name: "Jane",
44
- surname: "Doe",
45
- age: 25,
46
- phone: "987654321",
47
- },
48
- {
49
- name: "Alice",
50
- surname: "Smith",
51
- age: 35,
52
- phone: "123456789",
53
- },
54
- {
55
- name: "Bob",
56
- surname: "Smith",
57
- age: 40,
58
- phone: "987654321",
59
- },
60
- {
61
- name: "Charlie",
62
- surname: "Brown",
63
- age: 45,
64
- phone: "123456789",
65
- },
66
- {
67
- name: "Daisy",
68
- surname: "Brown",
69
- age: 50,
70
- phone: "987654321",
71
- },
72
- {
73
- name: "Eve",
74
- surname: "Johnson",
75
- age: 55,
76
- phone: "123456789",
77
- },
78
- {
79
- name: "Frank",
80
- surname: "Johnson",
81
- age: 60,
82
- phone: "987654321",
83
- },
84
- {
85
- name: "Grace",
86
- surname: "Williams",
87
- age: 65,
88
- phone: "123456789",
89
- },
90
- {
91
- name: "Henry",
92
- surname: "Williams",
93
- age: 70,
94
- phone: "987654321",
95
- },
96
- {
97
- name: "Ivy",
98
- surname: "Brown",
99
- age: 75,
100
- phone: "123456789",
101
- },
102
- {
103
- name: "Jack",
104
- surname: "Brown",
105
- age: 80,
106
- phone: "987654321",
107
- },
108
- {
109
- name: "Kelly",
110
- surname: "Johnson",
111
- age: 85,
112
- phone: "123456789",
113
- },
114
- {
115
- name: "Liam",
116
- surname: "Johnson",
117
- age: 90,
118
- phone: "987654321",
119
- },
120
- {
121
- name: "Mia",
122
- surname: "Williams",
123
- age: 95,
124
- phone: "123456789",
125
- },
126
- {
127
- name: "Nathan",
128
- surname: "Williams",
129
- age: 100,
130
- phone: "987654321",
131
- },
132
- ];
13
+ ```jsx
14
+ import { columns, data } from "./mockData";
133
15
 
134
16
  <RichTable columns={columns} data={data} withPagination />;
135
17
  ```
@@ -0,0 +1,119 @@
1
+ const columns = [
2
+ {
3
+ header: "Name",
4
+ accessorKey: "name",
5
+ },
6
+ {
7
+ header: "Surname",
8
+ accessorKey: "surname",
9
+ },
10
+ {
11
+ header: "Age",
12
+ accessorKey: "age",
13
+ },
14
+ {
15
+ header: "Phone",
16
+ accessorKey: "phone",
17
+ },
18
+ ];
19
+
20
+ const data = [
21
+ {
22
+ name: "John",
23
+ surname: "Coltrane",
24
+ age: 30,
25
+ phone: "123456789",
26
+ },
27
+ {
28
+ name: "Jane",
29
+ surname: "Doe",
30
+ age: 25,
31
+ phone: "987654321",
32
+ },
33
+ {
34
+ name: "Alice",
35
+ surname: "Smith",
36
+ age: 35,
37
+ phone: "123456789",
38
+ },
39
+ {
40
+ name: "Bob",
41
+ surname: "Smith",
42
+ age: 40,
43
+ phone: "987654321",
44
+ },
45
+ {
46
+ name: "Charlie",
47
+ surname: "Brown",
48
+ age: 45,
49
+ phone: "123456789",
50
+ },
51
+ {
52
+ name: "Daisy",
53
+ surname: "Brown",
54
+ age: 50,
55
+ phone: "987654321",
56
+ },
57
+ {
58
+ name: "Eve",
59
+ surname: "Johnson",
60
+ age: 55,
61
+ phone: "123456789",
62
+ },
63
+ {
64
+ name: "Frank",
65
+ surname: "Johnson",
66
+ age: 60,
67
+ phone: "987654321",
68
+ },
69
+ {
70
+ name: "Grace",
71
+ surname: "Williams",
72
+ age: 65,
73
+ phone: "123456789",
74
+ },
75
+ {
76
+ name: "Henry",
77
+ surname: "Williams",
78
+ age: 70,
79
+ phone: "987654321",
80
+ },
81
+ {
82
+ name: "Ivy",
83
+ surname: "Brown",
84
+ age: 75,
85
+ phone: "123456789",
86
+ },
87
+ {
88
+ name: "Jack",
89
+ surname: "Brown",
90
+ age: 80,
91
+ phone: "987654321",
92
+ },
93
+ {
94
+ name: "Kelly",
95
+ surname: "Johnson",
96
+ age: 85,
97
+ phone: "123456789",
98
+ },
99
+ {
100
+ name: "Liam",
101
+ surname: "Johnson",
102
+ age: 90,
103
+ phone: "987654321",
104
+ },
105
+ {
106
+ name: "Mia",
107
+ surname: "Williams",
108
+ age: 95,
109
+ phone: "123456789",
110
+ },
111
+ {
112
+ name: "Nathan",
113
+ surname: "Williams",
114
+ age: 100,
115
+ phone: "987654321",
116
+ },
117
+ ];
118
+
119
+ export { columns, data };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
2
+ * Copyright (C) 2019-2025 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.
@@ -9,7 +9,7 @@ import React, { useState } from "react";
9
9
 
10
10
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
11
11
  import PropTypes from "prop-types";
12
- import QRCode from "qrcode.react";
12
+ import { QRCodeSVG } from "qrcode.react";
13
13
 
14
14
  import { createAndDownloadPdf, toQRCodeContent } from "./qrCodeHelpers";
15
15
  import Button from "../../bootstrap/Button";
@@ -33,10 +33,7 @@ export default function WiFiQRCode({ SSID, password }) {
33
33
  <button
34
34
  type="button"
35
35
  className="input-group-text"
36
- onClick={(e) => {
37
- e.preventDefault();
38
- setModal(true);
39
- }}
36
+ onClick={() => setModal(true)}
40
37
  >
41
38
  <FontAwesomeIcon
42
39
  icon="fa-solid fa-qrcode"
@@ -45,14 +42,14 @@ export default function WiFiQRCode({ SSID, password }) {
45
42
  className="text-secondary"
46
43
  />
47
44
  </button>
48
- {modal ? (
45
+ {modal && (
49
46
  <QRCodeModal
50
47
  setShown={setModal}
51
48
  shown={modal}
52
49
  SSID={SSID}
53
50
  password={password}
54
51
  />
55
- ) : null}
52
+ )}
56
53
  </>
57
54
  );
58
55
  }
@@ -69,31 +66,30 @@ function QRCodeModal({ shown, setShown, SSID, password }) {
69
66
  <Modal setShown={setShown} shown={shown}>
70
67
  <ModalHeader setShown={setShown} title={_("Wi-Fi QR Code")} />
71
68
  <ModalBody>
72
- <QRCode
69
+ <QRCodeSVG
73
70
  className="d-block mx-auto img-logo-black"
74
- renderAs="svg"
75
71
  value={toQRCodeContent(SSID, password)}
76
72
  level="M"
77
73
  size={350}
78
- includeMargin
74
+ marginSize={0}
75
+ imageSettings={{
76
+ src: "/reforis/static/reforis/imgs/turris.svg",
77
+ height: 40,
78
+ width: 40,
79
+ excavate: true,
80
+ }}
79
81
  />
80
82
  </ModalBody>
81
83
  <ModalFooter>
82
84
  <Button
83
85
  className="btn-secondary"
84
- onClick={(e) => {
85
- e.preventDefault();
86
- setShown(false);
87
- }}
86
+ onClick={() => setShown(false)}
88
87
  >
89
88
  {_("Close")}
90
89
  </Button>
91
90
  <Button
92
91
  className="btn-primary"
93
- onClick={(e) => {
94
- e.preventDefault();
95
- createAndDownloadPdf(SSID, password);
96
- }}
92
+ onClick={() => createAndDownloadPdf(SSID, password)}
97
93
  >
98
94
  <FontAwesomeIcon
99
95
  icon="fa-solid fa-file-download"
Binary file
@@ -6,26 +6,30 @@ comfort API and allows to create typical Foris module forms easily.
6
6
 
7
7
  You can pass more forms as children.
8
8
 
9
- ```js
10
- <ForisForm
11
- ws={ws}
12
- forisConfig={{
13
- endpoint: API_URLs.wan,
14
- wsModule: "wan",
15
- }}
16
- prepData={prepData}
17
- prepDataToSubmit={prepDataToSubmit}
18
- validator={validator}
19
- >
20
- <WANForm />
21
- <WAN6Form />
22
- <MACForm />
23
- </ForisForm>
9
+ ```jsx static
10
+ export default function WAN({ ws }) {
11
+ return (
12
+ <ForisForm
13
+ ws={ws}
14
+ forisConfig={{
15
+ endpoint: API_URLs.wan,
16
+ wsModule: "wan",
17
+ }}
18
+ prepData={prepData}
19
+ prepDataToSubmit={prepDataToSubmit}
20
+ validator={validator}
21
+ >
22
+ <WANForm />
23
+ <WAN6Form />
24
+ <MACForm />
25
+ </ForisForm>
26
+ );
27
+ }
24
28
  ```
25
29
 
26
30
  ### Example of children forms `props` usage
27
31
 
28
- ```js
32
+ ```jsx static
29
33
  export default function MACForm({
30
34
  formData,
31
35
  formErrors,
@@ -64,9 +68,9 @@ export default function MACForm({
64
68
  }
65
69
  ```
66
70
 
67
- The <ForisForm/> passes subsequent `props` to the child components.
71
+ The `<ForisForm/>` passes subsequent `props` to the child components.
68
72
 
69
- | Prop | Type | Description |
73
+ | Prop name | Type | Description |
70
74
  | -------------- | ------ | -------------------------------------------------------------------------- |
71
75
  | `formData` | object | Data returned from API. |
72
76
  | `formErrors` | object | Errors returned after validation via validator. |
@@ -18,8 +18,11 @@ export const STATES = {
18
18
  };
19
19
 
20
20
  SubmitButton.propTypes = {
21
+ /** Disable button */
21
22
  disabled: PropTypes.bool,
23
+ /** Button state */
22
24
  state: PropTypes.oneOf(Object.keys(STATES).map((key) => STATES[key])),
25
+ /** Button label */
23
26
  label: PropTypes.string,
24
27
  };
25
28
 
@@ -34,7 +37,7 @@ export function SubmitButton({ disabled, state, label, ...props }) {
34
37
  labelSubmitButton = _("Updating");
35
38
  break;
36
39
  case STATES.LOAD:
37
- labelSubmitButton = _("Load settings");
40
+ labelSubmitButton = _("Loading");
38
41
  break;
39
42
  default:
40
43
  labelSubmitButton = _("Save");
@@ -0,0 +1,12 @@
1
+ SubmitButton is a component that renders a button with different states based on
2
+ the `state` prop. It can be used to indicate the status of a form submission.
3
+
4
+ ```jsx padded
5
+ <SubmitButton state={1} />
6
+
7
+ <SubmitButton state={2} />
8
+
9
+ <SubmitButton state={3} />
10
+
11
+ <SubmitButton label="Submitting" state={2} />
12
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foris",
3
- "version": "6.7.1",
3
+ "version": "6.7.2-beta.9da7bf6b",
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": {
@@ -62,6 +62,9 @@
62
62
  "style-loader": "^4.0.0",
63
63
  "webpack": "^5.98.0"
64
64
  },
65
+ "overrides": {
66
+ "markdown-to-jsx": "^7.7.4"
67
+ },
65
68
  "scripts": {
66
69
  "lint": "eslint src",
67
70
  "lint:fix": "eslint --fix src",
@@ -71,4 +74,4 @@
71
74
  "docs": "npx styleguidist build ",
72
75
  "docs:watch": "styleguidist server"
73
76
  }
74
- }
77
+ }
package/foris-6.7.1.tgz DELETED
Binary file