Skip to content

Commit

Permalink
fix: range picker props fixed for element-plus (#5042)
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan authored Dec 7, 2024
1 parent 4c1fc4a commit 68ab73b
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions apps/web-ele/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import type { BaseFormComponentType } from '@vben/common-ui';
import type { Recordable } from '@vben/types';

import type { Component, SetupContext } from 'vue';
import { h } from 'vue';
Expand Down Expand Up @@ -107,8 +108,48 @@ async function initComponentAdapter() {
Select: withDefaultPlaceholder(ElSelect, 'select'),
Space: ElSpace,
Switch: ElSwitch,
TimePicker: ElTimePicker,
DatePicker: ElDatePicker,
TimePicker: (props, { attrs, slots }) => {
const { name, id, isRange } = props;
const extraProps: Recordable<any> = {};
if (isRange) {
if (name && !Array.isArray(name)) {
extraProps.name = [name, `${name}_end`];
}
if (id && !Array.isArray(id)) {
extraProps.id = [id, `${id}_end`];
}
}
return h(
ElTimePicker,
{
...props,
...attrs,
...extraProps,
},
slots,
);
},
DatePicker: (props, { attrs, slots }) => {
const { name, id, type } = props;
const extraProps: Recordable<any> = {};
if (type && type.includes('range')) {
if (name && !Array.isArray(name)) {
extraProps.name = [name, `${name}_end`];
}
if (id && !Array.isArray(id)) {
extraProps.id = [id, `${id}_end`];
}
}
return h(
ElDatePicker,
{
...props,
...attrs,
...extraProps,
},
slots,
);
},
TreeSelect: withDefaultPlaceholder(ElTreeSelect, 'select'),
Upload: ElUpload,
};
Expand Down

0 comments on commit 68ab73b

Please sign in to comment.