-
-
+
+
{{ firstYear }}
@@ -49,11 +57,29 @@ export default {
type: Function,
default: () => [],
},
+ getIsYearDisabled: {
+ type: Function,
+ default: () => false,
+ },
getYearPanel: {
type: Function,
},
+ min: {
+ // in year e.g. 2021
+ type: Number,
+ },
+ max: {
+ // in year e.g. 2021
+ type: Number,
+ },
},
computed: {
+ isDoubleLeftDisabled() {
+ return !!this.min && this.firstYear <= this.min;
+ },
+ isDoubleRightDisabled() {
+ return !!this.max && this.lastYear >= this.max;
+ },
years() {
const calendar = new Date(this.calendar);
if (typeof this.getYearPanel === 'function') {
@@ -99,6 +125,7 @@ export default {
}
const year = target.getAttribute('data-year');
if (year) {
+ if (this.getIsYearDisabled(year)) return;
this.$emit('select', parseInt(year, 10));
}
},
diff --git a/src/date-picker.js b/src/date-picker.js
index 0eff88c..14703b6 100644
--- a/src/date-picker.js
+++ b/src/date-picker.js
@@ -133,6 +133,18 @@ export default {
return [];
},
},
+ min: {
+ type: [Date, String],
+ validator(value) {
+ return !isNaN(new Date(value));
+ },
+ },
+ max: {
+ type: [Date, String],
+ validator(value) {
+ return !isNaN(new Date(value));
+ },
+ },
},
data() {
return {
diff --git a/src/style/btn.scss b/src/style/btn.scss
index 90bd7cd..ca4d491 100644
--- a/src/style/btn.scss
+++ b/src/style/btn.scss
@@ -1,5 +1,4 @@
@import './var.scss';
-
.#{$namespace}-btn {
box-sizing: border-box;
line-height: 1;
@@ -14,12 +13,16 @@
border-radius: 4px;
color: $default-color;
white-space: nowrap;
- &:hover {
+ &:hover:not(:disabled) {
border-color: $primary-color;
color: $primary-color;
}
+ &-disabled {
+ color: $disabled-color !important;
+ border-color: $input-border-color !important;
+ cursor: not-allowed;
+ }
}
-
.#{$namespace}-btn-text {
border: 0;
padding: 0 4px;