diff --git a/packages/formiz-core/package.json b/packages/formiz-core/package.json index d3e3ccb1..952363c5 100644 --- a/packages/formiz-core/package.json +++ b/packages/formiz-core/package.json @@ -31,10 +31,8 @@ "@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", @@ -42,6 +40,7 @@ "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", diff --git a/packages/formiz-core/src/store.ts b/packages/formiz-core/src/store.ts index 59a96f6e..667f5ea2 100644 --- a/packages/formiz-core/src/store.ts +++ b/packages/formiz-core/src/store.ts @@ -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, @@ -25,7 +28,6 @@ import type { Store, StoreInitialState, } from "@/types"; -import uniqid from "uniqid"; import { formInterfaceSelector } from "@/selectors"; import { getFieldValidationsErrors } from "@/utils/validations"; @@ -719,7 +721,7 @@ export const createStore = ( options ); get().actions.setCollectionKeys(fieldName)((oldKeys) => - values.map((_, index) => oldKeys?.[index] ?? uniqid()) + values.map((_, index) => oldKeys?.[index] ?? uid.rnd()) ); return { @@ -737,7 +739,7 @@ export const createStore = ( index < 0 ? oldKeys.length + 1 + index : index; const keysToInsert = Array.from( { length: values?.length ?? 0 }, - () => uniqid() + () => uid.rnd() ); const newKeys = [ ...(oldKeys || []).slice(0, computedIndex), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4016dcb9..28d7c3b4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -175,9 +175,6 @@ importers: '@types/react-dom': specifier: 18.0.10 version: 18.0.10 - '@types/uniqid': - specifier: 5.3.2 - version: 5.3.2 clone-deep: specifier: 4.0.1 version: 4.0.1 @@ -205,6 +202,9 @@ importers: react-dom: specifier: 18.2.0 version: 18.2.0(react@18.2.0) + short-unique-id: + specifier: 5.0.3 + version: 5.0.3 ts-jest: specifier: 29.0.5 version: 29.0.5(@babel/core@7.22.1)(esbuild@0.15.18)(jest@29.4.0)(typescript@4.9.4) @@ -217,9 +217,6 @@ importers: typescript: specifier: 4.9.4 version: 4.9.4 - uniqid: - specifier: 5.4.0 - version: 5.4.0 zustand: specifier: 4.3.2 version: 4.3.2(react@18.2.0) @@ -3336,10 +3333,6 @@ packages: resolution: {integrity: sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==} dev: true - /@types/uniqid@5.3.2: - resolution: {integrity: sha512-/NYoaZpWsnAJDsGYeMNDeG3p3fuUb4AiC7MfKxi5VSu18tXd08w6Ch0fKW94T4FeLXXZwZPoFgHA1O0rDYKyMQ==} - dev: true - /@types/unist@2.0.6: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} dev: false @@ -9582,6 +9575,11 @@ packages: vscode-textmate: 8.0.0 dev: false + /short-unique-id@5.0.3: + resolution: {integrity: sha512-yhniEILouC0s4lpH0h7rJsfylZdca10W9mDJRAFh3EpcSUanCHGb0R7kcFOIUCZYSAPo0PUD5ZxWQdW0T4xaug==} + hasBin: true + dev: true + /side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: @@ -10380,10 +10378,6 @@ packages: vfile: 5.3.7 dev: false - /uniqid@5.4.0: - resolution: {integrity: sha512-38JRbJ4Fj94VmnC7G/J/5n5SC7Ab46OM5iNtSstB/ko3l1b5g7ALt4qzHFgGciFkyiRNtDXtLNb+VsxtMSE77A==} - dev: true - /unist-util-find-after@4.0.1: resolution: {integrity: sha512-QO/PuPMm2ERxC6vFXEPtmAutOopy5PknD+Oq64gGwxKtk4xwo9Z97t9Av1obPmGU0IyTa6EKYUfTrK2QJS3Ozw==} dependencies: