mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
804 B
29 lines
804 B
2 years ago
|
import type { TableType } from 'nocodb-sdk'
|
||
|
import type { Ref } from 'vue'
|
||
|
import { useInjectionState } from '#imports'
|
||
|
import type { Row } from '~/composables/useViewData'
|
||
|
|
||
|
const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState((meta: Ref<TableType>, row: Ref<Row>) => {
|
||
|
// state
|
||
|
const localState = reactive({})
|
||
|
|
||
|
// getters
|
||
|
const isNew = computed(() => row.value?.rowMeta?.new)
|
||
|
|
||
|
// actions
|
||
|
|
||
|
return {
|
||
|
row,
|
||
|
localState,
|
||
|
isNew,
|
||
|
}
|
||
|
}, 'smartsheet-row-store')
|
||
|
|
||
|
export { useProvideSmartsheetRowStore }
|
||
|
|
||
|
export function useSmartsheetRowStoreOrThrow() {
|
||
|
const smartsheetRowStore = useSmartsheetRowStore()
|
||
|
if (smartsheetRowStore == null) throw new Error('Please call `useSmartsheetRowStore` on the appropriate parent component')
|
||
|
return smartsheetRowStore
|
||
|
}
|