Просмотр исходного кода

#4307 Birthday field isn't working properly on mobile: update flatpickr

Alex Trofimov 3 лет назад
Родитель
Сommit
c30a68de99

+ 23 - 9
plugins_public/flatpickr/dist/esm/plugins/monthSelect/index.js

@@ -58,6 +58,16 @@ function monthSelectPlugin(pluginConfig) {
                 frag.appendChild(month);
             }
             self.monthsContainer.appendChild(frag);
+            if (fp.config.minDate &&
+                fp.currentYear === fp.config.minDate.getFullYear())
+                fp.prevMonthNav.classList.add("flatpickr-disabled");
+            else
+                fp.prevMonthNav.classList.remove("flatpickr-disabled");
+            if (fp.config.maxDate &&
+                fp.currentYear === fp.config.maxDate.getFullYear())
+                fp.nextMonthNav.classList.add("flatpickr-disabled");
+            else
+                fp.nextMonthNav.classList.remove("flatpickr-disabled");
         }
         function bindEvents() {
             fp._bind(fp.prevMonthNav, "click", function (e) {
@@ -143,21 +153,25 @@ function monthSelectPlugin(pluginConfig) {
         }
         function setMonth(date) {
             var selectedDate = new Date(fp.currentYear, date.getMonth(), date.getDate());
+            var selectedDates = [];
             switch (fp.config.mode) {
                 case "single":
-                    fp.selectedDates = [selectedDate];
+                    selectedDates = [selectedDate];
+                    break;
+                case "multiple":
+                    selectedDates.push(selectedDate);
                     break;
                 case "range":
                     if (fp.selectedDates.length === 2) {
-                        fp.clear(false, false);
-                        buildMonths();
+                        selectedDates = [selectedDate];
+                    }
+                    else {
+                        selectedDates = fp.selectedDates.concat([selectedDate]);
+                        selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
                     }
-                    fp.selectedDates.push(selectedDate);
-                    fp.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
                     break;
             }
-            fp.latestSelectedDateObj = selectedDate;
-            fp.updateValue();
+            fp.setDate(selectedDates, true);
             setCurrentlySelected();
         }
         var shifts = {
@@ -197,8 +211,8 @@ function monthSelectPlugin(pluginConfig) {
         }
         function stubCurrentMonth() {
             config._stubbedCurrentMonth = fp._initialDate.getMonth();
-            fp._initialDate.setMonth(0);
-            fp.currentMonth = 0;
+            fp._initialDate.setMonth(config._stubbedCurrentMonth);
+            fp.currentMonth = config._stubbedCurrentMonth;
         }
         function unstubCurrentMonth() {
             if (!config._stubbedCurrentMonth)

+ 1 - 1
plugins_public/flatpickr/dist/esm/tsconfig.esm.tsbuildinfo

@@ -557,7 +557,7 @@
         "affectsGlobalScope": false
       },
       "../../src/plugins/monthselect/index.ts": {
-        "version": "417fddf14f07ac5735f201d1034fe7136ad6424217334262046e234586c9abe7",
+        "version": "601ca634833552bc27d692e2acff25deeea4125714399ada3dae878a51bff5ff",
         "signature": "67a241ae0fe1141ca968431d3f72da39ae4dd02de9eee63b6abb2459504ef4b5",
         "affectsGlobalScope": false
       },

+ 1 - 1
plugins_public/flatpickr/dist/flatpickr.js

@@ -1,4 +1,4 @@
-/* flatpickr v4.6.11, @license MIT */
+/* flatpickr v4.6.13, @license MIT */
 (function (global, factory) {
     typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
     typeof define === 'function' && define.amd ? define(factory) :

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
plugins_public/flatpickr/dist/flatpickr.min.js


+ 23 - 9
plugins_public/flatpickr/dist/plugins/monthSelect/index.js

@@ -96,6 +96,16 @@
                     frag.appendChild(month);
                 }
                 self.monthsContainer.appendChild(frag);
+                if (fp.config.minDate &&
+                    fp.currentYear === fp.config.minDate.getFullYear())
+                    fp.prevMonthNav.classList.add("flatpickr-disabled");
+                else
+                    fp.prevMonthNav.classList.remove("flatpickr-disabled");
+                if (fp.config.maxDate &&
+                    fp.currentYear === fp.config.maxDate.getFullYear())
+                    fp.nextMonthNav.classList.add("flatpickr-disabled");
+                else
+                    fp.nextMonthNav.classList.remove("flatpickr-disabled");
             }
             function bindEvents() {
                 fp._bind(fp.prevMonthNav, "click", function (e) {
@@ -181,21 +191,25 @@
             }
             function setMonth(date) {
                 var selectedDate = new Date(fp.currentYear, date.getMonth(), date.getDate());
+                var selectedDates = [];
                 switch (fp.config.mode) {
                     case "single":
-                        fp.selectedDates = [selectedDate];
+                        selectedDates = [selectedDate];
+                        break;
+                    case "multiple":
+                        selectedDates.push(selectedDate);
                         break;
                     case "range":
                         if (fp.selectedDates.length === 2) {
-                            fp.clear(false, false);
-                            buildMonths();
+                            selectedDates = [selectedDate];
+                        }
+                        else {
+                            selectedDates = fp.selectedDates.concat([selectedDate]);
+                            selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
                         }
-                        fp.selectedDates.push(selectedDate);
-                        fp.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
                         break;
                 }
-                fp.latestSelectedDateObj = selectedDate;
-                fp.updateValue();
+                fp.setDate(selectedDates, true);
                 setCurrentlySelected();
             }
             var shifts = {
@@ -236,8 +250,8 @@
             // Help the prev/next year nav honor config.minDate (see 3fa5a69)
             function stubCurrentMonth() {
                 config._stubbedCurrentMonth = fp._initialDate.getMonth();
-                fp._initialDate.setMonth(0);
-                fp.currentMonth = 0;
+                fp._initialDate.setMonth(config._stubbedCurrentMonth);
+                fp.currentMonth = config._stubbedCurrentMonth;
             }
             function unstubCurrentMonth() {
                 if (!config._stubbedCurrentMonth)

+ 1 - 1
plugins_public/flatpickr/dist/tsconfig.declarations.tsbuildinfo

@@ -542,7 +542,7 @@
         "affectsGlobalScope": false
       },
       "../src/plugins/monthselect/index.ts": {
-        "version": "417fddf14f07ac5735f201d1034fe7136ad6424217334262046e234586c9abe7",
+        "version": "601ca634833552bc27d692e2acff25deeea4125714399ada3dae878a51bff5ff",
         "signature": "67a241ae0fe1141ca968431d3f72da39ae4dd02de9eee63b6abb2459504ef4b5",
         "affectsGlobalScope": false
       },

+ 1 - 1
plugins_public/flatpickr/package.json

@@ -1,6 +1,6 @@
 {
   "name": "flatpickr",
-  "version": "4.6.11",
+  "version": "4.6.13",
   "description": "A lightweight, powerful javascript datetime picker",
   "scripts": {
     "build": "run-s build:pre build:build build:esm build:types build:post",

Некоторые файлы не были показаны из-за большого количества измененных файлов