Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update Richontainer #528

Merged
merged 6 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gi-assets-basic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/gi-assets-basic",
"version": "2.4.20",
"version": "2.4.23",
"description": "G6VP 基础资产包",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Handler } from '@antv/gi-common-components';
import { Icon, useContainer, useContext, utils } from '@antv/gi-sdk';
import { Icon, useContainer, useContext } from '@antv/gi-sdk';
import { Button, Divider, Segmented, Select, Space } from 'antd';
import { Resizable } from 're-resizable';
import React, { memo, useEffect, useState } from 'react';
import $i18n from '../../i18n';
import Header from './Header';
import Toolbar from './Toolbar';
import './index.less';

const URL_SEARCH_KEY = 'ActiveAssetID';
const visibleStyle: React.CSSProperties = {
visibility: 'visible',
Expand Down Expand Up @@ -34,7 +35,7 @@ const RichContainer = props => {
const { HAS_GRAPH, GISDK_ID } = context;
const Containers = useContainer(context);
const [state, setState] = React.useState<RichContainerState>({
activeKey: utils.searchParamOf(URL_SEARCH_KEY) || 'LanguageQuery',
activeKey: localStorage.getItem(URL_SEARCH_KEY) || 'LanguageQuery',
viewMode: 'GISDK_CANVAS',
});
const { activeKey, viewMode } = state;
Expand All @@ -60,15 +61,24 @@ const RichContainer = props => {
} else setWidth(0);
}, [isExpanded]);

useEffect(()=>{
if (localStorage.getItem(URL_SEARCH_KEY)) {
setState(preState => {
return {
...preState,
activeKey: localStorage.getItem(URL_SEARCH_KEY) as string,
};
});
}
},[localStorage.getItem(URL_SEARCH_KEY)])

const toggleClick = () => {
setIsExpanded(prev => !prev);
};
const [NavbarLeftArea, NavbarRightArea, ViewArea, DataArea, FilterArea, StylingArea, CanvasArea] = Containers;
const [ NavbarLeftArea, NavbarRightArea, ViewArea, DataArea, FilterArea, StylingArea, CanvasArea, ConditionArea, TimeBarArea] = Containers;

const handleChange = id => {
const { searchParams, path } = utils.getSearchParams(window.location);
searchParams.set(URL_SEARCH_KEY, id);
// window.location.hash = `${path}?${searchParams.toString()}`;
localStorage.setItem(URL_SEARCH_KEY, id)

setState(preState => {
return {
Expand All @@ -90,6 +100,7 @@ const RichContainer = props => {
};
});
};

const DATA_QUERY_ID = DataArea.components.map(item => item.id);
const DATA_FILTER_ID = FilterArea.components.map(item => item.id);
const DATA_QUERY_OPTIONS = DataArea.components.map(item => {
Expand All @@ -102,6 +113,7 @@ const RichContainer = props => {
});
const HAS_QUERY_VIEW = DATA_QUERY_ID.indexOf(activeKey) !== -1;
const HAS_FILTER_VIEW = DATA_FILTER_ID.indexOf(activeKey) !== -1;


const onResizeStart = () => {
setIsResizing(true);
Expand Down Expand Up @@ -263,7 +275,7 @@ const RichContainer = props => {
<Segmented block value={activeKey} options={DATA_FILTER_OPTIONS} onChange={handleChange} />
)}

{[...DataArea.components, ...FilterArea.components, ...StylingArea.components].map(item => {
{[...DataArea.components, ...FilterArea.components, ...StylingArea.components, ...ConditionArea.components].map(item => {
const isActive = activeKey === item.id;
return (
<div key={item.id} style={{ display: isActive ? 'block' : 'none' }}>
Expand All @@ -290,6 +302,13 @@ const RichContainer = props => {
}}
>
{children}
<div className='gi-rich-container-timebar' style={{ position: 'absolute', bottom: 0, width: `calc(100vw - ${width}px)` }}>
{TimeBarArea.components.map(item => {
return (
<item.component key={item.id} {...item.props} />
);
})}
</div>
</div>
</div>
{ViewArea.components.map(item => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,50 @@ const registerMeta = context => {
default: [],
},
},
{
id: 'condition-content',
name:'条件展示容器',
required: true,
GI_CONTAINER: {
title: $i18n.get({ id: 'basic.components.RichContainer.registerMeta.IntegratedComponents', dm: '集成组件' }),
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {
mode: 'multiple',
},
enum: GIAC_CONTENT_ITEMS,
default: [],
},
},
{
id: 'timebar-container-bottom',
name: $i18n.get({ id: 'basic.components.RichContainer.registerMeta.BottomContainer', dm: '底部时序容器' }),
required: true,
GI_CONTAINER: {
title: $i18n.get({ id: 'basic.components.RichContainer.registerMeta.BottomAssembly', dm: '顶部时序组件' }),
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {},
enum: GIAC_CONTENT_ITEMS,
default: [],
},
height: {
type: 'number',
title: $i18n.get({ id: 'basic.components.RichContainer.registerMeta.BottomHeight', dm: '容器高度' }),
'x-component': 'NumberPicker',
'x-decorator': 'FormItem',
default: 150,
},
padding: {
type: 'string',
title: $i18n.get({ id: 'basic.components.RichContainer.registerMeta.InternalSpacing', dm: '内部间距' }),
'x-component': 'Input',
'x-decorator': 'FormItem',
default: '0px 0px',
},
},
],
isSheet: {
title: '多页签',
Expand Down
Loading