chore: image custom params

This commit is contained in:
jialin
2024-11-27 17:07:22 +08:00
parent ba76498acc
commit 230120fff5
19 changed files with 473 additions and 206 deletions
@@ -0,0 +1,19 @@
import { Slider } from 'antd';
import SealInput from '../seal-input';
import SealSelect from '../seal-select';
const components: {
InputNumber: typeof SealInput.Number;
Select: typeof SealSelect;
Slider: React.ComponentType<typeof Slider>;
TextArea: typeof SealInput.TextArea;
Input: typeof SealInput.Input;
} = {
InputNumber: SealInput.Number,
Select: SealSelect,
Slider: Slider as React.ComponentType<typeof Slider>,
TextArea: SealInput.TextArea,
Input: SealInput.Input
};
export default components;
@@ -0,0 +1,19 @@
import { ParamsSchema } from '@/pages/playground/config/types';
import { useIntl } from '@umijs/max';
import React from 'react';
import componentsMap from './config/components';
const FieldComponent: React.FC<ParamsSchema> = (props) => {
const intl = useIntl();
const { type, label, attrs, style, ...rest } = props;
return React.createElement(componentsMap[type], {
...rest,
...attrs,
style: { ...style, width: '100%' },
label: label.isLocalized
? intl.formatMessage({ id: label.text })
: label.text
});
};
export default React.memo(FieldComponent);