feat: date-picker add inputreadonly

pull/2156/head
tanjinzhou 2020-04-26 16:37:15 +08:00
parent b55fa75b93
commit 138eae594d
8 changed files with 27 additions and 2 deletions

View File

@ -292,6 +292,7 @@ export default {
localeCode, localeCode,
format, format,
separator, separator,
inputReadOnly,
} = props; } = props;
const getPrefixCls = this.configProvider.getPrefixCls; const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('calendar', customizePrefixCls); const prefixCls = getPrefixCls('calendar', customizePrefixCls);
@ -351,6 +352,7 @@ export default {
value: showDate, value: showDate,
hoverValue, hoverValue,
showToday, showToday,
inputReadOnly,
}, },
on: { on: {
change: calendarChange, change: calendarChange,

View File

@ -140,7 +140,7 @@ export default function createPicker(TheCalendar, props) {
const { panelChange = noop, focus = noop, blur = noop, ok = noop } = listeners; const { panelChange = noop, focus = noop, blur = noop, ok = noop } = listeners;
const props = getOptionProps(this); const props = getOptionProps(this);
const { prefixCls: customizePrefixCls, locale, localeCode } = props; const { prefixCls: customizePrefixCls, locale, localeCode, inputReadOnly } = props;
const getPrefixCls = this.configProvider.getPrefixCls; const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('calendar', customizePrefixCls); const prefixCls = getPrefixCls('calendar', customizePrefixCls);
this._prefixCls = prefixCls; this._prefixCls = prefixCls;
@ -189,6 +189,7 @@ export default function createPicker(TheCalendar, props) {
monthCellContentRender, monthCellContentRender,
renderFooter: this.renderFooter, renderFooter: this.renderFooter,
value: showDate, value: showDate,
inputReadOnly,
}, },
on: { on: {
ok, ok,

View File

@ -36,6 +36,7 @@ export const PickerProps = () => ({
tagPrefixCls: PropTypes.string, tagPrefixCls: PropTypes.string,
tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
align: PropTypes.object.def(() => ({})), align: PropTypes.object.def(() => ({})),
inputReadOnly: PropTypes.bool,
}); });
export const SinglePickerProps = () => ({ export const SinglePickerProps = () => ({

View File

@ -54,6 +54,7 @@ const Calendar = {
clearIcon: PropTypes.any, clearIcon: PropTypes.any,
focusablePanel: PropTypes.bool.def(true), focusablePanel: PropTypes.bool.def(true),
inputMode: PropTypes.string, inputMode: PropTypes.string,
inputReadOnly: PropTypes.bool,
}, },
mixins: [BaseMixin, CommonMixin, CalendarMixin], mixins: [BaseMixin, CommonMixin, CalendarMixin],
@ -250,6 +251,7 @@ const Calendar = {
sMode, sMode,
renderFooter, renderFooter,
inputMode, inputMode,
inputReadOnly,
monthCellRender, monthCellRender,
monthCellContentRender, monthCellContentRender,
$props: props, $props: props,
@ -303,6 +305,7 @@ const Calendar = {
clearIcon={clearIcon} clearIcon={clearIcon}
onSelect={this.onDateInputSelect} onSelect={this.onDateInputSelect}
inputMode={inputMode} inputMode={inputMode}
inputReadOnly={inputReadOnly}
/> />
) : null; ) : null;
const children = []; const children = [];

View File

@ -119,6 +119,7 @@ const RangeCalendar = {
renderSidebar: PropTypes.func.def(() => null), renderSidebar: PropTypes.func.def(() => null),
dateRender: PropTypes.func, dateRender: PropTypes.func,
clearIcon: PropTypes.any, clearIcon: PropTypes.any,
inputReadOnly: PropTypes.bool,
}, },
mixins: [BaseMixin, CommonMixin], mixins: [BaseMixin, CommonMixin],

View File

@ -26,6 +26,7 @@ const DateInput = {
selectedValue: PropTypes.object, selectedValue: PropTypes.object,
clearIcon: PropTypes.any, clearIcon: PropTypes.any,
inputMode: PropTypes.string, inputMode: PropTypes.string,
inputReadOnly: PropTypes.bool,
}, },
data() { data() {
@ -166,7 +167,17 @@ const DateInput = {
}, },
render() { render() {
const { invalid, str, locale, prefixCls, placeholder, disabled, showClear, inputMode } = this; const {
invalid,
str,
locale,
prefixCls,
placeholder,
disabled,
showClear,
inputMode,
inputReadOnly,
} = this;
const clearIcon = getComponentFromProp(this, 'clearIcon'); const clearIcon = getComponentFromProp(this, 'clearIcon');
const invalidClass = invalid ? `${prefixCls}-input-invalid` : ''; const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
return ( return (
@ -193,6 +204,7 @@ const DateInput = {
onFocus={this.onFocus} onFocus={this.onFocus}
onBlur={this.onBlur} onBlur={this.onBlur}
inputMode={inputMode} inputMode={inputMode}
readOnly={inputReadOnly}
/> />
</div> </div>
{showClear ? ( {showClear ? (

View File

@ -33,6 +33,7 @@ const CalendarPart = {
clearIcon: PropTypes.any, clearIcon: PropTypes.any,
dateRender: PropTypes.func, dateRender: PropTypes.func,
inputMode: PropTypes.string, inputMode: PropTypes.string,
inputReadOnly: PropTypes.bool,
}, },
render() { render() {
const { $props: props } = this; const { $props: props } = this;
@ -59,6 +60,7 @@ const CalendarPart = {
showWeekNumber, showWeekNumber,
showClear, showClear,
inputMode, inputMode,
inputReadOnly,
} = props; } = props;
const clearIcon = getComponentFromProp(this, 'clearIcon'); const clearIcon = getComponentFromProp(this, 'clearIcon');
const { const {
@ -117,6 +119,7 @@ const CalendarPart = {
onSelect={inputSelect} onSelect={inputSelect}
clearIcon={clearIcon} clearIcon={clearIcon}
inputMode={inputMode} inputMode={inputMode}
inputReadOnly={inputReadOnly}
/> />
); );
const headerProps = { const headerProps = {

View File

@ -86,4 +86,6 @@ export declare class DatepickerCommon extends AntdComponent {
* @type any (VNode | slot) * @type any (VNode | slot)
*/ */
suffixIcon: any; suffixIcon: any;
inputReadOnly: boolean;
} }