From 62a0096039c924b0e7520d12e66efc0355a14fda Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Tue, 31 Dec 2024 14:28:53 +0530 Subject: [PATCH] fix: replace crypto uuid generation with randomly generated hash string --- atable/src/stores/table.ts | 3 ++- atable/src/utils.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/atable/src/stores/table.ts b/atable/src/stores/table.ts index bc416165..f76b1961 100644 --- a/atable/src/stores/table.ts +++ b/atable/src/stores/table.ts @@ -2,6 +2,7 @@ import { defineStore } from 'pinia' import { type CSSProperties, computed, ref } from 'vue' import type { CellContext, TableColumn, TableConfig, TableDisplay, TableModal, TableRow } from '../types' +import { generateHash } from '../utils' /** * Create a table store @@ -18,7 +19,7 @@ export const createTableStore = (initData: { display?: TableDisplay[] modal?: TableModal }) => { - const id = initData.id || crypto.randomUUID() + const id = initData.id || generateHash() const createStore = defineStore(`table-${id}`, () => { // util functions const createTableObject = () => { diff --git a/atable/src/utils.ts b/atable/src/utils.ts index e97b8406..6f3616a9 100644 --- a/atable/src/utils.ts +++ b/atable/src/utils.ts @@ -2,3 +2,7 @@ export const isHtmlString = (htmlString: string) => { const $document = new DOMParser().parseFromString(htmlString, 'text/html') return Array.from($document.body.childNodes).some(node => node.nodeType === 1) } + +export const generateHash = (length = 8) => { + return Array.from({ length }, () => Math.floor(Math.random() * 16).toString(16)).join('') +}