/**
 * Cascader 字段渲染策略
 */

import React from 'react';
import { Cascader } from 'antd';
import { BaseFieldStrategy } from './BaseFieldStrategy';
import type { FieldRenderContext } from '../IFieldRenderStrategy';

export class CascaderStrategy extends BaseFieldStrategy {
  supportsReadonly = false;

  render(context: FieldRenderContext): React.ReactNode {
    const { field, value, onChange, cascadeOptions, loadData } = context;
    const disabledProps = this.getDisabledProps(context);
    
    return (
      <Cascader
        style={{ width: '100%' }}
        placeholder={field.placeholder}
        {...disabledProps}
        options={cascadeOptions as any}
        value={value}
        onChange={onChange}
        loadData={loadData as any}
        changeOnSelect={field.dataSourceType === 'predefined'}
      />
    );
  }
}

