Skip to content

Commit

Permalink
feat: date-picker add inputreadonly
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Apr 26, 2020
1 parent b55fa75 commit 138eae5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/date-picker/RangePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export default {
localeCode,
format,
separator,
inputReadOnly,
} = props;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
Expand Down Expand Up @@ -351,6 +352,7 @@ export default {
value: showDate,
hoverValue,
showToday,
inputReadOnly,
},
on: {
change: calendarChange,
Expand Down
3 changes: 2 additions & 1 deletion components/date-picker/createPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default function createPicker(TheCalendar, props) {
const { panelChange = noop, focus = noop, blur = noop, ok = noop } = listeners;
const props = getOptionProps(this);

const { prefixCls: customizePrefixCls, locale, localeCode } = props;
const { prefixCls: customizePrefixCls, locale, localeCode, inputReadOnly } = props;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
this._prefixCls = prefixCls;
Expand Down Expand Up @@ -189,6 +189,7 @@ export default function createPicker(TheCalendar, props) {
monthCellContentRender,
renderFooter: this.renderFooter,
value: showDate,
inputReadOnly,
},
on: {
ok,
Expand Down
1 change: 1 addition & 0 deletions components/date-picker/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const PickerProps = () => ({
tagPrefixCls: PropTypes.string,
tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
align: PropTypes.object.def(() => ({})),
inputReadOnly: PropTypes.bool,
});

export const SinglePickerProps = () => ({
Expand Down
3 changes: 3 additions & 0 deletions components/vc-calendar/src/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const Calendar = {
clearIcon: PropTypes.any,
focusablePanel: PropTypes.bool.def(true),
inputMode: PropTypes.string,
inputReadOnly: PropTypes.bool,
},

mixins: [BaseMixin, CommonMixin, CalendarMixin],
Expand Down Expand Up @@ -250,6 +251,7 @@ const Calendar = {
sMode,
renderFooter,
inputMode,
inputReadOnly,
monthCellRender,
monthCellContentRender,
$props: props,
Expand Down Expand Up @@ -303,6 +305,7 @@ const Calendar = {
clearIcon={clearIcon}
onSelect={this.onDateInputSelect}
inputMode={inputMode}
inputReadOnly={inputReadOnly}
/>
) : null;
const children = [];
Expand Down
1 change: 1 addition & 0 deletions components/vc-calendar/src/RangeCalendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const RangeCalendar = {
renderSidebar: PropTypes.func.def(() => null),
dateRender: PropTypes.func,
clearIcon: PropTypes.any,
inputReadOnly: PropTypes.bool,
},

mixins: [BaseMixin, CommonMixin],
Expand Down
14 changes: 13 additions & 1 deletion components/vc-calendar/src/date/DateInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const DateInput = {
selectedValue: PropTypes.object,
clearIcon: PropTypes.any,
inputMode: PropTypes.string,
inputReadOnly: PropTypes.bool,
},

data() {
Expand Down Expand Up @@ -166,7 +167,17 @@ const DateInput = {
},

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 invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
return (
Expand All @@ -193,6 +204,7 @@ const DateInput = {
onFocus={this.onFocus}
onBlur={this.onBlur}
inputMode={inputMode}
readOnly={inputReadOnly}
/>
</div>
{showClear ? (
Expand Down
3 changes: 3 additions & 0 deletions components/vc-calendar/src/range-calendar/CalendarPart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const CalendarPart = {
clearIcon: PropTypes.any,
dateRender: PropTypes.func,
inputMode: PropTypes.string,
inputReadOnly: PropTypes.bool,
},
render() {
const { $props: props } = this;
Expand All @@ -59,6 +60,7 @@ const CalendarPart = {
showWeekNumber,
showClear,
inputMode,
inputReadOnly,
} = props;
const clearIcon = getComponentFromProp(this, 'clearIcon');
const {
Expand Down Expand Up @@ -117,6 +119,7 @@ const CalendarPart = {
onSelect={inputSelect}
clearIcon={clearIcon}
inputMode={inputMode}
inputReadOnly={inputReadOnly}
/>
);
const headerProps = {
Expand Down
2 changes: 2 additions & 0 deletions types/date-picker/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ export declare class DatepickerCommon extends AntdComponent {
* @type any (VNode | slot)
*/
suffixIcon: any;

inputReadOnly: boolean;
}

0 comments on commit 138eae5

Please sign in to comment.