1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-11-14 17:35:35 +01:00

fixup! Update Bootstrap library to version 5.3.x

This commit is contained in:
Aleksandr Gumroian 2024-04-23 15:24:50 +02:00
parent c008d7bcc7
commit 6bd809222c
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733
11 changed files with 75 additions and 63 deletions

View File

@ -27,14 +27,14 @@ export const Input = forwardRef(
) => { ) => {
const uid = useUID(); const uid = useUID();
const inputClassName = `form-control ${className || ""} ${ const inputClassName = `${className || ""} ${
error ? "is-invalid" : "" error ? "is-invalid" : ""
}`.trim(); }`.trim();
return ( return (
<div className="mb-3"> <div className="mb-3">
<label <label
className={`form-label ${labelClassName}`.trim()} className={`form-label ${labelClassName || ""}`.trim()}
htmlFor={uid} htmlFor={uid}
> >
{label} {label}

View File

@ -92,11 +92,10 @@ export function ModalHeader({ setShown, title }) {
<h5 className="modal-title">{title}</h5> <h5 className="modal-title">{title}</h5>
<button <button
type="button" type="button"
className="close" className="btn-close"
onClick={() => setShown(false)} onClick={() => setShown(false)}
> aria-label={_("Close")}
<span aria-hidden="true">&times;</span> />
</button>
</div> </div>
); );
} }

View File

@ -23,7 +23,7 @@ NumberInput.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/** Function called when value changes. */ /** Function called when value changes. */
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
/** Additional description dispaled to the right of input value. */ /** Additional description displayed to the right of input value. */
inlineText: PropTypes.string, inlineText: PropTypes.string,
}; };
@ -49,8 +49,9 @@ export function NumberInput({ onChange, inlineText, value, ...props }) {
return ( return (
<Input type="number" onChange={onChange} value={value} {...props}> <Input type="number" onChange={onChange} value={value} {...props}>
<div className="input-group-append"> {inlineText && (
{inlineText && <p className="input-group-text">{inlineText}</p>} <span className="input-group-text">{inlineText}</span>
)}
<button <button
type="button" type="button"
className="btn btn-outline-secondary" className="btn btn-outline-secondary"
@ -69,7 +70,6 @@ export function NumberInput({ onChange, inlineText, value, ...props }) {
> >
<i className="fas fa-minus" /> <i className="fas fa-minus" />
</button> </button>
</div>
</Input> </Input>
); );
} }

View File

@ -34,8 +34,7 @@ export function PasswordInput({ withEye, newPass, ...props }) {
autoComplete={newPass ? "new-password" : "current-password"} autoComplete={newPass ? "new-password" : "current-password"}
{...props} {...props}
> >
{withEye ? ( {withEye && (
<div className="input-group-append">
<button <button
type="button" type="button"
className="input-group-text" className="input-group-text"
@ -45,13 +44,10 @@ export function PasswordInput({ withEye, newPass, ...props }) {
}} }}
> >
<i <i
className={`fa ${ className={`fa ${isHidden ? "fa-eye" : "fa-eye-slash"}`}
isHidden ? "fa-eye" : "fa-eye-slash"
}`}
/> />
</button> </button>
</div> )}
) : null}
</Input> </Input>
); );
} }

View File

@ -96,24 +96,24 @@ export function Radio({ label, id, helpText, inline, ...props }) {
return ( return (
<> <>
<div <div
className={`${ className={`mb-2 ${
inline ? "form-check form-check-inline" : "" inline ? "form-check form-check-inline" : ""
}`.trim()} }`.trim()}
> >
<input <input
id={id} id={id}
className="form-check-input" className="form-check-input me-2"
type="radio" type="radio"
{...props} {...props}
/> />
<label className="form-check-label" htmlFor={id}> <label className="form-check-label" htmlFor={id}>
{label} {label}
</label>
{helpText && ( {helpText && (
<div className="form-text"> <div className="form-text">
<small>{helpText}</small> <small>{helpText}</small>
</div> </div>
)} )}
</label>
</div> </div>
</> </>
); );

View File

@ -16,7 +16,7 @@ Spinner.propTypes = {
PropTypes.arrayOf(PropTypes.node), PropTypes.arrayOf(PropTypes.node),
PropTypes.node, PropTypes.node,
]), ]),
/** Render component with full-screen mode (using apropriate `.css` styles) */ /** Render component with full-screen mode (using appropriate `.css` styles) */
fullScreen: PropTypes.bool.isRequired, fullScreen: PropTypes.bool.isRequired,
className: PropTypes.string, className: PropTypes.string,
}; };

0
src/bootstrap/Tooltip.js Normal file
View File

View File

@ -119,12 +119,10 @@ function DeviceForm({
}))} }))}
{...props} {...props}
> >
<div className="input-group-append">
<WiFiQRCode <WiFiQRCode
SSID={formData.SSID} SSID={formData.SSID}
password={formData.password} password={formData.password}
/> />
</div>
</TextInput> </TextInput>
<PasswordInput <PasswordInput

View File

@ -87,7 +87,7 @@ function QRCodeModal({ shown, setShown, SSID, password }) {
createAndDownloadPdf(SSID, password); createAndDownloadPdf(SSID, password);
}} }}
> >
<i className="fas fa-arrow-down me-2" /> <i className="fas fa-file-download me-2" />
{_("Download PDF")} {_("Download PDF")}
</Button> </Button>
</ModalFooter> </ModalFooter>

View File

@ -69,7 +69,7 @@ export {
withErrorMessage, withErrorMessage,
} from "./utils/conditionalHOCs"; } from "./utils/conditionalHOCs";
export { ErrorMessage } from "./utils/ErrorMessage"; export { ErrorMessage } from "./utils/ErrorMessage";
export { useClickOutside } from "./utils/hooks"; export { useClickOutside, useTooltip } from "./utils/hooks";
export { toLocaleDateString } from "./utils/datetime"; export { toLocaleDateString } from "./utils/datetime";
export { displayCard } from "./utils/displayCard"; export { displayCard } from "./utils/displayCard";
export { isPluginInstalled } from "./utils/isPluginInstalled"; export { isPluginInstalled } from "./utils/isPluginInstalled";

View File

@ -5,7 +5,8 @@
* See /LICENSE for more information. * See /LICENSE for more information.
*/ */
import { useState, useEffect } from "react"; import { useState, useEffect, useRef } from "react";
import { Tooltip } from "bootstrap/dist/js/bootstrap.bundle.min.js";
/** Execute callback when condition is set to true. */ /** Execute callback when condition is set to true. */
export function useConditionalTimeout( export function useConditionalTimeout(
@ -40,3 +41,21 @@ export function useClickOutside(element, callback) {
}; };
}); });
} }
export function useTooltip(description, placement = "top", trigger = "hover") {
const tooltipRef = useRef();
useEffect(() => {
const tooltip = new Tooltip(tooltipRef.current, {
title: description,
placement: placement,
trigger: trigger,
});
return () => {
tooltip.dispose();
};
});
return tooltipRef;
}