Skip to content

Commit 93d64a5

Browse files
committed
change uuid lib to nanoid
1 parent a5797df commit 93d64a5

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
"classnames": "^2.3.1",
5454
"keycoder": "^1.1.1",
5555
"moment": "^2.13.0",
56+
"nanoid": "^3.3.4",
5657
"react-merge-refs": "^1.1.0",
5758
"react-relative-portal": "github:stomita/react-relative-portal#dist",
58-
"svg4everybody": "^2.1.9",
59-
"uuid": "^8.3.2"
59+
"svg4everybody": "^2.1.9"
6060
},
6161
"devDependencies": {
6262
"@babel/cli": "^7.17.6",
@@ -76,7 +76,6 @@
7676
"@types/react": "^17",
7777
"@types/react-dom": "^17",
7878
"@types/svg4everybody": "^2.1.1",
79-
"@types/uuid": "^8.3.4",
8079
"@typescript-eslint/eslint-plugin": "^5.20.0",
8180
"@typescript-eslint/parser": "^5.20.0",
8281
"babel-loader": "^8.1.0",

src/scripts/hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from 'react';
1010
import mergeRefs from 'react-merge-refs';
1111
import { FormElementContext } from './FormElement';
12-
import { uuid } from './util';
12+
import { generateUniqueId } from './util';
1313

1414
/**
1515
*
@@ -31,7 +31,7 @@ export function useFormElementId(
3131
prefix = 'form-element'
3232
) {
3333
const { id: formElemId } = useContext(FormElementContext);
34-
const [generatedId] = useState(`${prefix}-${uuid()}`);
34+
const [generatedId] = useState(`${prefix}-${generateUniqueId()}`);
3535
return propsId ?? formElemId ?? generatedId;
3636
}
3737

src/scripts/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { v4 as createUUID } from 'uuid';
1+
import { nanoid } from 'nanoid';
22
import { updateScroll } from 'react-relative-portal';
33

4-
export const uuid: () => string =
5-
process.env.NODE_ENV === 'test' ? () => '$uuid$' : createUUID;
4+
export const generateUniqueId: () => string =
5+
process.env.NODE_ENV === 'test' ? () => '$uuid$' : nanoid;
66

77
export const getToday =
88
process.env.NODE_ENV === 'test'

yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,11 +3041,6 @@
30413041
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d"
30423042
integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==
30433043

3044-
"@types/uuid@^8.3.4":
3045-
version "8.3.4"
3046-
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc"
3047-
integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==
3048-
30493044
"@types/wait-on@^5.0.0":
30503045
version "5.3.1"
30513046
resolved "https://registry.yarnpkg.com/@types/wait-on/-/wait-on-5.3.1.tgz#bc5520d1d8b90b9caab1bef23315685ded73320d"
@@ -4702,10 +4697,10 @@ class-utils@^0.3.5:
47024697
isobject "^3.0.0"
47034698
static-extend "^0.1.1"
47044699

4705-
classnames@^2.2.5:
4706-
version "2.2.6"
4707-
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
4708-
integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
4700+
classnames@^2.3.1:
4701+
version "2.3.1"
4702+
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.1.tgz#dfcfa3891e306ec1dad105d0e88f4417b8535e8e"
4703+
integrity sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==
47094704

47104705
clean-css@^4.2.3:
47114706
version "4.2.4"
@@ -9260,6 +9255,11 @@ nanoid@^3.1.23:
92609255
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25"
92619256
integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==
92629257

9258+
nanoid@^3.3.4:
9259+
version "3.3.4"
9260+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
9261+
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
9262+
92639263
nanomatch@^1.2.9:
92649264
version "1.2.13"
92659265
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@@ -13091,7 +13091,7 @@ uuid@^3.3.2:
1309113091
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
1309213092
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==
1309313093

13094-
uuid@^8.3.0, uuid@^8.3.2:
13094+
uuid@^8.3.0:
1309513095
version "8.3.2"
1309613096
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
1309713097
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

0 commit comments

Comments
 (0)