@sqrzro/ui 4.0.0-alpha.66 → 4.0.0-alpha.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,6 +2,7 @@ import type { EditableFormFieldComponentProps } from '../../interfaces';
|
|
|
2
2
|
import type { ColorInputComponentProps } from '../ColorInput';
|
|
3
3
|
import type { DropdownComponentProps } from '../Dropdown';
|
|
4
4
|
import type { ImageInputComponentProps } from '../ImageInput';
|
|
5
|
+
import type { SwitchComponentProps } from '../Switch';
|
|
5
6
|
import type { TextAreaComponentProps } from '../TextArea';
|
|
6
7
|
import type { TextInputComponentProps } from '../TextInput';
|
|
7
8
|
export type EditableColorFormFieldProps = EditableFormFieldComponentProps<string | undefined> & ColorInputComponentProps;
|
|
@@ -10,6 +11,8 @@ export type EditableDropdownFormFieldProps<T> = EditableFormFieldComponentProps<
|
|
|
10
11
|
export declare function EditableDropdownFormField<T>(props: Readonly<EditableDropdownFormFieldProps<T>>): React.ReactElement;
|
|
11
12
|
export type EditableImageFormFieldProps = EditableFormFieldComponentProps<string | null> & ImageInputComponentProps;
|
|
12
13
|
export declare function EditableImageFormField(props: Readonly<EditableImageFormFieldProps>): React.ReactElement;
|
|
14
|
+
export type EditableSwitchFormFieldProps = EditableFormFieldComponentProps<boolean> & SwitchComponentProps;
|
|
15
|
+
export declare function EditableSwitchFormField(props: Readonly<EditableSwitchFormFieldProps>): React.ReactElement;
|
|
13
16
|
export type EditableTextAreaFormFieldProps = EditableFormFieldComponentProps<string> & TextAreaComponentProps;
|
|
14
17
|
export declare function EditableTextAreaFormField(props: Readonly<EditableTextAreaFormFieldProps>): React.ReactElement;
|
|
15
18
|
export type EditableTextFormFieldProps = EditableFormFieldComponentProps<string> & TextInputComponentProps;
|
|
@@ -5,8 +5,9 @@ import tw from '../../../styles/classnames/utility/tw';
|
|
|
5
5
|
import extractEditableInputProps from '../../utility/extract-editable-input-props';
|
|
6
6
|
import ColorInput from '../ColorInput';
|
|
7
7
|
import Dropdown from '../Dropdown';
|
|
8
|
-
import ImageInput from '../ImageInput';
|
|
9
8
|
import EditableFormField from '../EditableFormField';
|
|
9
|
+
import ImageInput from '../ImageInput';
|
|
10
|
+
import Switch from '../Switch';
|
|
10
11
|
import TextArea from '../TextArea';
|
|
11
12
|
import TextInput from '../TextInput';
|
|
12
13
|
export function EditableColorFormField(props) {
|
|
@@ -42,6 +43,14 @@ export function EditableImageFormField(props) {
|
|
|
42
43
|
}, [fieldProps.value]);
|
|
43
44
|
return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
|
|
44
45
|
}
|
|
46
|
+
export function EditableSwitchFormField(props) {
|
|
47
|
+
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
48
|
+
const renderInput = useCallback((renderProps) => (_jsx(Switch, { ...renderProps, ...inputProps, label: null })), [inputProps]);
|
|
49
|
+
const renderValue = useCallback((value) => {
|
|
50
|
+
return _jsx("div", { children: value ? 'Yes' : 'No' });
|
|
51
|
+
}, [inputProps]);
|
|
52
|
+
return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
|
|
53
|
+
}
|
|
45
54
|
export function EditableTextAreaFormField(props) {
|
|
46
55
|
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
47
56
|
const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
|