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

fix: add nanoid back #607

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import { Checkbox } from "@washingtonpost/wpds-ui-kit";
import { nanoid } from "nanoid";

export const InputCheckbox = (props) => {
const elementId = React.useId();
const elementId = nanoid();

return <Checkbox {...props} id={elementId} />;
};
21 changes: 20 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@stitches/react": "^1.2.8",
"@washingtonpost/wpds-assets": "1.24.1-alpha.0",
"match-sorter": "6.3.1",
"nanoid": "^3.3.4",
"react": "^18.2.0",
"react-swipeable": "^7.0.0",
"react-transition-group": "^4.4.5"
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/carousel/CarouselContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { styled, theme } from "../theme";
import type * as WPDS from "../theme";

import { useSwipeable } from "react-swipeable";
import { nanoid } from "nanoid";

import { CarouselContext } from "./CarouselRoot";
import { CarouselItemProps } from "./CarouselItem";
Expand Down Expand Up @@ -50,7 +51,7 @@ export const CarouselContent = React.forwardRef<
} = React.useContext(CarouselContext);

const [totalItems, setTotalItems] = React.useState(0);
const id = React.useId();
const id = nanoid();
const childRefs = React.useRef<HTMLDivElement[]>([]);
const internalRef = React.useRef<HTMLDivElement>(null);
const [xPos, setXpos] = React.useState(0);
Expand Down
5 changes: 4 additions & 1 deletion packages/kit/src/carousel/CarouselTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React from "react";

import { nanoid } from "nanoid";

import { styled, theme } from "../theme";
import { CarouselContext } from "./CarouselRoot";

Expand All @@ -21,7 +24,7 @@ export const CarouselTitle = React.forwardRef<
CarouselTitleProps
>(({ children, ...props }, ref) => {
const { titleId, setTitleId } = React.useContext(CarouselContext);
const id = React.useId();
const id = nanoid();
React.useEffect(() => {
setTitleId && setTitleId(id);
}, [setTitleId]);
Expand Down
5 changes: 4 additions & 1 deletion packages/kit/src/input-text/InputText.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React, { useEffect, useState } from "react";

import { nanoid } from "nanoid";

import { theme, styled } from "../theme";
import { Button } from "../button";
import { Divider } from "../divider";
Expand Down Expand Up @@ -146,7 +149,7 @@ export const InputText = React.forwardRef<HTMLInputElement, InputTextProps>(
const [errorId, setErrorId] = useState<string | undefined>();
const [isAutofilled, setIsAutofilled] = useState<boolean>(false);
const internalRef = React.useRef<HTMLInputElement>(null);
const rootId = React.useId();
const rootId = nanoid();
useEffect(() => {
setHelperId(`wpds-input-helper-${rootId}`);
setErrorId(`wpds-input-error-${rootId}`);
Expand Down
5 changes: 4 additions & 1 deletion packages/kit/src/input-textarea/InputTextarea.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React, { useEffect, useState } from "react";

import { nanoid } from "nanoid";

import { theme, css, styled } from "../theme";
import type * as WPDS from "../theme";
import {
Expand Down Expand Up @@ -132,7 +135,7 @@ export const InputTextarea = React.forwardRef<

const internalRef = React.useRef<HTMLTextAreaElement>(null);

const rootId = React.useId();
const rootId = nanoid();
useEffect(() => {
setHelperId(`wpds-input-helper-${rootId}`);
setErrorId(`wpds-input-error-${rootId}`);
Expand Down
5 changes: 4 additions & 1 deletion packages/kit/src/radio-group/RadioGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from "react";

import { nanoid } from "nanoid";
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
import type { RadioGroupProps as RadioGroupRootProps } from "@radix-ui/react-radio-group";

import * as Theme from "../theme";
import type * as WPDS from "../theme";
import { Fieldset } from "../fieldset";
Expand Down Expand Up @@ -85,7 +88,7 @@ export const RadioGroup = React.forwardRef<
) => {
const [errorId, setErrorId] = React.useState<string | undefined>();

const id = React.useId();
const id = nanoid();
React.useEffect(() => {
setErrorId(`wpds-input-error-${id}`);
}, [setErrorId]);
Expand Down
4 changes: 3 additions & 1 deletion packages/kit/src/select/SelectTrigger.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import { nanoid } from "nanoid";

import { theme, styled } from "../theme";
import { ChevronDown } from "@washingtonpost/wpds-assets";
import { Icon } from "../icon";
Expand Down Expand Up @@ -116,7 +118,7 @@ export const SelectTrigger = React.forwardRef<
[setContentWidth]
);

const id = React.useId();
const id = nanoid();
React.useEffect(() => {
setHelperId(`wpds-input-helper-${id}`);
setErrorId(`wpds-input-error-${id}`);
Expand Down