|
1 | | -"use client"; |
2 | | - |
3 | 1 | import React, { memo, forwardRef, useId } from "react"; |
4 | 2 | import { symToStr } from "tsafe/symToStr"; |
5 | 3 | import { assert } from "tsafe/assert"; |
6 | 4 | import type { Equals } from "tsafe"; |
7 | | -import { createComponentI18nApi } from "./i18n/createComponentI18nApi"; |
8 | | -import { useLang } from "./i18n/useLang"; |
9 | | -import { cx } from "./tools/cx"; |
10 | | -import { fr } from "./fr"; |
11 | | -import { getLink } from "./link"; |
12 | | -import type { RegisteredLinkProps } from "./link"; |
13 | | - |
14 | | -type SummaryLink = { |
15 | | - text: string; |
16 | | - linkProps: RegisteredLinkProps; |
17 | | -}; |
18 | | - |
19 | | -export type SummaryProps = { |
20 | | - className?: string; |
21 | | - links: SummaryLink[]; |
22 | | - title?: string; |
23 | | - /** Default: "p" */ |
24 | | - as?: "p" | "h2" | "h3" | "h4" | "h5" | "h6"; |
25 | | - classes?: Partial<Record<"root" | "title" | "link", string>>; |
26 | | -}; |
| 5 | +import { createComponentI18nApi } from "../i18n/createComponentI18nApi"; |
| 6 | +import { cx } from "../tools/cx"; |
| 7 | +import { fr } from "../fr"; |
| 8 | +import { getLink } from "../link"; |
| 9 | +import type { SummaryProps } from "./Summary"; |
27 | 10 |
|
28 | 11 | /** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-summary> */ |
29 | 12 | export const Summary = memo( |
30 | | - forwardRef<HTMLDivElement, SummaryProps>((props, ref) => { |
31 | | - const { className, links, as = "p", title, classes = {}, ...rest } = props; |
| 13 | + forwardRef<HTMLDivElement, SummaryProps & { lang?: string }>((props, ref) => { |
| 14 | + const { className, links, as = "p", title, classes = {}, lang = "fr", ...rest } = props; |
32 | 15 |
|
33 | | - const { t } = getTranslation(useLang()); |
| 16 | + const { t } = getTranslation(lang); |
34 | 17 |
|
35 | 18 | const titleId = useId(); |
36 | 19 | const summaryTitle = title ?? t("title"); |
|
0 commit comments