import { INDEX, ReactList } from '@jswork/react-list'; import { Radio, RadioGroupProps } from 'antd'; import cx from 'classnames'; import React, { HTMLAttributes } from 'react'; import { radioKv } from '../tpls/kv'; import type { StdCallback, TemplateCallback } from './types'; const CLASS_NAME = 'ac-radio-group'; export type AcRadioGroupProps = { className?: string; value?: any; defaultValue?: any; items?: any[]; onChange?: StdCallback; onSearch?: StdCallback; template?: TemplateCallback; templateOptions?: any; buttonStyle?: 'solid' | 'outline'; } & RadioGroupProps & HTMLAttributes; export class AcRadioGroup extends React.Component { static displayName = CLASS_NAME; static formSchema = CLASS_NAME; static defaultProps = { items: [], template: radioKv, }; get templateCallback() { const { template, templateOptions } = this.props; return (item) => template!(item, templateOptions); } state = { value: this.props.value }; static getDerivedStateFromProps(inProps: Readonly, inState: any) { const { value } = inProps; if (value !== inState.value) return { value }; return null; } handleChange = (inEvent) => { const { onChange, onSearch } = this.props; const { value } = inEvent.target; const target = { value }; this.setState(target); onChange?.({ target }); onSearch?.({ target }); }; render() { const { className, items, template, templateOptions, onChange, onSearch, ...props } = this.props; return ( ); } } export const AcRadioGroupFc = (props: AcRadioGroupProps) => { return ; };