mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-15 13:36:35 +02:00
Fix linting issues
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
export const ALERT_TYPES = Object.freeze({
|
||||
@ -35,7 +36,7 @@ Alert.defaultProps = {
|
||||
type: ALERT_TYPES.DANGER,
|
||||
};
|
||||
|
||||
export function Alert({ type, onDismiss, children }) {
|
||||
function Alert({ type, onDismiss, children }) {
|
||||
return (
|
||||
<div
|
||||
className={`alert alert-${type} ${
|
||||
@ -54,3 +55,5 @@ export function Alert({ type, onDismiss, children }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Alert;
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2023 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
Button.propTypes = {
|
||||
@ -24,13 +25,7 @@ Button.propTypes = {
|
||||
]).isRequired,
|
||||
};
|
||||
|
||||
export function Button({
|
||||
className,
|
||||
loading,
|
||||
forisFormSize,
|
||||
children,
|
||||
...props
|
||||
}) {
|
||||
function Button({ className, loading, forisFormSize, children, ...props }) {
|
||||
let buttonClass = className ? `btn ${className}` : "btn btn-primary";
|
||||
if (forisFormSize) {
|
||||
buttonClass = `${buttonClass} col-12 col-md-3 col-lg-2`;
|
||||
@ -53,3 +48,5 @@ export function Button({
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default Button;
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import { useUID } from "react-uid";
|
||||
|
||||
@ -22,7 +23,7 @@ CheckBox.defaultProps = {
|
||||
disabled: false,
|
||||
};
|
||||
|
||||
export function CheckBox({ label, helpText, disabled, ...props }) {
|
||||
function CheckBox({ label, helpText, disabled, ...props }) {
|
||||
const uid = useUID();
|
||||
|
||||
return (
|
||||
@ -45,3 +46,5 @@ export function CheckBox({ label, helpText, disabled, ...props }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default CheckBox;
|
||||
|
@ -1,13 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React, { useState, useRef } from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import { Input } from "./Input";
|
||||
|
||||
import Input from "./Input";
|
||||
|
||||
CopyInput.propTypes = {
|
||||
/** Field label. */
|
||||
@ -22,7 +24,7 @@ CopyInput.propTypes = {
|
||||
readOnly: PropTypes.bool,
|
||||
};
|
||||
|
||||
export function CopyInput({ value, ...props }) {
|
||||
function CopyInput({ value, ...props }) {
|
||||
const inputTextRef = useRef();
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
|
||||
@ -58,3 +60,5 @@ export function CopyInput({ value, ...props }) {
|
||||
</Input>
|
||||
);
|
||||
}
|
||||
|
||||
export default CopyInput;
|
||||
|
@ -1,18 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import moment from "moment/moment";
|
||||
import PropTypes from "prop-types";
|
||||
import Datetime from "react-datetime";
|
||||
import moment from "moment/moment";
|
||||
import "react-datetime/css/react-datetime.css";
|
||||
import "./DataTimeInput.css";
|
||||
|
||||
import { Input } from "./Input";
|
||||
import Input from "./Input";
|
||||
|
||||
DataTimeInput.propTypes = {
|
||||
/** Field label. */
|
||||
@ -37,7 +38,7 @@ DataTimeInput.propTypes = {
|
||||
const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
||||
const DEFAULT_TIME_FORMAT = "HH:mm:ss";
|
||||
|
||||
export function DataTimeInput({
|
||||
function DataTimeInput({
|
||||
value,
|
||||
onChange,
|
||||
isValidDate,
|
||||
@ -46,13 +47,13 @@ export function DataTimeInput({
|
||||
children,
|
||||
...props
|
||||
}) {
|
||||
function renderInput(datetimeProps) {
|
||||
const renderInput = (datetimeProps) => {
|
||||
return (
|
||||
<Input {...props} {...datetimeProps}>
|
||||
{children}
|
||||
</Input>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Datetime
|
||||
@ -70,3 +71,5 @@ export function DataTimeInput({
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default DataTimeInput;
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
DownloadButton.propTypes = {
|
||||
@ -21,7 +22,7 @@ DownloadButton.defaultProps = {
|
||||
className: "btn-primary",
|
||||
};
|
||||
|
||||
export function DownloadButton({ href, className, children, ...props }) {
|
||||
function DownloadButton({ href, className, children, ...props }) {
|
||||
return (
|
||||
<a
|
||||
href={href}
|
||||
@ -33,3 +34,5 @@ export function DownloadButton({ href, className, children, ...props }) {
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
export default DownloadButton;
|
||||
|
@ -6,11 +6,14 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { Input } from "./Input";
|
||||
import Input from "./Input";
|
||||
|
||||
export const EmailInput = ({ ...props }) => <Input type="email" {...props} />;
|
||||
function EmailInput({ ...props }) {
|
||||
return <Input type="email" {...props} />;
|
||||
}
|
||||
|
||||
EmailInput.propTypes = {
|
||||
/** Field label. */
|
||||
@ -22,3 +25,5 @@ EmailInput.propTypes = {
|
||||
/** Email value. */
|
||||
value: PropTypes.string,
|
||||
};
|
||||
|
||||
export default EmailInput;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
@ -8,7 +8,8 @@
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import { Input } from "./Input";
|
||||
|
||||
import Input from "./Input";
|
||||
|
||||
FileInput.propTypes = {
|
||||
/** Field label. */
|
||||
@ -23,7 +24,7 @@ FileInput.propTypes = {
|
||||
multiple: PropTypes.bool,
|
||||
};
|
||||
|
||||
export function FileInput({ ...props }) {
|
||||
function FileInput({ ...props }) {
|
||||
return (
|
||||
<Input
|
||||
type="file"
|
||||
@ -34,3 +35,5 @@ export function FileInput({ ...props }) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default FileInput;
|
||||
|
@ -6,11 +6,12 @@
|
||||
*/
|
||||
|
||||
import React, { forwardRef } from "react";
|
||||
import { useUID } from "react-uid";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import { useUID } from "react-uid";
|
||||
|
||||
/** Base bootstrap input component. */
|
||||
export const Input = forwardRef(
|
||||
const Input = forwardRef(
|
||||
(
|
||||
{
|
||||
type,
|
||||
@ -60,6 +61,8 @@ export const Input = forwardRef(
|
||||
}
|
||||
);
|
||||
|
||||
Input.displayName = "Input";
|
||||
|
||||
Input.propTypes = {
|
||||
type: PropTypes.string.isRequired,
|
||||
label: PropTypes.string.isRequired,
|
||||
@ -73,3 +76,5 @@ Input.propTypes = {
|
||||
labelClassName: PropTypes.string,
|
||||
groupClassName: PropTypes.string,
|
||||
};
|
||||
|
||||
export default Input;
|
||||
|
@ -1,15 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2020-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React, { useRef, useEffect } from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { Portal } from "../utils/Portal";
|
||||
import { useClickOutside } from "../utils/hooks";
|
||||
import Portal from "../utils/Portal";
|
||||
import "./Modal.css";
|
||||
|
||||
Modal.propTypes = {
|
||||
|
@ -1,15 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Input from "./Input";
|
||||
import { useConditionalTimeout } from "../utils/hooks";
|
||||
import { Input } from "./Input";
|
||||
import "./NumberInput.css";
|
||||
|
||||
NumberInput.propTypes = {
|
||||
@ -31,7 +32,7 @@ NumberInput.defaultProps = {
|
||||
value: 0,
|
||||
};
|
||||
|
||||
export function NumberInput({ onChange, inlineText, value, ...props }) {
|
||||
function NumberInput({ onChange, inlineText, value, ...props }) {
|
||||
function updateValue(initialValue, difference) {
|
||||
onChange({ target: { value: initialValue + difference } });
|
||||
}
|
||||
@ -73,3 +74,5 @@ export function NumberInput({ onChange, inlineText, value, ...props }) {
|
||||
</Input>
|
||||
);
|
||||
}
|
||||
|
||||
export default NumberInput;
|
||||
|
@ -1,14 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React, { useState } from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { Input } from "./Input";
|
||||
import Input from "./Input";
|
||||
|
||||
PasswordInput.propTypes = {
|
||||
/** Field label. */
|
||||
@ -25,7 +26,7 @@ PasswordInput.propTypes = {
|
||||
newPass: PropTypes.bool,
|
||||
};
|
||||
|
||||
export function PasswordInput({ withEye, newPass, ...props }) {
|
||||
function PasswordInput({ withEye, newPass, ...props }) {
|
||||
const [isHidden, setHidden] = useState(true);
|
||||
|
||||
return (
|
||||
@ -51,3 +52,5 @@ export function PasswordInput({ withEye, newPass, ...props }) {
|
||||
</Input>
|
||||
);
|
||||
}
|
||||
|
||||
export default PasswordInput;
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2020-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import { useUID } from "react-uid";
|
||||
|
||||
@ -36,15 +37,7 @@ RadioSet.propTypes = {
|
||||
inline: PropTypes.bool,
|
||||
};
|
||||
|
||||
export function RadioSet({
|
||||
name,
|
||||
label,
|
||||
choices,
|
||||
value,
|
||||
helpText,
|
||||
inline,
|
||||
...props
|
||||
}) {
|
||||
function RadioSet({ name, label, choices, value, helpText, inline, ...props }) {
|
||||
const uid = useUID();
|
||||
const radios = choices.map((choice, key) => {
|
||||
const id = `${name}-${key}`;
|
||||
@ -94,27 +87,25 @@ Radio.propTypes = {
|
||||
|
||||
export function Radio({ label, id, helpText, inline, ...props }) {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={`mb-2 ${
|
||||
inline ? "form-check form-check-inline" : ""
|
||||
}`.trim()}
|
||||
>
|
||||
<input
|
||||
id={id}
|
||||
className="form-check-input me-2"
|
||||
type="radio"
|
||||
{...props}
|
||||
/>
|
||||
<label className="form-check-label" htmlFor={id}>
|
||||
{label}
|
||||
{helpText && (
|
||||
<div className="form-text">
|
||||
<small>{helpText}</small>
|
||||
</div>
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
</>
|
||||
<div
|
||||
className={`mb-2 ${inline ? "form-check form-check-inline" : ""}`.trim()}
|
||||
>
|
||||
<input
|
||||
id={id}
|
||||
className="form-check-input me-2"
|
||||
type="radio"
|
||||
{...props}
|
||||
/>
|
||||
<label className="form-check-label" htmlFor={id}>
|
||||
{label}
|
||||
{helpText && (
|
||||
<div className="form-text">
|
||||
<small>{helpText}</small>
|
||||
</div>
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default RadioSet;
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import { useUID } from "react-uid";
|
||||
|
||||
@ -20,7 +21,7 @@ Select.propTypes = {
|
||||
helpText: PropTypes.string,
|
||||
};
|
||||
|
||||
export function Select({ label, choices, helpText, ...props }) {
|
||||
function Select({ label, choices, helpText, ...props }) {
|
||||
const uid = useUID();
|
||||
|
||||
const options = Object.keys(choices).map((choice) => (
|
||||
@ -45,3 +46,5 @@ export function Select({ label, choices, helpText, ...props }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Select;
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import "./Spinner.css";
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (c) 2020-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import { useUID } from "react-uid";
|
||||
|
||||
@ -20,7 +21,7 @@ Switch.propTypes = {
|
||||
switchHeading: PropTypes.bool,
|
||||
};
|
||||
|
||||
export function Switch({ label, helpText, switchHeading, ...props }) {
|
||||
function Switch({ label, helpText, switchHeading, ...props }) {
|
||||
const uid = useUID();
|
||||
|
||||
return (
|
||||
@ -31,9 +32,7 @@ export function Switch({ label, helpText, switchHeading, ...props }) {
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
className={`form-check-input ${
|
||||
switchHeading ? "me-2" : ""
|
||||
}`.trim()}
|
||||
className={`form-check-input ${switchHeading ? "me-2" : ""}`.trim()}
|
||||
role="switch"
|
||||
id={uid}
|
||||
{...props}
|
||||
@ -49,3 +48,5 @@ export function Switch({ label, helpText, switchHeading, ...props }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Switch;
|
||||
|
@ -1,16 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { Input } from "./Input";
|
||||
import Input from "./Input";
|
||||
|
||||
export const TextInput = ({ ...props }) => <Input type="text" {...props} />;
|
||||
function TextInput({ ...props }) {
|
||||
return <Input type="text" {...props} />;
|
||||
}
|
||||
|
||||
TextInput.propTypes = {
|
||||
/** Field label. */
|
||||
@ -20,3 +23,5 @@ TextInput.propTypes = {
|
||||
/** Help text message. */
|
||||
helpText: PropTypes.string,
|
||||
};
|
||||
|
||||
export default TextInput;
|
||||
|
@ -9,7 +9,7 @@ import React from "react";
|
||||
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import { Button } from "../Button";
|
||||
import Button from "../Button";
|
||||
|
||||
describe("<Button />", () => {
|
||||
it("Render button correctly", () => {
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
/** Bootstrap column size for form fields */
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const formFieldsSize = "card p-4 col-sm-12 col-lg-12 p-0 mb-4";
|
||||
export const buttonFormFieldsSize = "col-sm-12 col-lg-12 p-0 mb-3";
|
||||
const formFieldsSize = "card p-4 col-sm-12 col-lg-12 p-0 mb-4";
|
||||
const buttonFormFieldsSize = "col-sm-12 col-lg-12 p-0 mb-3";
|
||||
|
||||
export { formFieldsSize, buttonFormFieldsSize };
|
||||
|
Reference in New Issue
Block a user