Skip to content

Commit

Permalink
refactor: 重命名 base sheet props, emits 类型定义
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo committed May 16, 2022
1 parent fa256ad commit 59f2d4c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions packages/s2-vue/src/hooks/useEvents.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { S2Event, type SpreadSheet, getBaseCellData, GEvent } from '@antv/s2';
import { onMounted, type Ref } from 'vue';
import type { BaseSheetInitEmits, EmitFn } from './../interface';
import type { BaseSheetEmits, EmitFn } from './../interface';

const useCellEvent = (
s2Ref: Ref<SpreadSheet | undefined>,
emit: EmitFn<BaseSheetInitEmits>,
emit: EmitFn<BaseSheetEmits>,
eventName: S2Event,
emitName: keyof BaseSheetInitEmits,
emitName: keyof BaseSheetEmits,
) => {
const handler = (event: GEvent) => {
const param = getBaseCellData(event);
Expand All @@ -17,9 +17,9 @@ const useCellEvent = (

const useS2Event = (
s2Ref: Ref<SpreadSheet | undefined>,
emit: EmitFn<BaseSheetInitEmits>,
emit: EmitFn<BaseSheetEmits>,
eventName: S2Event,
emitName: keyof BaseSheetInitEmits,
emitName: keyof BaseSheetEmits,
) => {
const handler = (params: any) => {
emit(emitName as any, params);
Expand All @@ -29,7 +29,7 @@ const useS2Event = (

export const useEvents = (
s2Ref: Ref<SpreadSheet | undefined>,
emit: EmitFn<BaseSheetInitEmits>,
emit: EmitFn<BaseSheetEmits>,
) => {
onMounted(() => {
if (!s2Ref.value) {
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-vue/src/hooks/useSpreadSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type SpreadSheet,
} from '@antv/s2';
import { onBeforeUnmount, onMounted, ref, shallowRef, toRaw } from 'vue';
import type { BaseSheetInitEmits, EmitFn } from '../interface';
import type { BaseSheetEmits, EmitFn } from '../interface';
import type { BaseSheetProps } from '../utils/initPropAndEmits';
import { getSheetComponentOptions } from '../utils/options';
import { usePagination } from './usePagination';
Expand All @@ -17,7 +17,7 @@ import { useResize } from './useResize';

export function useSpreadSheet(
props: BaseSheetProps,
emit: EmitFn<BaseSheetInitEmits>,
emit: EmitFn<BaseSheetEmits>,
) {
const {
dataCfg,
Expand Down
8 changes: 4 additions & 4 deletions packages/s2-vue/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type GetInitEmits<T> = {
/* 组件类型 */
/* -------------------------------------------------------------------------- */

export type BaseSheetInitPropKeys = GetPropKeys<BaseSheetComponentProps>;
export type BaseSheetInitEmitKeys = GetEmitKeys<BaseSheetComponentProps>;
export type BaseSheetInitProps = GetInitProps<BaseSheetComponentProps>;
export type BaseSheetInitEmits = GetInitEmits<BaseSheetComponentProps>;
export type BaseSheetPropKeys = GetPropKeys<BaseSheetComponentProps>;
export type BaseSheetEmitKeys = GetEmitKeys<BaseSheetComponentProps>;

export type BaseSheetEmits = GetInitEmits<BaseSheetComponentProps>;
6 changes: 3 additions & 3 deletions packages/s2-vue/src/utils/initPropAndEmits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
SheetType,
} from '@antv/s2-shared';
import type { ExtractPropTypes, PropType } from 'vue';
import type { BaseSheetInitEmitKeys, BaseSheetInitEmits } from './../interface';
import type { BaseSheetEmitKeys, BaseSheetEmits } from './../interface';

export const initBaseSheetProps = () => ({
sheetType: String as PropType<SheetType>,
Expand Down Expand Up @@ -40,7 +40,7 @@ export type BaseSheetProps = ExtractPropTypes<

export const initBaseSheetEmits = () => {
/** base sheet all emits */
const keys: Array<BaseSheetInitEmitKeys> = [
const keys: Array<BaseSheetEmitKeys> = [
'spreadsheet',
'getSpreadSheet',
// ============== Row Cell ====================
Expand Down Expand Up @@ -130,5 +130,5 @@ export const initBaseSheetEmits = () => {
'reset',
'linkFieldJump',
];
return keys as unknown as BaseSheetInitEmits;
return keys as unknown as BaseSheetEmits;
};

0 comments on commit 59f2d4c

Please sign in to comment.