mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* React 19 upgrade Bumps react and react-dom to 19.2.8, with the dependency changes React 19 requires: react-is 19, @types/react 19, @types/react-dom 19, react-helmet-async 3 and react-avatar-editor 15 (which now ships its own types). framer-motion moves to 13 — its v6 types reference React.ReactHTML, removed from @types/react 19. The type changes fall into a few classes: - The global JSX namespace is gone, so JSX.Element becomes React.JSX.Element and the custom element declarations move into a module augmentation. - useRef() now requires an initial value. - A ref created with a null initial value is typed nullable, so consumers that accept one are widened to RefObject<T | null>. - React.ReactChild was removed; tooltips take React.ReactNode. - Ref callbacks may only return a cleanup function. react-dnd connectors return the connected node, so useDragRef and useDropRef wrap useDrag and useDrop and hand back a ref callback. react-i18next stays on v12: i18next 23 drops compatibilityJSON "v3", which would rewrite all 64 _plural keys across every locale. outline-icons, oy-vey and react-waypoint have no release that lists React 19 as a peer. All three render correctly under it; the install reports them as unmet peers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Remove react-helmet and forwardRef --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
76 lines
1.9 KiB
TypeScript
76 lines
1.9 KiB
TypeScript
import * as OneTimePasswordField from "@radix-ui/react-one-time-password-field";
|
|
import * as React from "react";
|
|
import styled from "styled-components";
|
|
import { s } from "@shared/styles";
|
|
|
|
type Props = React.ComponentPropsWithoutRef<typeof OneTimePasswordRoot> & {
|
|
/** The length of the OTP */
|
|
length?: number;
|
|
ref?: React.Ref<HTMLInputElement>;
|
|
/**
|
|
* Whether to accept uppercase letters in addition to digits. Lowercase input
|
|
* is normalized to uppercase. Defaults to numeric only.
|
|
*/
|
|
alphanumeric?: boolean;
|
|
};
|
|
|
|
const sanitizeAlphanumeric = (value: string) =>
|
|
value.replace(/[^a-zA-Z0-9]/g, "").toUpperCase();
|
|
|
|
export function OneTimePasswordInput({
|
|
length = 6,
|
|
alphanumeric,
|
|
ref,
|
|
...rest
|
|
}: Props) {
|
|
const alphanumericProps = alphanumeric
|
|
? {
|
|
validationType: "none" as const,
|
|
sanitizeValue: sanitizeAlphanumeric,
|
|
}
|
|
: undefined;
|
|
|
|
return (
|
|
<OneTimePasswordRoot {...alphanumericProps} {...rest}>
|
|
{Array.from({ length }, (_, i) => (
|
|
<OneTimePasswordInputField key={i} />
|
|
))}
|
|
<OneTimePasswordField.HiddenInput ref={ref} />
|
|
</OneTimePasswordRoot>
|
|
);
|
|
}
|
|
|
|
const OneTimePasswordRoot = styled(OneTimePasswordField.Root)`
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
flex-wrap: nowrap;
|
|
justify-content: space-between;
|
|
`;
|
|
|
|
const OneTimePasswordInputField = styled(OneTimePasswordField.Input)`
|
|
all: unset;
|
|
box-sizing: border-box;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
text-align: center;
|
|
border-radius: 4px;
|
|
font-size: 15px;
|
|
color: ${s("text")};
|
|
background: ${s("background")};
|
|
box-shadow: 0 0 0 1px ${s("inputBorder")};
|
|
padding: 0;
|
|
height: 38px;
|
|
width: 38px;
|
|
line-height: 1;
|
|
transition: box-shadow 0.1s ease-in-out;
|
|
|
|
&:focus {
|
|
box-shadow: 0 0 0 2px ${s("inputBorderFocused")};
|
|
}
|
|
&::selection {
|
|
background-color: ${s("background")};
|
|
color: ${s("text")};
|
|
}
|
|
`;
|