Skip to content

Commit

Permalink
Fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Jul 13, 2023
1 parent 44dfca3 commit aeac22f
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 70 deletions.
8 changes: 1 addition & 7 deletions src/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"use client";

import React, {
forwardRef,
memo,
useState,
type ReactNode,
type CSSProperties
} from "react";
import React, { forwardRef, memo, useState, type ReactNode, type CSSProperties } from "react";
import { assert } from "tsafe/assert";
import type { Equals } from "tsafe";
import { fr } from "./fr";
Expand Down
7 changes: 6 additions & 1 deletion src/AgentConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export const AgentConnectButton = memo(
const Inner = onClick !== undefined ? "button" : "a";

return (
<div id={id_props ?? "fr-agentconnect-button"} className={className} style={style} ref={ref}>
<div
id={id_props ?? "fr-agentconnect-button"}
className={className}
style={style}
ref={ref}
>
<span className="agentconnect-button__preload-hover" />
<Inner
className="agentconnect-button__link"
Expand Down
2 changes: 1 addition & 1 deletion src/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Badge = memo(

assert<Equals<keyof typeof rest, never>>();

const id= useAnalyticsId({
const id = useAnalyticsId({
"defaultIdPrefix": "fr-badge",
"explicitlyProvidedId": props_id
});
Expand Down
4 changes: 2 additions & 2 deletions src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export namespace ButtonProps {
export type AsButton = {
linkProps?: never;
onClick?: React.MouseEventHandler<HTMLButtonElement>;
nativeButtonProps?: ComponentProps<"button"> & Record<`data-${string}`, string | boolean | null | undefined>;
nativeButtonProps?: ComponentProps<"button"> &
Record<`data-${string}`, string | boolean | null | undefined>;
disabled?: boolean;
/** Default "button" */
type?: "button" | "submit" | "reset";
};
}


/** @see <https://components.react-dsfr.fr/?path=/docs/components-button> */
export const Button = memo(
forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {
Expand Down
13 changes: 10 additions & 3 deletions src/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ export type DownloadProps = {
/** @see <https://components.react-dsfr.fr/?path=/docs/components-download> */
export const Download = memo(
forwardRef<HTMLDivElement, DownloadProps>((props, ref) => {
const { className, style, details, label, linkProps, classes = {},
id: props_id
, ...rest } = props;
const {
className,
style,
details,
label,
linkProps,
classes = {},
id: props_id,
...rest
} = props;

assert<Equals<keyof typeof rest, never>>();

Expand Down
14 changes: 10 additions & 4 deletions src/FranceConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ export namespace FranceConnectButtonProps {
/** @see <https://components.react-dsfr.fr/?path=/docs/components-franceconnectbutton> */
export const FranceConnectButton = memo(
forwardRef<HTMLDivElement, FranceConnectButtonProps>((props, ref) => {
const { classes = {}, className, url: href, plus = false, style, onClick,
id: id_props
,
...rest } = props;
const {
classes = {},
className,
url: href,
plus = false,
style,
onClick,
id: id_props,
...rest
} = props;

assert<Equals<keyof typeof rest, never>>();

Expand Down
5 changes: 4 additions & 1 deletion src/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ export const Header = memo(
</div>
{navigation !== undefined &&
(navigation instanceof Array ? (
<MainNavigation id={`${id}-main-navigation`} items={navigation} />
<MainNavigation
id={`${id}-main-navigation`}
items={navigation}
/>
) : (
navigation
))}
Expand Down
4 changes: 1 addition & 3 deletions src/Highlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export namespace HighlightProps {
/** @see <https://components.react-dsfr.fr/?path=/docs/components-highlight> */
export const Highlight = memo(
forwardRef<HTMLDivElement, HighlightProps>((props, ref) => {
const { className, classes = {}, style, children, size,
id: id_props
, ...rest } = props;
const { className, classes = {}, style, children, size, id: id_props, ...rest } = props;

assert<Equals<keyof typeof rest, never>>();

Expand Down
3 changes: 1 addition & 2 deletions src/MainNavigation/MainNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ export const MainNavigation = memo(
return { getMenuId };
})();


const id = useAnalyticsId({
"explicitlyProvidedId": id_props,
"defaultIdPrefix": "main-navigation",
"defaultIdPrefix": "main-navigation"
});

return (
Expand Down
4 changes: 1 addition & 3 deletions src/MonCompteProButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export namespace FranceConnectButtonProps {
/** @see <https://components.react-dsfr.fr/?path=/docs/components-franceconnectbutton> */
export const MonCompteProButton = memo(
forwardRef<HTMLDivElement, FranceConnectButtonProps>((props, ref) => {
const { classes = {}, className, url: href, style, onClick,
id: id_props
, ...rest } = props;
const { classes = {}, className, url: href, style, onClick, id: id_props, ...rest } = props;

assert<Equals<keyof typeof rest, never>>();

Expand Down
4 changes: 1 addition & 3 deletions src/SkipLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export type SkipLinksProps = {
/** @see <https://components.react-dsfr.fr/?path=/docs/components-skiplinks> */
export const SkipLinks = memo(
forwardRef<HTMLDivElement, SkipLinksProps>((props, ref) => {
const { className, classes = {}, links, style,
id: id_props
,...rest } = props;
const { className, classes = {}, links, style, id: id_props, ...rest } = props;
const { t } = useTranslation();
assert<Equals<keyof typeof rest, never>>();

Expand Down
13 changes: 10 additions & 3 deletions src/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ export type SummaryProps = {
/** @see <https://components.react-dsfr.fr/?path=/docs/components-summary> */
export const Summary = memo(
forwardRef<HTMLDivElement, SummaryProps>((props, ref) => {
const { className, links, as = "p", title, classes = {}, style,
id: id_props
,...rest } = props;
const {
className,
links,
as = "p",
title,
classes = {},
style,
id: id_props,
...rest
} = props;

const { t } = useTranslation();

Expand Down
10 changes: 7 additions & 3 deletions src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ export const Tabs = memo(
})();

return (
<div
id={id}
className={cx(fr.cx("fr-tabs"), className)} ref={ref} style={style} {...rest}>
<div
id={id}
className={cx(fr.cx("fr-tabs"), className)}
ref={ref}
style={style}
{...rest}
>
<ul className={fr.cx("fr-tabs__list")} role="tablist" aria-label={label}>
{tabs.map(({ label, iconId }, tabIndex) => (
<li key={label + (iconId ?? "")} role="presentation">
Expand Down
12 changes: 6 additions & 6 deletions src/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ export const Tag = memo(
) as MemoExoticComponent<
ForwardRefExoticComponent<
TagProps.Common &
(TagProps.WithIcon | TagProps.WithoutIcon) &
(
| (TagProps.AsAnchor & RefAttributes<HTMLAnchorElement>)
| (TagProps.AsButton & RefAttributes<HTMLButtonElement>)
| (TagProps.AsSpan & RefAttributes<HTMLSpanElement>)
)
(TagProps.WithIcon | TagProps.WithoutIcon) &
(
| (TagProps.AsAnchor & RefAttributes<HTMLAnchorElement>)
| (TagProps.AsButton & RefAttributes<HTMLButtonElement>)
| (TagProps.AsSpan & RefAttributes<HTMLSpanElement>)
)
>
>;

Expand Down
9 changes: 1 addition & 8 deletions src/ToggleSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import React, {
memo,
forwardRef,
ReactNode,
useState,
useEffect,
type CSSProperties
} from "react";
import React, { memo, forwardRef, ReactNode, useState, useEffect, type CSSProperties } from "react";
import { symToStr } from "tsafe/symToStr";
import { assert } from "tsafe/assert";
import type { Equals } from "tsafe";
Expand Down
8 changes: 1 addition & 7 deletions src/Upload.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import React, {
DetailedHTMLProps,
InputHTMLAttributes,
ReactNode,
forwardRef,
memo
} from "react";
import React, { DetailedHTMLProps, InputHTMLAttributes, ReactNode, forwardRef, memo } from "react";
import { createComponentI18nApi } from "./i18n";
import { symToStr } from "tsafe/symToStr";
import { cx } from "./tools/cx";
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const PasswordInput = memo(

assert<Equals<keyof typeof rest, never>>();

const id= useAnalyticsId({
const id = useAnalyticsId({
"explicitlyProvidedId": id_props,
"defaultIdPrefix": "password-input"
});
Expand Down
1 change: 0 additions & 1 deletion src/consentManagement/createConsentManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export function createConsentManagement<
return JSON.parse(serializedFinalityConsent);
});


const { processConsentChanges, useConsentCallback } = createProcessConsentChanges<Finality>({
consentCallback,
finalities,
Expand Down
4 changes: 3 additions & 1 deletion src/shared/Fieldset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export const Fieldset = memo(
assert<Equals<keyof typeof rest, never>>();

const id = useAnalyticsId({
"defaultIdPrefix": `fr-fieldset-${type}${name_props === undefined ? "" : `-${name_props}`}`,
"defaultIdPrefix": `fr-fieldset-${type}${
name_props === undefined ? "" : `-${name_props}`
}`,
"explicitlyProvidedId": id_props
});

Expand Down
14 changes: 4 additions & 10 deletions src/tools/useAnalyticsId.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { useId } from "react";

/**
* Eulerian analytics requires every element to have a unique ID.
/**
* Eulerian analytics requires every element to have a unique ID.
* This hook help generate such an ID in the case they are not explicitly provided.
*/
export function useAnalyticsId(
params: {
explicitlyProvidedId?: string;
defaultIdPrefix: string;
}
) {

export function useAnalyticsId(params: { explicitlyProvidedId?: string; defaultIdPrefix: string }) {
const { explicitlyProvidedId, defaultIdPrefix } = params;

const id = useId();

return explicitlyProvidedId ?? `${defaultIdPrefix}-${id}`;
}
}

0 comments on commit aeac22f

Please sign in to comment.