Skip to content

Commit

Permalink
Add utils.js back
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinr committed Dec 27, 2024
1 parent 5b2edc0 commit d96b8c7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/frontend-core/src/components/grid/lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// TODO: remove when all stores are typed

import { GeneratedIDPrefix, CellIDSeparator } from "./constants"
import { Helpers } from "@budibase/bbui"

export const parseCellID = cellId => {
if (!cellId) {
return { rowId: undefined, field: undefined }
}
const parts = cellId.split(CellIDSeparator)
const field = parts.pop()
return { rowId: parts.join(CellIDSeparator), field }
}

export const getCellID = (rowId, fieldName) => {
return `${rowId}${CellIDSeparator}${fieldName}`
}

export const parseEventLocation = e => {
return {
x: e.clientX ?? e.touches?.[0]?.clientX,
y: e.clientY ?? e.touches?.[0]?.clientY,
}
}

export const generateRowID = () => {
return `${GeneratedIDPrefix}${Helpers.uuid()}`
}

export const isGeneratedRowID = id => {
return id?.startsWith(GeneratedIDPrefix)
}

0 comments on commit d96b8c7

Please sign in to comment.