import {computed, designComponent} from "@peryl/react-compose"; import {createPlcPropOptions, PlcEmitsOptions} from "../Table/plc/utils/plc.utils"; import {PlcScopeSlotsOptions} from "../Table/plc/utils/plc.scope-slots"; import {usePlc} from "../Table/plc/use/usePlc"; import _Object from "../Object"; import {pick} from "@peryl/utils/pick"; import {ObjectPropsOption} from "../Object/object.utils"; import {iFilterConfigObject} from "../FilterService/filter/fitler.object"; export const PlcObject = designComponent({ name: 'plc-object', props: { ...createPlcPropOptions({ filterType: 'object', filterHandler: 'like' }), ...pick(ObjectPropsOption, ['option', 'labelField', 'keyField', 'map']), }, emits: PlcEmitsOptions, scopeSlots: PlcScopeSlotsOptions, setup({ props, scopeSlots, slots, event }) { const filterConfig = computed((): iFilterConfigObject => { return { option: props.option, labelField: props.labelField, keyField: props.keyField, ...props.filterConfig, }; }); return usePlc({ props, scopeSlots, slots, event, proxyPropsConfig: { filterConfig: () => {return filterConfig.value;} }, defaultScopeSlots: { edit: ({ row, plc }) => !plc.props.field ? null : ( <_Object v-model={row[plc.props.field]} option={props.option} row={row} labelField={props.labelField} keyField={props.keyField} map={props.map} /> ) } }); }, }); export default PlcObject;