chore: sunset scene api

This commit is contained in:
lawvs 2022-07-27 16:15:21 +08:00
parent 29d5a8c971
commit 3deabad74c
5 changed files with 14 additions and 61 deletions

View File

@ -27,7 +27,6 @@ export interface CreateView {
* @deprecated Use recast table instead * @deprecated Use recast table instead
*/ */
columnsFromId: string; columnsFromId: string;
scene: 'page' | 'kanban' | 'table' | 'whiteboard';
} }
export interface ChildrenView extends CreateView { export interface ChildrenView extends CreateView {

View File

@ -1,46 +0,0 @@
import { useCallback } from 'react';
import { useRecastBlock } from './Context';
import { RecastScene } from './types';
/**
* Get the recast table state
*
* /
* @public
* @deprecated Use the `useRecastView` or `useCurrentView` API
*/
export const useRecastBlockScene = () => {
const groupBlock = useRecastBlock();
const DEFAULT_SCENE = RecastScene.Page;
let maybeScene = groupBlock.getProperty('scene');
// TODO remove this
// Backward compatible
if (maybeScene && typeof maybeScene !== 'string') {
groupBlock.setProperty('scene', DEFAULT_SCENE);
maybeScene = DEFAULT_SCENE;
}
// End of backward compatible
const scene = maybeScene ?? DEFAULT_SCENE;
const setScene = useCallback(
(scene: RecastScene) => {
return groupBlock.setProperty('scene', scene);
},
[groupBlock]
);
const setPage = useCallback(() => setScene(RecastScene.Page), [setScene]);
const setTable = useCallback(() => setScene(RecastScene.Table), [setScene]);
const setKanban = useCallback(
() => setScene(RecastScene.Kanban),
[setScene]
);
return {
scene,
setScene,
setPage,
setTable,
setKanban,
};
};

View File

@ -4,7 +4,6 @@ import {
useSelectProperty, useSelectProperty,
genSelectOptionId, genSelectOptionId,
} from './property'; } from './property';
import { useRecastBlockScene } from './Scene';
export * from './types'; export * from './types';
export { export {
RecastBlockProvider, RecastBlockProvider,
@ -14,7 +13,6 @@ export {
export { export {
getRecastItemValue, getRecastItemValue,
useRecastBlockScene,
useRecastBlockMeta, useRecastBlockMeta,
useSelectProperty, useSelectProperty,
genSelectOptionId, genSelectOptionId,

View File

@ -2,9 +2,5 @@
export const META_PROPERTIES_KEY = 'metaProps' as const; export const META_PROPERTIES_KEY = 'metaProps' as const;
export const TABLE_VALUES_KEY = 'recastValues' as const; export const TABLE_VALUES_KEY = 'recastValues' as const;
/**
* @deprecated Use {@link META_VIEWS_KEY} instead.
*/
export const KANBAN_PROPERTIES_KEY = 'kanbanProps' as const;
export const META_VIEWS_KEY = 'recastViews' as const; export const META_VIEWS_KEY = 'recastViews' as const;
export const META_CURRENT_VIEW_ID_KEY = 'recastCurrentViewId' as const; export const META_CURRENT_VIEW_ID_KEY = 'recastCurrentViewId' as const;

View File

@ -1,11 +1,10 @@
import { CSSProperties } from 'react'; import { CSSProperties } from 'react';
import { import {
KANBAN_PROPERTIES_KEY,
META_CURRENT_VIEW_ID_KEY, META_CURRENT_VIEW_ID_KEY,
META_PROPERTIES_KEY, META_PROPERTIES_KEY,
META_VIEWS_KEY, META_VIEWS_KEY,
} from './constant'; } from './constant';
import { RecastScene, RecastView, RecastViewId } from './view'; import { RecastView, RecastViewId } from './view';
// --------------------------------------------------- // ---------------------------------------------------
// Property // Property
@ -108,16 +107,23 @@ export type RecastMetaProperty =
| InformationProperty; | InformationProperty;
/** /**
* @deprecated Use {@link RecastView} * @deprecated Use {@link META_VIEWS_KEY} instead.
*/ */
export type RecastKanbanProperty = { const KANBAN_PROPERTIES_KEY = 'kanbanProps' as const;
groupBy: RecastPropertyId;
};
export type RecastDataProperties = Partial<{ export type RecastDataProperties = Partial<{
scene: RecastScene; /**
* PLEASE DO NOT USE IT
* @deprecated Use {@link RecastView} instead
*/
scene?: undefined;
/**
* PLEASE DO NOT USE IT
* @deprecated Use {@link RecastView} instead
*/
[KANBAN_PROPERTIES_KEY]?: undefined;
[META_PROPERTIES_KEY]: RecastMetaProperty[]; [META_PROPERTIES_KEY]: RecastMetaProperty[];
[META_VIEWS_KEY]: RecastView[]; [META_VIEWS_KEY]: RecastView[];
[META_CURRENT_VIEW_ID_KEY]: RecastViewId; [META_CURRENT_VIEW_ID_KEY]: RecastViewId;
[KANBAN_PROPERTIES_KEY]: RecastKanbanProperty;
}>; }>;