-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Zheng-Changfu/dev
Dev
- Loading branch information
Showing
41 changed files
with
601 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export function nilOrEmptyStringToNull(value: any) { | ||
value = value ?? null | ||
return value === '' ? null : value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { InjectionKey } from 'vue' | ||
|
||
/** | ||
* copy from naive | ||
*/ | ||
export function createInjectionKey<T>(key: string): InjectionKey<T> { | ||
return key as any | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,35 @@ | ||
import type { InjectionKey } from 'vue' | ||
import type { ProConfigProviderExtendProps } from './props' | ||
import { inject, provide, ref } from 'vue' | ||
import type { MaybeRef, VNodeChild } from 'vue' | ||
import type { PlainComponentValueTransform } from '../plains' | ||
import { inject, provide } from 'vue' | ||
import { createInjectionKey } from '../composables/createInjectionKey' | ||
|
||
const globalConfigContextKey = Symbol('globalConfig') as InjectionKey<ProConfigProviderExtendProps> | ||
export type WrappedIn = 'form' | 'data-table' | 'edit-data-table' | '' | ||
|
||
export function provideGlobalConfig(config: ProConfigProviderExtendProps) { | ||
provide(globalConfigContextKey, config) | ||
interface GlobalConfig { | ||
mergedEmpty: (wrappedIn: WrappedIn) => VNodeChild | ||
mergedPropOverrides: MaybeRef<Record<string, object>> | ||
mergedPlainComponentValueTransform: PlainComponentValueTransform | ||
} | ||
|
||
const wrappedInInjectionKey = createInjectionKey<WrappedIn>('wrapped-in') | ||
const globalConfigInjectionKey = createInjectionKey<GlobalConfig>('global-config') | ||
|
||
export function provideGlobalConfig(config: GlobalConfig) { | ||
provide(globalConfigInjectionKey, config) | ||
} | ||
|
||
export function provideWrappedIn(wrappedIn: WrappedIn) { | ||
return provide(wrappedInInjectionKey, wrappedIn) | ||
} | ||
|
||
export function useInjectWrappedIn() { | ||
return inject(wrappedInInjectionKey, '') | ||
} | ||
|
||
export function useInjectGlobalConfig() { | ||
return inject(globalConfigContextKey, () => { | ||
return { | ||
propOverrides: ref({}), | ||
} | ||
}) as any as Required<ProConfigProviderExtendProps> | ||
return inject(globalConfigInjectionKey, { | ||
mergedEmpty: () => '-', | ||
mergedPropOverrides: {}, | ||
mergedPlainComponentValueTransform: {}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import type { InjectionKey, MaybeRef } from 'vue' | ||
import type { MaybeRef } from 'vue' | ||
import type { ProFormListInst } from './inst' | ||
import { inject, provide } from 'vue' | ||
import { createInjectionKey } from '../composables/createInjectionKey' | ||
|
||
export const proFormListInstContextKey = Symbol('proFormListInst') as InjectionKey<ProFormListInst> | ||
export const proFormListContextKey = Symbol('proFormListContext') as InjectionKey<{ | ||
export const proFormListConfigInjectionKey = createInjectionKey<{ | ||
showLabel: MaybeRef<boolean | undefined> | ||
}> | ||
}>('pro-form-list-config') | ||
|
||
export const proFormListInstInjectionKey = createInjectionKey<ProFormListInst>('pro-form-list') | ||
|
||
export function provideProFormListInst(inst: ProFormListInst) { | ||
provide(proFormListInstContextKey, inst) | ||
provide(proFormListInstInjectionKey, inst) | ||
} | ||
|
||
export function useInjectProFormListInst() { | ||
return inject(proFormListInstContextKey)! | ||
return inject(proFormListInstInjectionKey)! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.