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 inputClassName = `form-control ${className || ""} ${
const inputClassName = `${className || ""} ${
error ? "is-invalid" : ""
}`.trim();
return (
<div className="mb-3">
<label
className={`form-label ${labelClassName}`.trim()}
className={`form-label ${labelClassName || ""}`.trim()}
htmlFor={uid}
>
{label}

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ Spinner.propTypes = {
PropTypes.arrayOf(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,
className: PropTypes.string,
};

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,8 @@
* 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. */
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;
}