Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop fjern UUID #2214

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/ffe-accordion-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@sb1/ffe-accordion": "^10.0.30",
"@sb1/ffe-collapse-react": "^5.0.5",
"@sb1/ffe-icons-react": "^11.0.2",
"@types/uuid": "^9.0.0",
"classnames": "^2.3.1"
},
"devDependencies": {
Expand Down
13 changes: 7 additions & 6 deletions packages/ffe-form-react/src/ToggleSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useRef } from 'react';
import { v4 as uuidv4 } from 'uuid';
import React, { useId } from 'react';
import classNames from 'classnames';
import i18n from './i18n/i18n';

Expand All @@ -26,13 +25,15 @@ export const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
hideOnOff,
onText,
offText,
id,
id: providedId,
value = 'on',
locale = 'nb',
checked,
...rest
}) => {
const generatedId = useRef(id ?? `toggle-${uuidv4()}`).current;
const generatedId = useId();

const id = providedId ?? generatedId;

const text = i18n[locale];

Expand All @@ -47,12 +48,12 @@ export const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
<input
className="ffe-toggle-switch__input"
type="checkbox"
id={generatedId}
id={id}
value={value}
checked={!!checked}
{...rest}
/>
<label className="ffe-toggle-switch__label" htmlFor={generatedId}>
<label className="ffe-toggle-switch__label" htmlFor={id}>
<span className="ffe-toggle-switch__label-text">
{children}
{description && (
Expand Down
5 changes: 2 additions & 3 deletions packages/ffe-tables-react/src/TableRowExpandable.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useRef, useState } from 'react';
import React, { useRef, useState, useId } from 'react';
import classNames from 'classnames';
import { Icon } from '@sb1/ffe-icons-react';
import { Collapse } from '@sb1/ffe-collapse-react';
import { txt } from './texts';
import { v4 as uuid } from 'uuid';
import { CellContent } from './CellContent';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denne var ikke i package.json og skall ikke vare så trynet før noen


export interface TableRowExpandableProps
Expand All @@ -30,7 +29,7 @@ export const TableRowExpandable = React.forwardRef<
ref,
) => {
const [isOpen, setIsOpen] = useState(!!isDefaultOpen);
const expandoRowId = useRef(`check-${uuid()}`).current;
const expandoRowId = useId();
const [isAnimating, setIsAnimating] = useState(false);
const expandButtonRef = useRef<HTMLButtonElement>(null);

Expand Down
Loading