deps: react-bootstrap 0.31 -> 2 (Bootstrap 5 CSS deferred as debt)

Removes the largest batch of React-19-blocking warnings: the 0.31
components (Grid, FormGroup, ControlLabel, Navbar.Header/Brand, Checkbox,
SafeAnchor) all leaned on legacy context / defaultProps.

29 files converted: Grid->Container, FormGroup/ControlLabel/FormControl/
HelpBlock -> Form.Group/Label/Control/Text, Checkbox -> Form.Check (label
as prop), bsStyle->variant (default->secondary), bsSize->size,
pull-right->float-end. Custom Col.js now re-exports v2's Col; custom
NavItem.js rewritten self-contained (no SafeAnchor/createChainedFunction);
Navigation.js drops react-bootstrap Navbar (raw markup anyway).

CSS stays on Bootstrap 4 (alexwine:bootstrap-4) for now: the BS4->5 jump
is entangled with the jQuery carousel/swipe + navbar-collapse and is
tracked as separate debt in UPGRADE.md. Only .form-label needed a shim
(forms.scss). Browser-verified home carousel+navbar, signup form + terms
checkbox, login form; REST smoke byte-identical.
This commit is contained in:
vjrj 2026-07-21 12:44:46 +02:00
parent 12bdbe8fed
commit a1a1b9a801
30 changed files with 539 additions and 333 deletions

View file

@ -2,9 +2,9 @@ import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { SafeAnchor } from 'react-bootstrap';
import createChainedFunction from 'react-bootstrap/lib/utils/createChainedFunction';
// Self-contained NavItem. The old one wrapped react-bootstrap 0.31's
// `SafeAnchor` + `createChainedFunction` (both gone in v2); the markup this
// navbar needs is just an <li><a> that toggles the collapsed menu on click.
const propTypes = {
active: PropTypes.bool,
disabled: PropTypes.bool,
@ -12,7 +12,11 @@ const propTypes = {
href: PropTypes.string,
onClick: PropTypes.func,
onSelect: PropTypes.func,
eventKey: PropTypes.any
eventKey: PropTypes.any,
className: PropTypes.string,
anchorClassName: PropTypes.string,
style: PropTypes.object,
children: PropTypes.node
};
const defaultProps = {
@ -21,42 +25,35 @@ const defaultProps = {
};
class NavItem extends React.Component {
constructor(props, context) {
super(props, context);
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
if (this.props.onSelect) {
const { disabled, onClick, onSelect, eventKey } = this.props;
if (disabled) {
e.preventDefault();
if (!this.props.disabled) {
this.props.onSelect(this.props.eventKey, e);
}
return;
}
if (onClick) onClick(e);
if (onSelect) {
e.preventDefault();
onSelect(eventKey, e);
}
}
render() {
const {
active, disabled, onClick, className, anchorClassName, style, ...props
} =
this.props;
active, disabled, role, href, onClick, onSelect, eventKey,
className, anchorClassName, style, children, ...props
} = this.props;
delete props.onSelect;
delete props.eventKey;
const anchorProps = { ...props };
if (href) anchorProps.href = href;
anchorProps.role = role || (href === '#' ? 'button' : undefined);
if (role === 'tab') anchorProps['aria-selected'] = active;
// These are injected down by `<Nav>` for building `<SubNav>`s.
delete props.activeKey;
delete props.activeHref;
if (!props.role) {
if (props.href === '#') {
props.role = 'button';
}
} else if (props.role === 'tab') {
props['aria-selected'] = active;
}
return (
<li
role="presentation"
@ -65,12 +62,14 @@ class NavItem extends React.Component {
className={classNames(className, { active, disabled })}
style={style}
>
<SafeAnchor
{...props}
disabled={disabled}
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a
{...anchorProps}
className={anchorClassName}
onClick={createChainedFunction(onClick, this.handleClick)}
/>
onClick={this.handleClick}
>
{children}
</a>
</li>
);
}