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:
parent
c008d7bcc7
commit
6bd809222c
|
@ -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}
|
||||||
|
|
|
@ -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">×</span>
|
/>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,27 +49,27 @@ 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
|
)}
|
||||||
type="button"
|
<button
|
||||||
className="btn btn-outline-secondary"
|
type="button"
|
||||||
onMouseDown={() => enableIncrease(true)}
|
className="btn btn-outline-secondary"
|
||||||
onMouseUp={() => enableIncrease(false)}
|
onMouseDown={() => enableIncrease(true)}
|
||||||
aria-label="Increase"
|
onMouseUp={() => enableIncrease(false)}
|
||||||
>
|
aria-label="Increase"
|
||||||
<i className="fas fa-plus" />
|
>
|
||||||
</button>
|
<i className="fas fa-plus" />
|
||||||
<button
|
</button>
|
||||||
type="button"
|
<button
|
||||||
className="btn btn-outline-secondary"
|
type="button"
|
||||||
onMouseDown={() => enableDecrease(true)}
|
className="btn btn-outline-secondary"
|
||||||
onMouseUp={() => enableDecrease(false)}
|
onMouseDown={() => enableDecrease(true)}
|
||||||
aria-label="Decrease"
|
onMouseUp={() => enableDecrease(false)}
|
||||||
>
|
aria-label="Decrease"
|
||||||
<i className="fas fa-minus" />
|
>
|
||||||
</button>
|
<i className="fas fa-minus" />
|
||||||
</div>
|
</button>
|
||||||
</Input>
|
</Input>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,24 +34,20 @@ 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"
|
onClick={(e) => {
|
||||||
onClick={(e) => {
|
e.preventDefault();
|
||||||
e.preventDefault();
|
setHidden((shouldBeHidden) => !shouldBeHidden);
|
||||||
setHidden((shouldBeHidden) => !shouldBeHidden);
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<i
|
||||||
<i
|
className={`fa ${isHidden ? "fa-eye" : "fa-eye-slash"}`}
|
||||||
className={`fa ${
|
/>
|
||||||
isHidden ? "fa-eye" : "fa-eye-slash"
|
</button>
|
||||||
}`}
|
)}
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</Input>
|
</Input>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}
|
||||||
|
{helpText && (
|
||||||
|
<div className="form-text">
|
||||||
|
<small>{helpText}</small>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</label>
|
</label>
|
||||||
{helpText && (
|
|
||||||
<div className="form-text">
|
|
||||||
<small>{helpText}</small>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -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
0
src/bootstrap/Tooltip.js
Normal 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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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";
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user