From 2f5a489a9cc766eb400a91d523e42957531f9c1c Mon Sep 17 00:00:00 2001 From: zxyRealm Date: Mon, 4 Mar 2019 15:41:04 +0800 Subject: [PATCH] DatePicker: add monthrange for type attribute (#4204) (#14487) --- examples/docs/en-US/date-picker.md | 71 +++- examples/docs/es/date-picker.md | 71 +++- examples/docs/fr-FR/date-picker.md | 71 +++- examples/docs/zh-CN/date-picker.md | 73 ++++- .../date-picker/src/basic/month-table.vue | 259 +++++++++++---- .../date-picker/src/panel/month-range.vue | 289 +++++++++++++++++ packages/date-picker/src/picker.vue | 6 + .../date-picker/src/picker/date-picker.js | 3 + .../src/date-picker/date-range-picker.scss | 11 +- .../src/date-picker/month-table.scss | 47 ++- .../theme-chalk/src/date-picker/picker.scss | 7 + test/unit/specs/date-picker.spec.js | 302 ++++++++++++++++++ 12 files changed, 1138 insertions(+), 72 deletions(-) create mode 100644 packages/date-picker/src/panel/month-range.vue diff --git a/examples/docs/en-US/date-picker.md b/examples/docs/en-US/date-picker.md index 707f9971fec..21d0bcf7b5d 100644 --- a/examples/docs/en-US/date-picker.md +++ b/examples/docs/en-US/date-picker.md @@ -1,3 +1,4 @@ + ## DatePicker Use Date Picker for date input. @@ -202,6 +203,74 @@ Picking a date range is supported. ::: +### Month Range + +Picking a month range is supported. + +:::demo When in range mode, the left and right panels are linked by default. If you want the two panels to switch current years independently, you can use the `unlink-panels` attribute. +```html + + + +``` +::: + ### Default Value If user hasn't picked a date, shows today's calendar by default. You can use `default-value` to set another date. Its value should be parsable by `new Date()`. @@ -372,7 +441,7 @@ When picking a date range, you can assign the time part for start date and end d | placeholder | placeholder in non-range mode | string | — | — | | start-placeholder | placeholder for the start date in range mode | string | — | — | | end-placeholder | placeholder for the end date in range mode | string | — | — | -| type | type of the picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange | date | +| type | type of the picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange/ monthrange | date | | format | format of the displayed value in the input box | string | see [date formats](#/en-US/component/date-picker#date-formats) | yyyy-MM-dd | | align | alignment | left/center/right | left | | popper-class | custom class name for DatePicker's dropdown | string | — | — | diff --git a/examples/docs/es/date-picker.md b/examples/docs/es/date-picker.md index 9be02f2a4a6..641ac854ce0 100644 --- a/examples/docs/es/date-picker.md +++ b/examples/docs/es/date-picker.md @@ -1,3 +1,4 @@ + ## DatePicker Utilice Date Picker para introducir la fecha. @@ -204,6 +205,74 @@ Se soporta la selección de un rango de fechas. ::: +### Month Range + +Picking a month range is supported. + +:::demo When in range mode, the left and right panels are linked by default. If you want the two panels to switch current years independently, you can use the `unlink-panels` attribute. +```html + + + +``` +::: + ### Valor por defecto Si el usuario no ha escogido una fecha, muestra el calendario de hoy por defecto. Puede utilizar `default-value` para fijar otra fecha. Su valor debe ser definido por `new Date()`. @@ -373,7 +442,7 @@ Al seleccionar un intervalo de fechas, puede asignar la hora para la fecha de in | placeholder | placeholder cuando el modo NO es rango | string | — | — | | start-placeholder | placeholder para la fecha de inicio en modo rango | string | — | — | | end-placeholder | placeholder para la fecha final en modo rango | string | — | — | -| type | tipo de picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange | date | +| type | tipo de picker | string | year/month/date/dates/datetime/ week/datetimerange/daterange/ monthrange | date | | format | formato en que se muestra el valor en el input | string | ver [date formats](#/es/component/date-picker#date-formats) | yyyy-MM-dd | | align | alineación | left/center/right | left | | | popper-class | nombre de clase personalizada para el dropdown de DatePicker | string | — | — | diff --git a/examples/docs/fr-FR/date-picker.md b/examples/docs/fr-FR/date-picker.md index 297f95d64a3..864f679199c 100644 --- a/examples/docs/fr-FR/date-picker.md +++ b/examples/docs/fr-FR/date-picker.md @@ -1,3 +1,4 @@ + ## DatePicker Utilisez le DatePicker pour les champs de dates. @@ -202,6 +203,74 @@ Vous pouvez sélectionner une plage de dates. ::: +### Month Range + +Picking a month range is supported. + +:::demo When in range mode, the left and right panels are linked by default. If you want the two panels to switch current years independently, you can use the `unlink-panels` attribute. +```html + + + +``` +::: + ### Valeur par défaut Si l'utilisateur n'a pas sélectionné de date, vous pouvez montrer la date d'aujourd'hui par défaut. Utilisez `default-value` pour montrer une autre date. Sa valeur doit être parsable par `new Date()`. @@ -373,7 +442,7 @@ Lorsque vous choisissez une plage de dates, vous pouvez assigner l'horaire de d | placeholder | Le placeholder en mode normal. | string | — | — | | start-placeholder | Le placeholder pour la date de début en mode plage de dates. | string | — | — | | end-placeholder | Le placeholder pour la date de fin en mode plage de dates. | string | — | — | -| type | Type du picker. | string | year/month/date/dates/datetime/ week/datetimerange/daterange | date | +| type | Type du picker. | string | year/month/date/dates/datetime/ week/datetimerange/daterange/ monthrange | date | | format | Format d'affichage dans le champ. | string | Voir [formats de date](#/fr-FR/component/date-picker#formats-de-date). | yyyy-MM-dd | | align | Alignement. | left/center/right | left | | popper-class | Nom de classe pour le menu déroulant du DatePicker. | string | — | — | diff --git a/examples/docs/zh-CN/date-picker.md b/examples/docs/zh-CN/date-picker.md index 40393d54b23..73d5b5131cd 100644 --- a/examples/docs/zh-CN/date-picker.md +++ b/examples/docs/zh-CN/date-picker.md @@ -1,3 +1,4 @@ + ## DatePicker 日期选择器 用于选择或输入日期 @@ -198,6 +199,76 @@ ``` ::: + +### 选择月份范围 + +可在一个选择器中便捷地选择一个月份范围 + +:::demo 在选择月份范围时,默认情况下左右面板会联动。如果希望两个面板各自独立切换当前年份,可以使用`unlink-panels`属性解除联动。 +```html + + + +``` +::: + + ### 日期格式 使用`format`指定输入框的格式;使用`value-format`指定绑定值的格式。 @@ -323,7 +394,7 @@ | placeholder | 非范围选择时的占位内容 | string | — | — | | start-placeholder | 范围选择时开始日期的占位内容 | string | — | — | | end-placeholder | 范围选择时结束日期的占位内容 | string | — | — | -| type | 显示类型 | string | year/month/date/dates/ week/datetime/datetimerange/daterange | date | +| type | 显示类型 | string | year/month/date/dates/ week/datetime/datetimerange/ daterange/monthrange | date | | format | 显示在输入框中的格式 | string | 见[日期格式](#/zh-CN/component/date-picker#ri-qi-ge-shi) | yyyy-MM-dd | | align | 对齐方式 | string | left, center, right | left | | popper-class | DatePicker 下拉框的类名 | string | — | — | diff --git a/packages/date-picker/src/basic/month-table.vue b/packages/date-picker/src/basic/month-table.vue index a343cb4be4b..d539935b30c 100644 --- a/packages/date-picker/src/basic/month-table.vue +++ b/packages/date-picker/src/basic/month-table.vue @@ -1,46 +1,11 @@