Skip to content

Commit 6426f5b

Browse files
fix: fix type error
1 parent 2fe1d27 commit 6426f5b

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/components/pivottable-ui/VPivottableUi.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ import {
145145
provideFilterBox
146146
} from '@/composables'
147147
import { DefaultPropsType } from '@/types'
148+
import { locales } from '@/helper'
148149
149150
const props = withDefaults(
150151
defineProps<
@@ -167,7 +168,9 @@ const props = withDefaults(
167168
menuLimit: 500,
168169
hideFilterBoxOfUnusedAttributes: false,
169170
rowOrder: 'key_a_to_z',
170-
colOrder: 'key_a_to_z'
171+
colOrder: 'key_a_to_z',
172+
languagePack: () => locales,
173+
locale: 'en'
171174
}
172175
)
173176

src/components/pivottable/renderer/TableRenderer.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ import { providePivotData } from '@/composables'
1818
import VPivottableHeader from '../VPivottableHeader.vue'
1919
import VPivottableBody from '../VPivottableBody.vue'
2020
import { DefaultPropsType } from '@/types'
21+
import { redColorScaleGenerator } from '@/helper'
2122
22-
const props = defineProps<DefaultPropsType>()
23+
const props = withDefaults(defineProps<DefaultPropsType>(), {
24+
tableColorScaleGenerator: (value: number[]) => redColorScaleGenerator(value)
25+
})
2326
2427
providePivotData(props)
2528
</script>
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { computed, ComputedRef, inject, provide, InjectionKey } from 'vue'
22
import { getSort } from '@/helper'
33
import { DefaultPropsType } from '@/types'
4+
import { Locale } from '@/helper'
45

5-
type ProvideFilterBoxProps = Pick<DefaultPropsType,
6-
'languagePack' | 'locale' | 'sorters'> & {
7-
menuLimit: number
8-
}
6+
type ProvideFilterBoxProps = Pick<DefaultPropsType, 'sorters'> & {
7+
menuLimit: number
8+
languagePack: Record<string, Locale>
9+
locale: string
10+
}
911

1012
interface FilterBoxContext {
1113
localeStrings: ComputedRef<any>
@@ -15,9 +17,9 @@ interface FilterBoxContext {
1517

1618
const filterBoxKey = Symbol('filterBox') as InjectionKey<FilterBoxContext>
1719

18-
export function provideFilterBox (props: ProvideFilterBoxProps) {
20+
export function provideFilterBox(props: ProvideFilterBoxProps) {
1921
const localeStrings = computed(
20-
() => props.languagePack?.[props.locale || 'en']?.localeStrings
22+
() => props.languagePack[props.locale].localeStrings
2123
)
2224
const sorters = computed(() => props.sorters)
2325
const sorter = (x: string) => getSort(sorters.value, x)
@@ -29,6 +31,6 @@ export function provideFilterBox (props: ProvideFilterBoxProps) {
2931
})
3032
}
3133

32-
export function useProvideFilterBox () {
34+
export function useProvideFilterBox() {
3335
return inject(filterBoxKey)
3436
}

src/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { AggregatorTemplate } from '@/helper'
22
import { VNode } from 'vue'
3+
import { Locale } from '@/helper'
34

45
export interface DefaultPropsType {
56
data: any
@@ -11,7 +12,7 @@ export interface DefaultPropsType {
1112
renderers: Record<string, RendererDefinition>
1213
rendererName: string
1314
locale?: string
14-
languagePack?: Record<string, { localeStrings: Record<string, string> }>
15+
languagePack?: Record<string, Locale>
1516
showRowTotal?: boolean
1617
showColTotal?: boolean
1718
cols: string[]

0 commit comments

Comments
 (0)