@douyinfe/semi-foundation 2.69.0 → 2.69.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,9 +105,9 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
105
105
  const month = copy(currentMonth);
106
106
  month[panelType] = item.month;
107
107
 
108
- // make sure the right panel time is always less than the left panel time
108
+ // Make sure the time on the right panel is always greater than or equal to the time on the left panel
109
109
  if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
110
- month[right] = item.month + 1;
110
+ month[right] = item.month ;
111
111
  }
112
112
 
113
113
  this._adapter.setCurrentMonth(month);
@@ -121,8 +121,19 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
121
121
  const { disabledDate, locale } = this._adapter.getProps();
122
122
  const { months, currentMonth } = this._adapter.getStates();
123
123
 
124
+ const oppositeType = panelType === strings.PANEL_TYPE_LEFT ? 'right' : 'left';
125
+
124
126
  const currentDate = setYear(Date.now(), item.year);
125
127
  const isCurrentMonthDisabled = disabledDate(setMonth(currentDate, currentMonth[panelType] - 1));
128
+ // whether the date on the opposite is legal
129
+ const isOppositeMonthDisabled = disabledDate(setMonth(setYear(Date.now(), year[oppositeType]), currentMonth[oppositeType] - 1));
130
+
131
+ if (!isCurrentMonthDisabled && !isOppositeMonthDisabled) {
132
+ // all panel Date is legal
133
+ return;
134
+ }
135
+ let finalYear = year;
136
+ let finalMonth = currentMonth;
126
137
  if (isCurrentMonthDisabled) {
127
138
  const currentIndex = months.findIndex(({ month }) => month === currentMonth[panelType]);
128
139
  let validMonth: typeof months[number];
@@ -131,15 +142,24 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
131
142
  if (!validMonth) {
132
143
  validMonth = months.slice(0, currentIndex).find(({ month }) => !disabledDate(setMonth(currentDate, month - 1)));
133
144
  }
134
- if (validMonth) {
135
- const month = copy(currentMonth);
136
- month[panelType] = validMonth.month;
137
-
138
- // change year and month same time
139
- this._adapter.setCurrentYearAndMonth(year, month);
140
- this._adapter.notifySelectYearAndMonth(year, month);
145
+ if (validMonth && !isOppositeMonthDisabled) {
146
+ // only currentPanel Date is illegal
147
+ // just need to modify the month of the current panel
148
+ finalMonth[panelType] = validMonth.month;
149
+ } else if (validMonth && isOppositeMonthDisabled) {
150
+ // all panel Date is illegal
151
+ // change the value to the legal value calculated by the current panel
152
+ finalYear = { 'left': item.year, 'right': item.year };
153
+ finalMonth = { 'left': validMonth.month, 'right': validMonth.month };
141
154
  }
155
+ } else if (!isCurrentMonthDisabled && isOppositeMonthDisabled) {
156
+ // only opposite panel Date is illegal
157
+ // change the value to the legal value in the current panel
158
+ finalYear = { 'left': item.year, 'right': item.year };
159
+ finalMonth = { 'left': currentMonth[panelType], 'right': currentMonth[panelType] };
142
160
  }
161
+ this._adapter.setCurrentYearAndMonth(finalYear, finalMonth);
162
+ this._adapter.notifySelectYearAndMonth(finalYear, finalMonth);
143
163
  }
144
164
 
