2021-06-09 03:21:49 +00:00
|
|
|
import { computed } from 'vue';
|
2021-06-26 01:35:40 +00:00
|
|
|
import type { Ref, InjectionKey, ComputedRef } from 'vue';
|
|
|
|
import { inject, provide } from 'vue';
|
2021-06-07 09:35:03 +00:00
|
|
|
|
|
|
|
export interface RowContext {
|
|
|
|
gutter: ComputedRef<[number, number]>;
|
|
|
|
wrap: ComputedRef<boolean>;
|
|
|
|
supportFlexGap: Ref<boolean>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const RowContextKey: InjectionKey<RowContext> = Symbol('rowContextKey');
|
|
|
|
|
|
|
|
const useProvideRow = (state: RowContext) => {
|
|
|
|
provide(RowContextKey, state);
|
|
|
|
};
|
|
|
|
|
|
|
|
const useInjectRow = () => {
|
2021-06-09 03:21:49 +00:00
|
|
|
return inject(RowContextKey, {
|
|
|
|
gutter: computed(() => undefined),
|
|
|
|
wrap: computed(() => undefined),
|
|
|
|
supportFlexGap: computed(() => undefined),
|
|
|
|
});
|
2021-06-07 09:35:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export { useInjectRow, useProvideRow };
|
|
|
|
export default useProvideRow;
|