Skip to content

Commit

Permalink
Merge pull request #279 from acelaya-forks/feature/remove-uuid
Browse files Browse the repository at this point in the history
Drop dependency on uuid
  • Loading branch information
acelaya authored Oct 2, 2024
2 parents 90e9a73 + 8fab1b5 commit 673a654
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).

## [0.5.3] - 2024-10-02
### Added
* *Nothing*

### Changed
* Drop dependency on `uuid`.

### Deprecated
* The `useDomId` hook is now deprecated. Use `useId` instead.

### Removed
* *Nothing*

### Fixed
* *Nothing*


## [0.5.2] - 2024-07-22
### Added
* *Nothing*
Expand Down
15 changes: 1 addition & 14 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"dev": "vite serve --host=0.0.0.0 --port 3001"
},
"dependencies": {
"clsx": "^2.1.1",
"uuid": "^10.0.0"
"clsx": "^2.1.1"
},
"peerDependencies": {
"@fortawesome/fontawesome-free": "^6.4.2",
Expand Down
4 changes: 2 additions & 2 deletions src/form/BooleanControl.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clsx } from 'clsx';
import type { ChangeEvent, FC, PropsWithChildren } from 'react';
import { useDomId } from '../hooks';
import { useId } from 'react';

export type BooleanControlProps = PropsWithChildren<{
checked?: boolean;
Expand All @@ -16,7 +16,7 @@ type BooleanControlWithTypeProps = BooleanControlProps & {
export const BooleanControl: FC<BooleanControlWithTypeProps> = (
{ checked = false, onChange, className, children, type, inline = false },
) => {
const id = useDomId();
const id = useId();
const onChecked = (e: ChangeEvent<HTMLInputElement>) => onChange?.(e.target.checked, e);
const typeClasses = {
'form-switch': type === 'switch',
Expand Down
4 changes: 2 additions & 2 deletions src/form/InputFormGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC, PropsWithChildren } from 'react';
import { useId } from 'react';
import type { InputType } from 'reactstrap/types/lib/Input';
import { useDomId } from '../hooks';
import { LabeledFormGroup } from './LabeledFormGroup';

export type InputFormGroupProps = PropsWithChildren<{
Expand All @@ -16,7 +16,7 @@ export type InputFormGroupProps = PropsWithChildren<{
export const InputFormGroup: FC<InputFormGroupProps> = (
{ children, value, onChange, type, required, placeholder, className, labelClassName },
) => {
const id = useDomId();
const id = useId();

return (
<LabeledFormGroup label={<>{children}:</>} className={className} labelClassName={labelClassName} id={id}>
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback, useMemo, useRef, useState } from 'react';
import { useCallback, useId, useMemo, useRef, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { v4 as uuid } from 'uuid';
import { parseQueryString } from '../utils';

type ToggleResult = [boolean, () => void, () => void, () => void];
Expand Down Expand Up @@ -40,9 +39,9 @@ export const useTimeoutToggle = (
return [flag, callback];
};

/** @deprecated Use standard useId() instead */
export const useDomId = (): string => {
const { current: id } = useRef(`dom-${uuid()}`);
return id;
return useId();
};

export const useElementRef = <T>() => useRef<T | null>(null);
Expand Down

0 comments on commit 673a654

Please sign in to comment.