145
165
  backToMain() {
@@ -55,9 +55,9 @@ class YearAndMonthFoundation extends _foundation.default {
55
55
  const right = _constants.strings.PANEL_TYPE_RIGHT;
56
56
  const month = (0, _fastCopy.default)(currentMonth);
57
57
  month[panelType] = item.month;
58
- // make sure the right panel time is always less than the left panel time
58
+ // Make sure the time on the right panel is always greater than or equal to the time on the left panel
59
59
  if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
60
- month[right] = item.month + 1;
60
+ month[right] = item.month;
61
61
  }
62
62
  this._adapter.setCurrentMonth(month);
63
63
  this._adapter.notifySelectMonth(month);
@@ -74,8 +74,17 @@ class YearAndMonthFoundation extends _foundation.default {
74
74
  months,
75
75
  currentMonth
76
76
  } = this._adapter.getStates();
77
+ const oppositeType = panelType === _constants.strings.PANEL_TYPE_LEFT ? 'right' : 'left';
77
78
  const currentDate = (0, _dateFns.setYear)(Date.now(), item.year);
78
79
  const isCurrentMonthDisabled = disabledDate((0, _dateFns.setMonth)(currentDate, currentMonth[panelType] - 1));
80
+ // whether the date on the opposite is legal
81
+ const isOppositeMonthDisabled = disabledDate((0, _dateFns.setMonth)((0, _dateFns.setYear)(Date.now(), year[oppositeType]), currentMonth[oppositeType] - 1));
82
+ if (!isCurrentMonthDisabled && !isOppositeMonthDisabled) {
83
+ // all panel Date is legal
84
+ return;
85
+ }
86
+ let finalYear = year;
87
+ let finalMonth = currentMonth;
79
88
  if (isCurrentMonthDisabled) {
80
89
  const currentIndex = months.findIndex(_ref => {
81
90
  let {
@@ -99,14 +108,36 @@ class YearAndMonthFoundation extends _foundation.default {
99
108
  return !disabledDate((0, _dateFns.setMonth)(currentDate, month - 1));
100
109
  });
101
110
  }
102
- if (validMonth) {
103
- const month = (0, _fastCopy.default)(currentMonth);
104
- month[panelType] = validMonth.month;
105
- // change year and month same time
106
- this._adapter.setCurrentYearAndMonth(year, month);
107
- this._adapter.notifySelectYearAndMonth(year, month);
111
+ if (validMonth && !isOppositeMonthDisabled) {
112
+ // only currentPanel Date is illegal
113
+ // just need to modify the month of the current panel
114
+ finalMonth[panelType] = validMonth.month;
115
+ } else if (validMonth && isOppositeMonthDisabled) {
116
+ // all panel Date is illegal
117
+ // change the value to the legal value calculated by the current panel
118
+ finalYear = {
119
+ 'left': item.year,
120
+ 'right': item.year
121
+ };
122
+ finalMonth = {
123
+ 'left': validMonth.month,
124
+ 'right': validMonth.month
125
+ };
108
126
  }
127
+ } else if (!isCurrentMonthDisabled && isOppositeMonthDisabled) {
128
+ // only opposite panel Date is illegal
129
+ // change the value to the legal value in the current panel
130
+ finalYear = {
131
+ 'left': item.year,
132
+ 'right': item.year
133
+ };
134
+ finalMonth = {
135
+ 'left': currentMonth[panelType],
136
+ 'right': currentMonth[panelType]
137
+ };
109
138
  }
139
+ this._adapter.setCurrentYearAndMonth(finalYear, finalMonth);
140
+ this._adapter.notifySelectYearAndMonth(finalYear, finalMonth);
110
141
  }
111
142
  backToMain() {
112
143
  this._adapter.notifyBackToMain();
@@ -48,9 +48,9 @@ export default class YearAndMonthFoundation extends BaseFoundation {
48
48
  const right = strings.PANEL_TYPE_RIGHT;
49
49
  const month = copy(currentMonth);
50
50
  month[panelType] = item.month;
51
- // make sure the right panel time is always less than the left panel time
51
+ // Make sure the time on the right panel is always greater than or equal to the time on the left panel
52
52
  if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
53
- month[right] = item.month + 1;
53
+ month[right] = item.month;
54
54
  }
55
55
  this._adapter.setCurrentMonth(month);
56
56
  this._adapter.notifySelectMonth(month);
@@ -67,8 +67,17 @@ export default class YearAndMonthFoundation extends BaseFoundation {
67
67
  months,
68
68
  currentMonth
69
69
  } = this._adapter.getStates();
70
+ const oppositeType = panelType === strings.PANEL_TYPE_LEFT ? 'right' : 'left';
70
71
  const currentDate = setYear(Date.now(), item.year);
71
72
  const isCurrentMonthDisabled = disabledDate(setMonth(currentDate, currentMonth[panelType] - 1));
73
+ // whether the date on the opposite is legal
74
+ const isOppositeMonthDisabled = disabledDate(setMonth(setYear(Date.now(), year[oppositeType]), currentMonth[oppositeType] - 1));
75
+ if (!isCurrentMonthDisabled && !isOppositeMonthDisabled) {
76
+ // all panel Date is legal
77
+ return;
78
+ }
79
+ let finalYear = year;
80
+ let finalMonth = currentMonth;
72
81
  if (isCurrentMonthDisabled) {
73
82
  const currentIndex = months.findIndex(_ref => {
74
83
  let {
@@ -92,14 +101,36 @@ export default class YearAndMonthFoundation extends BaseFoundation {
92
101
  return !disabledDate(setMonth(currentDate, month - 1));
93
102
  });
94
103
  }
95
- if (validMonth) {
96
- const month = copy(currentMonth);
97
- month[panelType] = validMonth.month;
98
- // change year and month same time
99
- this._adapter.setCurrentYearAndMonth(year, month);
100
- this._adapter.notifySelectYearAndMonth(year, month);
104
+ if (validMonth && !isOppositeMonthDisabled) {
105
+ // only currentPanel Date is illegal
106
+ // just need to modify the month of the current panel
107
+ finalMonth[panelType] = validMonth.month;
108
+ } else if (validMonth && isOppositeMonthDisabled) {
109
+ // all panel Date is illegal
110
+ // change the value to the legal value calculated by the current panel
111
+ finalYear = {
112
+ 'left': item.year,
113
+ 'right': item.year
114
+ };
115
+ finalMonth = {
116
+ 'left': validMonth.month,
117
+ 'right': validMonth.month
118
+ };
101
119
  }
120
+ } else if (!isCurrentMonthDisabled && isOppositeMonthDisabled) {
121
+ // only opposite panel Date is illegal
122
+ // change the value to the legal value in the current panel
123
+ finalYear = {
124
+ 'left': item.year,
125
+ 'right': item.year
126
+ };
127
+ finalMonth = {
128
+ 'left': currentMonth[panelType],
129
+ 'right': currentMonth[panelType]
130
+ };
102
131
  }
132
+ this._adapter.setCurrentYearAndMonth(finalYear, finalMonth);
133
+ this._adapter.notifySelectYearAndMonth(finalYear, finalMonth);
103
134
  }
104
135
  backToMain() {
105
136
  this._adapter.notifyBackToMain();
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.69.0",
3
+ "version": "2.69.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.69.0",
10
+ "@douyinfe/semi-animation": "2.69.1",
11
11
  "@mdx-js/mdx": "^3.0.1",
12
12
  "async-validator": "^3.5.0",
13
13
  "classnames": "^2.2.6",
@@ -28,7 +28,7 @@
28
28
  "*.scss",
29
29
  "*.css"
30
30
  ],
31
- "gitHead": "e5c98a0dcec045fd50521e951f968923ebaa128e",
31
+ "gitHead": "4cdfb1b5db170e0cf55e9e371aebfc89c9b5a54f",
32
32
  "devDependencies": {
33
33
  "@babel/plugin-transform-runtime": "^7.15.8",
34
34
  "@babel/preset-env": "^7.15.8",