Skip to content

Commit

Permalink
fix: date picker component value can be number
Browse files Browse the repository at this point in the history
  • Loading branch information
tinymins committed Dec 1, 2023
1 parent c5e5c56 commit d385c24
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ export default class DTCDate<RecordType extends DripTableRecordTypeBase> extends
if (options.mode === 'basic') {
const value = indexValue(dataIndex, '');
if (typeof value === 'string' || typeof value === 'number') {
return String(value);
return value;
}
if (typeof defaultValue === 'string' || typeof defaultValue === 'number') {
return String(defaultValue);
return defaultValue;
}
}
return '';
Expand All @@ -123,10 +123,10 @@ export default class DTCDate<RecordType extends DripTableRecordTypeBase> extends
if (options.mode === 'range') {
const value = indexValue(dataIndex, []);
if (Array.isArray(value) && !value.some(v => typeof v !== 'string' && typeof v !== 'number')) {
return value.map(String);
return value;
}
if (Array.isArray(defaultValue) && !defaultValue.some(v => typeof v !== 'string' && typeof v !== 'number')) {
return defaultValue.map(String);
return defaultValue;
}
}
return [];
Expand Down Expand Up @@ -216,7 +216,7 @@ export default class DTCDate<RecordType extends DripTableRecordTypeBase> extends
>
<Picker.DatePicker
autoFocus
date={this.basicValue}
date={this.basicValue as string}
onChange={(value) => {
if (this.props.preview) { return; }
this.props.onChange?.(moment(value).format(options.format));
Expand All @@ -237,7 +237,7 @@ export default class DTCDate<RecordType extends DripTableRecordTypeBase> extends
style={{ width: 380, height: 300, justifyContent }}
>
<Picker.DateRangePicker
date={this.rangeValue}
date={this.rangeValue as string[]}
autoFocus
style={Object.assign({}, { width: 340 })}
format={options.format}
Expand Down

0 comments on commit d385c24

Please sign in to comment.