mirror of
https://github.com/MrXujiang/h5-Dooring.git
synced 2025-12-11 17:32:50 +00:00
fix : popover flash move bug
This commit is contained in:
parent
f37db4691a
commit
03727a7239
@ -83,6 +83,7 @@
|
|||||||
"umi": "^3.2.19",
|
"umi": "^3.2.19",
|
||||||
"video-react": "^0.14.1",
|
"video-react": "^0.14.1",
|
||||||
"xlsx": "^0.16.7",
|
"xlsx": "^0.16.7",
|
||||||
|
"yh-react-popover": "^0.2.0",
|
||||||
"yorkie": "^2.0.0",
|
"yorkie": "^2.0.0",
|
||||||
"zarm": "^2.5.1"
|
"zarm": "^2.5.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { memo, useEffect } from 'react';
|
import React, { memo, RefObject, useEffect } from 'react';
|
||||||
import { Form, Select, InputNumber, Input, Switch, Radio, Button } from 'antd';
|
import { Form, Select, InputNumber, Input, Switch, Radio, Button } from 'antd';
|
||||||
import Upload from '../Upload';
|
import Upload from '../Upload';
|
||||||
import DataList from '../DataList';
|
import DataList from '../DataList';
|
||||||
@ -33,10 +33,11 @@ interface FormEditorProps {
|
|||||||
onDel: Function;
|
onDel: Function;
|
||||||
defaultValue: { [key: string]: any };
|
defaultValue: { [key: string]: any };
|
||||||
config: Array<any>;
|
config: Array<any>;
|
||||||
|
rightPannelRef: RefObject<HTMLDivElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormEditor = (props: FormEditorProps) => {
|
const FormEditor = (props: FormEditorProps) => {
|
||||||
const { config, defaultValue, onSave, onDel, uid } = props;
|
const { config, defaultValue, onSave, onDel, uid, rightPannelRef } = props;
|
||||||
const onFinish = (values: Store) => {
|
const onFinish = (values: Store) => {
|
||||||
onSave && onSave(values);
|
onSave && onSave(values);
|
||||||
};
|
};
|
||||||
@ -157,7 +158,7 @@ const FormEditor = (props: FormEditorProps) => {
|
|||||||
)}
|
)}
|
||||||
{item.type === 'FormItems' && (
|
{item.type === 'FormItems' && (
|
||||||
<Form.Item name={item.key} valuePropName="formList">
|
<Form.Item name={item.key} valuePropName="formList">
|
||||||
<FormItems data={item.data} />
|
<FormItems data={item.data} rightPannelRef={rightPannelRef} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { memo, useState } from 'react';
|
import React, { memo, RefObject, useCallback, useEffect, useState } from 'react';
|
||||||
import BaseForm from '../../BasicShop/BasicComponents/Form/BaseForm';
|
import BaseForm from '../../BasicShop/BasicComponents/Form/BaseForm';
|
||||||
import BasePopoverForm from '../../BasicShop/BasicComponents/Form/BasePopoverForm';
|
import BasePopoverForm from '../../BasicShop/BasicComponents/Form/BasePopoverForm';
|
||||||
import EditorModal from './EditorModal';
|
import EditorModal from './EditorModal';
|
||||||
@ -6,8 +6,8 @@ import { MinusCircleFilled, EditFilled, PlusOutlined } from '@ant-design/icons';
|
|||||||
import styles from './formItems.less';
|
import styles from './formItems.less';
|
||||||
import { baseFormUnion, TFormItemsDefaultType } from '../FormEditor/types';
|
import { baseFormUnion, TFormItemsDefaultType } from '../FormEditor/types';
|
||||||
import { uuid } from '@/utils/tool';
|
import { uuid } from '@/utils/tool';
|
||||||
import { Button, Popover } from 'antd';
|
import { Button } from 'antd';
|
||||||
|
import MyPopover from 'yh-react-popover';
|
||||||
// import { Popconfirm } from 'antd';
|
// import { Popconfirm } from 'antd';
|
||||||
|
|
||||||
const formTpl: TFormItemsDefaultType = [
|
const formTpl: TFormItemsDefaultType = [
|
||||||
@ -60,24 +60,27 @@ interface FormItemsProps {
|
|||||||
formList?: TFormItemsDefaultType;
|
formList?: TFormItemsDefaultType;
|
||||||
onChange?: (v: TFormItemsDefaultType) => void;
|
onChange?: (v: TFormItemsDefaultType) => void;
|
||||||
data: any;
|
data: any;
|
||||||
|
rightPannelRef: RefObject<HTMLDivElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormItems = (props: FormItemsProps) => {
|
const FormItems = (props: FormItemsProps) => {
|
||||||
const { formList, onChange } = props;
|
const { formList, onChange, rightPannelRef } = props;
|
||||||
const [formData, setFormData] = useState<TFormItemsDefaultType>(formList || []);
|
const [formData, setFormData] = useState<TFormItemsDefaultType>(formList || []);
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [curItem, setCurItem] = useState<baseFormUnion>();
|
const [curItem, setCurItem] = useState<baseFormUnion>();
|
||||||
const [isFormTplVisible, setFormTplVisible] = useState(false);
|
const [force, setforce] = useState<{ force: Function }>({
|
||||||
|
force: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
const handleAddItem = (item: baseFormUnion) => {
|
const handleAddItem = (item: baseFormUnion) => {
|
||||||
let tpl = formTpl.find(v => v.type === item.type);
|
let tpl = formTpl.find(v => v.type === item.type);
|
||||||
let newData = [...formData, { ...tpl!, id: uuid(6, 10) }];
|
let newData = [...formData, { ...tpl!, id: uuid(6, 10) }];
|
||||||
setFormData(newData);
|
setFormData(newData);
|
||||||
onChange && onChange(newData);
|
onChange && onChange(newData);
|
||||||
|
force.force();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditItem = (item: baseFormUnion) => {
|
const handleEditItem = (item: baseFormUnion) => {
|
||||||
console.log(item);
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
setCurItem(item);
|
setCurItem(item);
|
||||||
};
|
};
|
||||||
@ -94,9 +97,28 @@ const FormItems = (props: FormItemsProps) => {
|
|||||||
onChange && onChange(newData);
|
onChange && onChange(newData);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
};
|
};
|
||||||
const handleVisibleChange = (visible: boolean) => {
|
|
||||||
setFormTplVisible(visible);
|
const callback = useCallback((v: Function) => {
|
||||||
};
|
console.log(v);
|
||||||
|
setforce({ force: v });
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let listenner: (e: Event) => void;
|
||||||
|
if (rightPannelRef.current) {
|
||||||
|
listenner = () => {
|
||||||
|
force.force();
|
||||||
|
};
|
||||||
|
rightPannelRef.current.addEventListener('scroll', listenner);
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
if (rightPannelRef.current) {
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
rightPannelRef.current.removeEventListener('scroll', listenner);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [force, rightPannelRef]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.formItemWrap}>
|
<div className={styles.formItemWrap}>
|
||||||
<div className={styles.formTitle}>表单控件</div>
|
<div className={styles.formTitle}>表单控件</div>
|
||||||
@ -122,7 +144,7 @@ const FormItems = (props: FormItemsProps) => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<div className={styles.formAddWrap}>
|
<div className={styles.formAddWrap}>
|
||||||
<Popover
|
<MyPopover
|
||||||
content={
|
content={
|
||||||
<>
|
<>
|
||||||
<div className={styles.formTpl} style={{ color: 'red' }}>
|
<div className={styles.formTpl} style={{ color: 'red' }}>
|
||||||
@ -148,19 +170,15 @@ const FormItems = (props: FormItemsProps) => {
|
|||||||
{/* <a style={{color: 'red'}} onClick={() => setFormTplVisible(false)}>Close</a> */}
|
{/* <a style={{color: 'red'}} onClick={() => setFormTplVisible(false)}>Close</a> */}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
color="#4A4A4A"
|
directions={'LB'}
|
||||||
overlayStyle={{ width: '200px' }}
|
innerConstDomStyle={{ display: 'block' }}
|
||||||
// title="表单模板"
|
constDomStyle={{ display: 'block' }}
|
||||||
trigger="click"
|
callback={callback}
|
||||||
placement="left"
|
|
||||||
visible={isFormTplVisible}
|
|
||||||
autoAdjustOverflow
|
|
||||||
onVisibleChange={handleVisibleChange}
|
|
||||||
>
|
>
|
||||||
<Button block icon={<PlusOutlined />}>
|
<Button style={{ width: '100%' }} block icon={<PlusOutlined />}>
|
||||||
添加
|
添加
|
||||||
</Button>
|
</Button>
|
||||||
</Popover>
|
</MyPopover>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -223,11 +223,12 @@ const Container = (props: {
|
|||||||
// ratioSpeed: { x: 1.2, y: 1.2 },
|
// ratioSpeed: { x: 1.2, y: 1.2 },
|
||||||
// intervalDelay: 5,
|
// intervalDelay: 5,
|
||||||
// });
|
// });
|
||||||
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const renderRight = useMemo(() => {
|
const renderRight = useMemo(() => {
|
||||||
if (context.theme === 'h5') {
|
if (context.theme === 'h5') {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
ref={ref}
|
||||||
className={styles.attrSetting}
|
className={styles.attrSetting}
|
||||||
style={{
|
style={{
|
||||||
transition: 'all ease-in-out 0.5s',
|
transition: 'all ease-in-out 0.5s',
|
||||||
@ -243,6 +244,7 @@ const Container = (props: {
|
|||||||
defaultValue={curPoint.item.config}
|
defaultValue={curPoint.item.config}
|
||||||
onSave={handleFormSave}
|
onSave={handleFormSave}
|
||||||
onDel={handleDel}
|
onDel={handleDel}
|
||||||
|
rightPannelRef={ref}
|
||||||
/>
|
/>
|
||||||
{/* <div className={styles.del}>
|
{/* <div className={styles.del}>
|
||||||
<Button block>删顶顶顶顶除</Button>
|
<Button block>删顶顶顶顶除</Button>
|
||||||
@ -277,6 +279,7 @@ const Container = (props: {
|
|||||||
defaultValue={curPoint.item.config}
|
defaultValue={curPoint.item.config}
|
||||||
onSave={handleFormSave}
|
onSave={handleFormSave}
|
||||||
onDel={handleDel}
|
onDel={handleDel}
|
||||||
|
rightPannelRef={ref}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useRef, memo, useContext, useState, useEffect } from 'react';
|
import React, { useRef, memo, useContext, useState, useEffect } from 'react';
|
||||||
import { Button, Input, Popover, Modal, Select } from 'antd';
|
import { Button, Input, Modal, Select } from 'antd';
|
||||||
import {
|
import {
|
||||||
ArrowLeftOutlined,
|
ArrowLeftOutlined,
|
||||||
MobileOutlined,
|
MobileOutlined,
|
||||||
@ -19,6 +19,7 @@ import req from '@/utils/req';
|
|||||||
import Code from '@/assets/code.png';
|
import Code from '@/assets/code.png';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
import { dooringContext } from '@/layouts';
|
import { dooringContext } from '@/layouts';
|
||||||
|
import MyPopover from 'yh-react-popover';
|
||||||
|
|
||||||
const { confirm } = Modal;
|
const { confirm } = Modal;
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ const HeaderComponent = memo((props: HeaderComponentProps) => {
|
|||||||
>
|
>
|
||||||
<FileAddOutlined />
|
<FileAddOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
<Popover placement="bottom" title={null} content={content} trigger="click">
|
<MyPopover content={content()} directions="BOTTOM">
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
style={{ marginRight: '9px' }}
|
style={{ marginRight: '9px' }}
|
||||||
@ -225,7 +226,7 @@ const HeaderComponent = memo((props: HeaderComponentProps) => {
|
|||||||
>
|
>
|
||||||
<MobileOutlined />
|
<MobileOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
</Popover>
|
</MyPopover>
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
style={{ marginRight: '9px' }}
|
style={{ marginRight: '9px' }}
|
||||||
|
|||||||
@ -14691,6 +14691,11 @@ yeast@0.1.2:
|
|||||||
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
|
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
|
||||||
integrity sha1-AI4G2AlDIMNy28L47XagymyKxBk=
|
integrity sha1-AI4G2AlDIMNy28L47XagymyKxBk=
|
||||||
|
|
||||||
|
yh-react-popover@^0.2.0:
|
||||||
|
version "0.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/yh-react-popover/-/yh-react-popover-0.2.0.tgz#a5e3bdaa50b5e7e119bf0ce38a24bea57068cfc4"
|
||||||
|
integrity sha512-cTH2huOrUvsbyhvH0iTE+S/Lu7dOpxuF8upyNP4GCsCN8IzQXLvlbxZl8395wOwa6Xm5+kT7QvZw+wI3vA8q8Q==
|
||||||
|
|
||||||
ylru@^1.2.0:
|
ylru@^1.2.0:
|
||||||
version "1.2.1"
|
version "1.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/ylru/-/ylru-1.2.1.tgz#f576b63341547989c1de7ba288760923b27fe84f"
|
resolved "https://registry.yarnpkg.com/ylru/-/ylru-1.2.1.tgz#f576b63341547989c1de7ba288760923b27fe84f"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user