Fix types
This commit is contained in:
parent
41c8ab976f
commit
8624997f4c
|
@ -70,10 +70,16 @@ export const duplicateName = (name: string, allNames: string[]) => {
|
||||||
* @param getName optional function to extract the name for an item, if not a
|
* @param getName optional function to extract the name for an item, if not a
|
||||||
* flat array of strings
|
* flat array of strings
|
||||||
*/
|
*/
|
||||||
export const getSequentialName = (
|
export const getSequentialName = <T extends string | object>(
|
||||||
items: string[],
|
items: T[],
|
||||||
prefix: string,
|
prefix: string,
|
||||||
{ getName = (x: string) => x, numberFirstItem = false } = {}
|
{
|
||||||
|
getName,
|
||||||
|
numberFirstItem,
|
||||||
|
}: {
|
||||||
|
getName: (item: T) => string
|
||||||
|
numberFirstItem?: boolean
|
||||||
|
}
|
||||||
) => {
|
) => {
|
||||||
if (!prefix?.length || !getName) {
|
if (!prefix?.length || !getName) {
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -62,7 +62,7 @@ export class RowActionStore extends BudiStore<RowActionState> {
|
||||||
const existingRowActions = get(this)[tableId] || []
|
const existingRowActions = get(this)[tableId] || []
|
||||||
name = getSequentialName(existingRowActions, "New row action ", {
|
name = getSequentialName(existingRowActions, "New row action ", {
|
||||||
getName: x => x.name,
|
getName: x => x.name,
|
||||||
})
|
})!
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
|
|
Loading…
Reference in New Issue