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(#215): change uniqid dependency for a new one #216

Merged
merged 1 commit into from
Jan 24, 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
3 changes: 1 addition & 2 deletions packages/formiz-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@
"@types/node": "18.11.18",
"@types/react": "18.0.27",
"@types/react-dom": "18.0.10",
"@types/uniqid": "5.3.2",
"clone-deep": "4.0.1",
"config": "workspace:*",
"uniqid": "5.4.0",
"fast-equals": "4.0.3",
"jest": "29.4.0",
"jest-environment-jsdom": "29.4.0",
"jest-in-case": "1.0.2",
"lodash": "4.17.21",
"react": "18.2.0",
"react-dom": "18.2.0",
"short-unique-id": "5.0.3",
"ts-jest": "29.0.5",
"tsconfig": "workspace:*",
"tsup": "6.5.0",
Expand Down
8 changes: 5 additions & 3 deletions packages/formiz-core/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import lodashSet from "lodash/set";
import lodashGet from "lodash/get";
import lodashMerge from "lodash/merge";
import cloneDeep from "clone-deep";
import ShortUniqueId from "short-unique-id";

const uid = new ShortUniqueId({ length: 19 });

import {
generateField,
Expand All @@ -25,7 +28,6 @@ import type {
Store,
StoreInitialState,
} from "@/types";
import uniqid from "uniqid";
import { formInterfaceSelector } from "@/selectors";
import { getFieldValidationsErrors } from "@/utils/validations";

Expand Down Expand Up @@ -719,7 +721,7 @@ export const createStore = <Values extends object = DefaultFormValues>(
options
);
get().actions.setCollectionKeys(fieldName)((oldKeys) =>
values.map((_, index) => oldKeys?.[index] ?? uniqid())
values.map((_, index) => oldKeys?.[index] ?? uid.rnd())
);

return {
Expand All @@ -737,7 +739,7 @@ export const createStore = <Values extends object = DefaultFormValues>(
index < 0 ? oldKeys.length + 1 + index : index;
const keysToInsert = Array.from(
{ length: values?.length ?? 0 },
() => uniqid()
() => uid.rnd()
);
const newKeys = [
...(oldKeys || []).slice(0, computedIndex),
Expand Down
22 changes: 8 additions & 14 deletions pnpm-lock.yaml

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

Loading