forked from shesha-io/shesha-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformSettingsButton.tsx
More file actions
35 lines (31 loc) · 1.19 KB
/
formSettingsButton.tsx
File metadata and controls
35 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React, { FC, useState } from 'react';
import { Button } from 'antd';
import { FormSettingsEditor } from '../formSettingsEditor';
import { SettingOutlined } from '@ant-design/icons';
import { useFormDesignerStateSelector } from '@/providers/formDesigner';
import { SizeType } from 'antd/es/config-provider/SizeContext';
export interface IFormSettingsButtonProps {
buttonText?: string;
size?: SizeType;
}
export const FormSettingsButton: FC<IFormSettingsButtonProps> = ({ buttonText, size }) => {
const [settingsVisible, setSettingsVisible] = useState(false);
const readOnly = useFormDesignerStateSelector((x) => x.readOnly);
const onSettingsClick = () => {
setSettingsVisible(true);
};
return (
<>
<Button icon={<SettingOutlined />} size={size} type="link" onClick={onSettingsClick} title="Form Settings">
{ buttonText !== undefined ? buttonText : "Settings" }
</Button>
<FormSettingsEditor
readOnly={readOnly}
isVisible={settingsVisible}
close={() => {
setSettingsVisible(false);
}}
/>
</>
);
};