import { use } from '../utils'; import { emit, inherit } from '../utils/functional'; import Button from '../button'; import RadioGroup from '../radio-group'; import AddressItem from './Item'; const [sfc, bem, t] = use('address-list'); function AddressList(h, props, slots, ctx) { const getList = (list, disabled) => list.map((item, index) => ( { emit(ctx, disabled ? 'select-disabled' : 'select', item, index); }} onEdit={() => { emit(ctx, disabled ? 'edit-disabled' : 'edit', item, index); }} /> )); const List = getList(props.list); const DisabledList = getList(props.disabledList, true); return (
{slots.top && slots.top()} { emit(ctx, 'input', event); }} > {List} {props.disabledText && (
{props.disabledText}
)} {DisabledList} {slots.default && slots.default()}
); } AddressList.props = { list: Array, disabledList: Array, disabledText: String, addButtonText: String, value: [String, Number], switchable: { type: Boolean, default: true } }; export default sfc(AddressList);