1- import { ref , watch } from 'vue'
2- import { PivotData } from '@/helper/utilities.js '
1+ import { Ref , ref , watch } from 'vue'
2+ import { PivotData } from '@/helper/utilities'
33
4- export function useMaterializeInput ( dataSource , options ) {
5- const rawData = ref ( null )
6- const allFilters = ref ( { } )
7- const materializedInput = ref ( [ ] )
4+ export interface UseMaterializeInputOptions {
5+ derivedAttributes : Ref < Record < string , ( record : Record < string , any > ) => any > >
6+ }
7+
8+ export interface UseMaterializeInputReturn {
9+ rawData : Ref < any >
10+ allFilters : Ref < Record < string , Record < string , number > > >
11+ materializedInput : Ref < any [ ] >
12+ processData : ( data : any ) => { AllFilters : Record < string , Record < string , number > > ; materializedInput : any [ ] } | void
13+ }
814
9- function processData ( data ) {
15+ export function useMaterializeInput (
16+ dataSource : Ref < any > ,
17+ options : UseMaterializeInputOptions
18+ ) : UseMaterializeInputReturn {
19+ const rawData = ref < any > ( null )
20+ const allFilters = ref < Record < string , Record < string , number > > > ( { } )
21+ const materializedInput = ref < any [ ] > ( [ ] )
22+
23+ function processData ( data : any ) {
1024 if ( ! data || rawData . value === data ) return
1125
1226 rawData . value = data
13- const newAllFilters = { }
14- const newMaterializedInput = [ ]
27+ const newAllFilters : Record < string , Record < string , number > > = { }
28+ const newMaterializedInput : any [ ] = [ ]
1529
1630 let recordsProcessed = 0
1731
1832 PivotData . forEachRecord (
1933 data ,
2034 options . derivedAttributes . value ,
21- function ( record ) {
35+ function ( record : Record < string , any > ) {
2236 newMaterializedInput . push ( record )
2337
2438 for ( const attr of Object . keys ( record ) ) {
@@ -66,4 +80,4 @@ export function useMaterializeInput(dataSource, options) {
6680 materializedInput,
6781 processData
6882 }
69- }
83+ }
0 commit comments