Skip to content

Commit 138eae5

Browse files
committed
feat: date-picker add inputreadonly
1 parent b55fa75 commit 138eae5

File tree

8 files changed

+27
-2
lines changed

8 files changed

+27
-2
lines changed

components/date-picker/RangePicker.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ export default {
292292
localeCode,
293293
format,
294294
separator,
295+
inputReadOnly,
295296
} = props;
296297
const getPrefixCls = this.configProvider.getPrefixCls;
297298
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
@@ -351,6 +352,7 @@ export default {
351352
value: showDate,
352353
hoverValue,
353354
showToday,
355+
inputReadOnly,
354356
},
355357
on: {
356358
change: calendarChange,

components/date-picker/createPicker.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export default function createPicker(TheCalendar, props) {
140140
const { panelChange = noop, focus = noop, blur = noop, ok = noop } = listeners;
141141
const props = getOptionProps(this);
142142

143-
const { prefixCls: customizePrefixCls, locale, localeCode } = props;
143+
const { prefixCls: customizePrefixCls, locale, localeCode, inputReadOnly } = props;
144144
const getPrefixCls = this.configProvider.getPrefixCls;
145145
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
146146
this._prefixCls = prefixCls;
@@ -189,6 +189,7 @@ export default function createPicker(TheCalendar, props) {
189189
monthCellContentRender,
190190
renderFooter: this.renderFooter,
191191
value: showDate,
192+
inputReadOnly,
192193
},
193194
on: {
194195
ok,

components/date-picker/interface.js

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const PickerProps = () => ({
3636
tagPrefixCls: PropTypes.string,
3737
tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
3838
align: PropTypes.object.def(() => ({})),
39+
inputReadOnly: PropTypes.bool,
3940
});
4041

4142
export const SinglePickerProps = () => ({

components/vc-calendar/src/Calendar.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const Calendar = {
5454
clearIcon: PropTypes.any,
5555
focusablePanel: PropTypes.bool.def(true),
5656
inputMode: PropTypes.string,
57+
inputReadOnly: PropTypes.bool,
5758
},
5859

5960
mixins: [BaseMixin, CommonMixin, CalendarMixin],
@@ -250,6 +251,7 @@ const Calendar = {
250251
sMode,
251252
renderFooter,
252253
inputMode,
254+
inputReadOnly,
253255
monthCellRender,
254256
monthCellContentRender,
255257
$props: props,
@@ -303,6 +305,7 @@ const Calendar = {
303305
clearIcon={clearIcon}
304306
onSelect={this.onDateInputSelect}
305307
inputMode={inputMode}
308+
inputReadOnly={inputReadOnly}
306309
/>
307310
) : null;
308311
const children = [];

components/vc-calendar/src/RangeCalendar.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const RangeCalendar = {
119119
renderSidebar: PropTypes.func.def(() => null),
120120
dateRender: PropTypes.func,
121121
clearIcon: PropTypes.any,
122+
inputReadOnly: PropTypes.bool,
122123
},
123124

124125
mixins: [BaseMixin, CommonMixin],

components/vc-calendar/src/date/DateInput.jsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const DateInput = {
2626
selectedValue: PropTypes.object,
2727
clearIcon: PropTypes.any,
2828
inputMode: PropTypes.string,
29+
inputReadOnly: PropTypes.bool,
2930
},
3031

3132
data() {
@@ -166,7 +167,17 @@ const DateInput = {
166167
},
167168

168169
render() {
169-
const { invalid, str, locale, prefixCls, placeholder, disabled, showClear, inputMode } = this;
170+
const {
171+
invalid,
172+
str,
173+
locale,
174+
prefixCls,
175+
placeholder,
176+
disabled,
177+
showClear,
178+
inputMode,
179+
inputReadOnly,
180+
} = this;
170181
const clearIcon = getComponentFromProp(this, 'clearIcon');
171182
const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
172183
return (
@@ -193,6 +204,7 @@ const DateInput = {
193204
onFocus={this.onFocus}
194205
onBlur={this.onBlur}
195206
inputMode={inputMode}
207+
readOnly={inputReadOnly}
196208
/>
197209
</div>
198210
{showClear ? (

components/vc-calendar/src/range-calendar/CalendarPart.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const CalendarPart = {
3333
clearIcon: PropTypes.any,
3434
dateRender: PropTypes.func,
3535
inputMode: PropTypes.string,
36+
inputReadOnly: PropTypes.bool,
3637
},
3738
render() {
3839
const { $props: props } = this;
@@ -59,6 +60,7 @@ const CalendarPart = {
5960
showWeekNumber,
6061
showClear,
6162
inputMode,
63+
inputReadOnly,
6264
} = props;
6365
const clearIcon = getComponentFromProp(this, 'clearIcon');
6466
const {
@@ -117,6 +119,7 @@ const CalendarPart = {
117119
onSelect={inputSelect}
118120
clearIcon={clearIcon}
119121
inputMode={inputMode}
122+
inputReadOnly={inputReadOnly}
120123
/>
121124
);
122125
const headerProps = {

types/date-picker/common.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,6 @@ export declare class DatepickerCommon extends AntdComponent {
8686
* @type any (VNode | slot)
8787
*/
8888
suffixIcon: any;
89+
90+
inputReadOnly: boolean;
8991
}

0 commit comments

Comments
 (0)