有効期限ExpiryBadgeExperimental

The date-vs-deadline currency indicator: classifies an expiry date against today into 有効 / 期限間近 / 失効 / 未登録 and shows a colour-safe state chip (icon + label, never colour alone), the date, and a 残N日 / N日超過 readout. The date-domain sibling of Meter (value vs a capacity) and ReferenceValue (value vs a numeric range) — this is value vs a DEADLINE. For licence / 資格 / 適性診断 / 健診 / 車検 / 保険 / 認証 / 点検 currency across crew, asset and compliance consoles. Pairs with the pure classifyExpiry() helper (value → {state, days}), mirroring how ReferenceValue pairs with flagValue(). RSC-safe; pass today in for SSR determinism (defaults to new Date()).

プレビュー

普通二種免許
有効2029/03/15残991日
適性診断(適齢)
期限間近2026/07/20残22日
健康診断
失効2026/06/1018日超過
地理試験合格証
未登録

基準日 2026-06-28。しきい値を上げると「適性診断」が有効→期限間近に変わる。失効/未登録は色のみに依存せずアイコン+ラベルで表示。

Props

表は横にスクロールできます
プロパティ初期値説明
valuestring | number | Date | null-有効期限(ISO文字列/タイムスタンプ/Date)。null/省略 → 未登録。
todaystring | number | Datenew Date()判定の基準日。SSR決定性のため渡すことを推奨(Gantt の today と同様)。
warnWithinDaysnumber30この日数以内を「期限間近」とする。
showDatebooleantrue状態チップの横に日付を表示。
hideRemainingbooleanfalse残N日 / N日超過 の表示を隠す。
formatDate(d: Date) => string-日付の整形。既定は YYYY/MM/DD。
labelsPartial<Record<ExpiryState, ReactNode>>-状態ラベルの上書き(有効/期限間近/失効/未登録)。
classifyExpiry()(value, { today?, warnWithinDays? }) => { state, days }-純関数の分類器(flagValue の日付版)。state=valid/expiring/expired/missing、days=期限までの日数。

Usage

import { ExpiryBadge, classifyExpiry } from "@gunjo/ui"

// component — colour-safe state chip + date + 残N日/N日超過
<ExpiryBadge value="2026-07-20" today={today} warnWithinDays={60} />

// pure helper (mirrors ReferenceValue's flagValue) — drive your own UI / sort / counts
const { state, days } = classifyExpiry("2026-07-20", { today, warnWithinDays: 60 })
// → { state: "expiring", days: 22 }   // "valid" | "expiring" | "expired" | "missing"

使用コンポーネント