1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-12-26 00:21:36 +01:00

Merge branch 'dev' into 'master'

Add "inline" option to RadioSet

See merge request turris/reforis/foris-js!124
This commit is contained in:
Aleksandr Gumroian 2020-08-31 18:24:42 +02:00
commit ad99a2034d
7 changed files with 78 additions and 61 deletions

92
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "5.1.0",
"version": "5.1.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -5906,9 +5906,9 @@
"dev": true
},
"copy-webpack-plugin": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-5.1.1.tgz",
"integrity": "sha512-P15M5ZC8dyCjQHWwd4Ia/dm0SgVvZJMYeykVIVYXbGyqO4dWB5oyPHp9i7wjwo5LhtlhKbiBCdS2NvM07Wlybg==",
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-5.1.2.tgz",
"integrity": "sha512-Uh7crJAco3AjBvgAy9Z75CjK8IG+gxaErro71THQ+vv/bl4HaQcpkexAY8KVW/T6D2W2IRr+couF/knIRkZMIQ==",
"dev": true,
"requires": {
"cacache": "^12.0.3",
@ -5921,7 +5921,7 @@
"normalize-path": "^3.0.0",
"p-limit": "^2.2.1",
"schema-utils": "^1.0.0",
"serialize-javascript": "^2.1.2",
"serialize-javascript": "^4.0.0",
"webpack-log": "^2.0.0"
},
"dependencies": {
@ -5962,6 +5962,15 @@
"ajv-keywords": "^3.1.0"
}
},
"serialize-javascript": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
"integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"dev": true,
"requires": {
"randombytes": "^2.1.0"
}
},
"slash": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",
@ -15717,12 +15726,6 @@
}
}
},
"serialize-javascript": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz",
"integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==",
"dev": true
},
"serve-index": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz",
@ -16879,25 +16882,6 @@
"supports-hyperlinks": "^2.0.0"
}
},
"terser": {
"version": "4.6.7",
"resolved": "https://registry.npmjs.org/terser/-/terser-4.6.7.tgz",
"integrity": "sha512-fmr7M1f7DBly5cX2+rFDvmGBAaaZyPrHYK4mMdHEDAdNTqXSZgSOfqsfGq2HqPGT/1V0foZZuCZFx8CHKgAk3g==",
"dev": true,
"requires": {
"commander": "^2.20.0",
"source-map": "~0.6.1",
"source-map-support": "~0.5.12"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
},
"terser-webpack-plugin": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz",
@ -18108,20 +18092,51 @@
"dev": true
},
"terser-webpack-plugin": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz",
"integrity": "sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA==",
"version": "1.4.5",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.5.tgz",
"integrity": "sha512-04Rfe496lN8EYruwi6oPQkG0vo8C+HT49X687FZnpPF0qMAIHONI6HEXYPKDOE8e5HjXTyKfqRd/agHtH0kOtw==",
"dev": true,
"requires": {
"cacache": "^12.0.2",
"find-cache-dir": "^2.1.0",
"is-wsl": "^1.1.0",
"schema-utils": "^1.0.0",
"serialize-javascript": "^2.1.2",
"serialize-javascript": "^4.0.0",
"source-map": "^0.6.1",
"terser": "^4.1.2",
"webpack-sources": "^1.4.0",
"worker-farm": "^1.7.0"
},
"dependencies": {
"serialize-javascript": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
"integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"dev": true,
"requires": {
"randombytes": "^2.1.0"
}
},
"terser": {
"version": "4.8.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz",
"integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==",
"dev": true,
"requires": {
"commander": "^2.20.0",
"source-map": "~0.6.1",
"source-map-support": "~0.5.12"
}
},
"worker-farm": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz",
"integrity": "sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw==",
"dev": true,
"requires": {
"errno": "~0.1.7"
}
}
}
}
}
@ -18483,15 +18498,6 @@
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"dev": true
},
"worker-farm": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz",
"integrity": "sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw==",
"dev": true,
"requires": {
"errno": "~0.1.7"
}
},
"worker-rpc": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/worker-rpc/-/worker-rpc-0.1.1.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "5.1.0",
"version": "5.1.1",
"description": "Set of components and utils for Foris and its plugins.",
"author": "CZ.NIC, z.s.p.o.",
"repository": {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
@ -33,9 +33,18 @@ RadioSet.propTypes = {
value: PropTypes.string,
/** Help text message . */
helpText: PropTypes.string,
inline: PropTypes.bool,
};
export function RadioSet({ name, label, choices, value, helpText, ...props }) {
export function RadioSet({
name,
label,
choices,
value,
helpText,
inline,
...props
}) {
const uid = useUID();
const radios = choices.map((choice, key) => {
const id = `${name}-${key}`;
@ -48,6 +57,7 @@ export function RadioSet({ name, label, choices, value, helpText, ...props }) {
value={choice.value}
helpText={choice.helpText}
checked={choice.value === value}
inline={inline}
{...props}
/>
);
@ -76,15 +86,16 @@ Radio.propTypes = {
PropTypes.arrayOf(PropTypes.node),
]).isRequired,
id: PropTypes.string.isRequired,
inline: PropTypes.bool,
helpText: PropTypes.string,
};
export function Radio({ label, id, helpText, ...props }) {
export function Radio({ label, id, helpText, inline, ...props }) {
return (
<>
<div
className={`custom-control custom-radio ${
!helpText ? "custom-control-inline" : ""
inline ? "custom-control-inline" : ""
}`.trim()}
>
<input

View File

@ -23,7 +23,7 @@ Switch.propTypes = {
export function Switch({ label, helpText, switchHeading, ...props }) {
const uid = useUID();
return (
<div className="form-group">
<div className="form-group switch">
<div
className={`custom-control custom-switch ${
!helpText ? "custom-control-inline" : ""

View File

@ -11,7 +11,7 @@ exports[`<RadioSet/> Render radio set 1`] = `
Radios set label
</label>
<div
class="custom-control custom-radio custom-control-inline"
class="custom-control custom-radio"
>
<input
checked=""
@ -29,7 +29,7 @@ exports[`<RadioSet/> Render radio set 1`] = `
</label>
</div>
<div
class="custom-control custom-radio custom-control-inline"
class="custom-control custom-radio"
>
<input
class="custom-control-input"
@ -46,7 +46,7 @@ exports[`<RadioSet/> Render radio set 1`] = `
</label>
</div>
<div
class="custom-control custom-radio custom-control-inline"
class="custom-control custom-radio"
>
<input
class="custom-control-input"

View File

@ -2,7 +2,7 @@
exports[`<Switch/> Render switch 1`] = `
<div
class="form-group"
class="form-group switch"
>
<div
class="custom-control custom-switch"
@ -30,7 +30,7 @@ exports[`<Switch/> Render switch 1`] = `
exports[`<Switch/> Render uncheked switch 1`] = `
<div
class="form-group"
class="form-group switch"
>
<div
class="custom-control custom-switch"

View File

@ -255,7 +255,7 @@ exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = `
>
<form>
<div
class="form-group"
class="form-group switch"
>
<div
class="custom-control custom-switch custom-control-inline switch-heading"
@ -277,7 +277,7 @@ exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = `
</div>
<hr />
<div
class="form-group"
class="form-group switch"
>
<div
class="custom-control custom-switch custom-control-inline switch-heading"
@ -423,7 +423,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
+ </div>
<hr />
<div
class=\\"form-group\\"
class=\\"form-group switch\\"
>
<div
@@ -501,10 +580,11 @@
@ -560,7 +560,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ GHz
+ </label>
+ <div
+ class=\\"custom-control custom-radio custom-control-inline\\"
+ class=\\"custom-control custom-radio\\"
+ >
+ <input
+ class=\\"custom-control-input\\"
@ -577,7 +577,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </label>
+ </div>
+ <div
+ class=\\"custom-control custom-radio custom-control-inline\\"
+ class=\\"custom-control custom-radio\\"
+ >
+ <input
+ checked=\\"\\"
@ -876,7 +876,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </select>
+ </div>
+ <div
+ class=\\"form-group\\"
+ class=\\"form-group switch\\"
+ >
+ <div
+ class=\\"custom-control custom-switch\\"
@ -905,7 +905,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </div>
<hr />
<div
class=\\"form-group\\"
class=\\"form-group switch\\"
>
<div"
`;