LoginForm without remember-me and forgot-password, release 0.6.0
Breaking: LoginCredentials has no `remember` field and LoginForm no longer takes `onForgotPassword`. The form is login, password, sign-in and the electronic signature button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
96239dd064
commit
1d9c935b1e
|
|
@ -18,7 +18,7 @@ src/styles.css тема (токены, шрифты, тёмный режим)
|
||||||
Пакет ставится прямо из git, версии — теги `vX.Y.Z`:
|
Пакет ставится прямо из git, версии — теги `vX.Y.Z`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm i "git+https://git.med-logic.ru/medlogic/medkit.git#semver:^0.5.0"
|
npm i "git+https://git.med-logic.ru/medlogic/medkit.git#semver:^0.6.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
`package-lock.json` фиксирует коммит; обновиться до свежего тега — `npm update @medkit/ui`. В medicine-ui kit подключён git-submodule в `packages/medkit` (npm workspace) — правки видны сразу.
|
`package-lock.json` фиксирует коммит; обновиться до свежего тега — `npm update @medkit/ui`. В medicine-ui kit подключён git-submodule в `packages/medkit` (npm workspace) — правки видны сразу.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@medkit/ui",
|
"name": "@medkit/ui",
|
||||||
"version": "0.5.0",
|
"version": "0.6.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Medkit — UI kit МИС «Медицина»: React 19 + Tailwind 4 + Radix (shadcn/ui)",
|
"description": "Medkit — UI kit МИС «Медицина»: React 19 + Tailwind 4 + Radix (shadcn/ui)",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,15 @@ import * as React from "react"
|
||||||
import { ArrowLeftIcon, EyeIcon, EyeOffIcon, FileKeyIcon, Loader2Icon } from "lucide-react"
|
import { ArrowLeftIcon, EyeIcon, EyeOffIcon, FileKeyIcon, Loader2Icon } from "lucide-react"
|
||||||
|
|
||||||
import { Button } from "../ui/button"
|
import { Button } from "../ui/button"
|
||||||
import { Checkbox } from "../ui/checkbox"
|
|
||||||
import { Input } from "../ui/input"
|
import { Input } from "../ui/input"
|
||||||
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../ui/input-group"
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../ui/input-group"
|
||||||
import { InputOTP, InputOTPGroup, InputOTPSlot } from "../ui/input-otp"
|
import { InputOTP, InputOTPGroup, InputOTPSlot } from "../ui/input-otp"
|
||||||
import { Label } from "../ui/label"
|
|
||||||
import { cn } from "../lib/utils"
|
import { cn } from "../lib/utils"
|
||||||
import { FormField } from "./form-field"
|
import { FormField } from "./form-field"
|
||||||
|
|
||||||
export interface LoginCredentials {
|
export interface LoginCredentials {
|
||||||
login: string
|
login: string
|
||||||
password: string
|
password: string
|
||||||
remember: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Второй шаг входа: у пользователя включён одноразовый код. */
|
/** Второй шаг входа: у пользователя включён одноразовый код. */
|
||||||
|
|
@ -40,7 +37,6 @@ export interface LoginFormProps {
|
||||||
onResendOtp?: () => Promise<void>
|
onResendOtp?: () => Promise<void>
|
||||||
/** Кнопка «Войти по электронной подписи»; выбор сертификата — на стороне приложения. */
|
/** Кнопка «Войти по электронной подписи»; выбор сертификата — на стороне приложения. */
|
||||||
onSignature?: () => Promise<void | OtpChallenge>
|
onSignature?: () => Promise<void | OtpChallenge>
|
||||||
onForgotPassword?: () => void
|
|
||||||
className?: string
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,12 +64,10 @@ export function LoginForm({
|
||||||
onVerifyOtp,
|
onVerifyOtp,
|
||||||
onResendOtp,
|
onResendOtp,
|
||||||
onSignature,
|
onSignature,
|
||||||
onForgotPassword,
|
|
||||||
className,
|
className,
|
||||||
}: LoginFormProps) {
|
}: LoginFormProps) {
|
||||||
const [login, setLogin] = React.useState(defaultLogin)
|
const [login, setLogin] = React.useState(defaultLogin)
|
||||||
const [password, setPassword] = React.useState("")
|
const [password, setPassword] = React.useState("")
|
||||||
const [remember, setRemember] = React.useState(true)
|
|
||||||
const [showPassword, setShowPassword] = React.useState(false)
|
const [showPassword, setShowPassword] = React.useState(false)
|
||||||
const [capsLock, setCapsLock] = React.useState(false)
|
const [capsLock, setCapsLock] = React.useState(false)
|
||||||
const [challenge, setChallenge] = React.useState<OtpChallenge | null>(null)
|
const [challenge, setChallenge] = React.useState<OtpChallenge | null>(null)
|
||||||
|
|
@ -112,7 +106,7 @@ export function LoginForm({
|
||||||
|
|
||||||
async function submitLogin() {
|
async function submitLogin() {
|
||||||
if (busy || !login.trim() || !password) return
|
if (busy || !login.trim() || !password) return
|
||||||
const result = await run("login", () => onLogin({ login: login.trim(), password, remember }))
|
const result = await run("login", () => onLogin({ login: login.trim(), password }))
|
||||||
if (result.ok) startOtp(result.value)
|
if (result.ok) startOtp(result.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,25 +271,6 @@ export function LoginForm({
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<div className="flex items-center justify-between gap-2">
|
|
||||||
<Label className="font-normal">
|
|
||||||
<Checkbox checked={remember} onCheckedChange={(v) => setRemember(v === true)} disabled={busy} />
|
|
||||||
Запомнить меня
|
|
||||||
</Label>
|
|
||||||
{onForgotPassword && (
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="link"
|
|
||||||
size="sm"
|
|
||||||
className="-mr-3 h-auto py-0"
|
|
||||||
onClick={onForgotPassword}
|
|
||||||
disabled={busy}
|
|
||||||
>
|
|
||||||
Забыли пароль?
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{error && <p className="text-sm text-destructive">{error}</p>}
|
{error && <p className="text-sm text-destructive">{error}</p>}
|
||||||
|
|
||||||
<Button type="submit" size="lg" className="w-full" disabled={busy || !login.trim() || !password}>
|
<Button type="submit" size="lg" className="w-full" disabled={busy || !login.trim() || !password}>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue