eoss 0.1.0-alpha.25 → 0.1.0-alpha.26
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.
- package/lib/0.js +1 -1
- package/lib/1.js +1 -1
- package/lib/10.js +1 -1
- package/lib/11.js +1 -1
- package/lib/12.js +1 -1
- package/lib/13.js +1 -1
- package/lib/14.js +1 -1
- package/lib/15.js +1 -1
- package/lib/16.js +1 -1
- package/lib/17.js +1 -1
- package/lib/18.js +1 -1
- package/lib/19.js +1 -1
- package/lib/20.js +1 -1
- package/lib/21.js +1 -1
- package/lib/22.js +1 -1
- package/lib/23.js +1 -1
- package/lib/24.js +1 -1
- package/lib/25.js +1 -1
- package/lib/26.js +1 -1
- package/lib/27.js +1 -1
- package/lib/28.js +1 -1
- package/lib/29.js +1 -1
- package/lib/3.js +1 -1
- package/lib/30.js +1 -1
- package/lib/31.js +1 -1
- package/lib/32.js +1 -1
- package/lib/33.js +1 -1
- package/lib/34.js +1 -1
- package/lib/35.js +1 -1
- package/lib/36.js +1 -1
- package/lib/37.js +1 -1
- package/lib/38.js +1 -1
- package/lib/39.js +1 -1
- package/lib/4.js +1 -1
- package/lib/40.js +1 -1
- package/lib/41.js +1 -1
- package/lib/42.js +1 -1
- package/lib/43.js +1 -1
- package/lib/44.js +1 -1
- package/lib/45.js +1 -1
- package/lib/46.js +1 -1
- package/lib/47.js +1 -1
- package/lib/48.js +1 -1
- package/lib/49.js +1 -1
- package/lib/5.js +1 -1
- package/lib/50.js +1 -1
- package/lib/51.js +1 -1
- package/lib/52.js +1 -1
- package/lib/53.js +1 -1
- package/lib/54.js +1 -1
- package/lib/55.js +1 -1
- package/lib/56.js +1 -1
- package/lib/57.js +1 -1
- package/lib/58.js +1 -1
- package/lib/59.js +1 -1
- package/lib/6.js +1 -1
- package/lib/60.js +1 -1
- package/lib/61.js +1 -1
- package/lib/62.js +1 -1
- package/lib/63.js +1 -1
- package/lib/64.js +1 -1
- package/lib/65.js +1 -1
- package/lib/66.js +1 -1
- package/lib/67.js +1 -1
- package/lib/68.js +1 -1
- package/lib/69.js +1 -1
- package/lib/7.js +1 -1
- package/lib/70.js +1 -1
- package/lib/71.js +1 -1
- package/lib/72.js +1 -1
- package/lib/73.js +1 -1
- package/lib/74.js +1 -1
- package/lib/75.js +1 -1
- package/lib/76.js +1 -1
- package/lib/77.js +1 -1
- package/lib/78.js +1 -1
- package/lib/79.js +1 -1
- package/lib/8.js +1 -1
- package/lib/80.js +1 -1
- package/lib/81.js +1 -1
- package/lib/9.js +1 -1
- package/lib/account-login.js +1000 -971
- package/lib/alert.js +2 -2
- package/lib/aside.js +2 -2
- package/lib/audit-trajectory.js +75 -71
- package/lib/autocomplete.js +2136 -1951
- package/lib/avatar.js +2 -2
- package/lib/backtop.js +2 -2
- package/lib/badge.js +2 -2
- package/lib/breadcrumb-item.js +4 -4
- package/lib/breadcrumb.js +4 -4
- package/lib/button-group.js +12 -12
- package/lib/button.js +2 -2
- package/lib/ca-login.js +913 -888
- package/lib/calendar.js +872 -847
- package/lib/card.js +2 -2
- package/lib/carousel-item.js +905 -880
- package/lib/carousel.js +1042 -1017
- package/lib/cascader-panel.js +926 -901
- package/lib/cascader.js +2022 -1837
- package/lib/checkbox-button.js +2 -2
- package/lib/checkbox-group.js +1000 -971
- package/lib/checkbox.js +2 -2
- package/lib/col.js +2 -2
- package/lib/collapse-item.js +2174 -1980
- package/lib/collapse.js +2175 -1980
- package/lib/color-picker.js +1112 -952
- package/lib/config/api.js +3 -0
- package/lib/container.js +2 -2
- package/lib/cron.js +2 -2
- package/lib/data-table.js +1007 -978
- package/lib/date-picker.js +2142 -1957
- package/lib/dialog.js +910 -885
- package/lib/divider.js +2 -2
- package/lib/drawer.js +2 -2
- package/lib/dropdown-item.js +4 -4
- package/lib/dropdown-menu.js +1104 -944
- package/lib/dropdown.js +925 -900
- package/lib/email-login.js +999 -970
- package/lib/empty.js +2 -2
- package/lib/eoss.common.js +8751 -4166
- package/lib/flip.js +2 -2
- package/lib/flow-group.js +906 -881
- package/lib/flow.js +1112 -1083
- package/lib/flows.js +1010 -981
- package/lib/footer.js +2 -2
- package/lib/form-item.js +909 -884
- package/lib/form.js +2185 -1986
- package/lib/guide.js +620 -0
- package/lib/header.js +2 -2
- package/lib/icon.js +981 -952
- package/lib/icons.js +2 -2
- package/lib/image-viewer.js +907 -882
- package/lib/image.js +4 -4
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +2 -2
- package/lib/input-number.js +4 -4
- package/lib/input.js +910 -885
- package/lib/link.js +2 -2
- package/lib/loading.js +2 -2
- package/lib/login.js +1027 -998
- package/lib/lowcode.js +17336 -13510
- package/lib/main.js +14933 -14625
- package/lib/marquee.js +907 -882
- package/lib/menu-item-group.js +2 -2
- package/lib/menu-item.js +2 -2
- package/lib/menu.js +2011 -1826
- package/lib/message-box.js +923 -898
- package/lib/message.js +911 -886
- package/lib/notification.js +911 -886
- package/lib/option-group.js +2 -2
- package/lib/option.js +907 -882
- package/lib/page-header.js +2 -2
- package/lib/pagination.js +910 -885
- package/lib/phone-login.js +998 -969
- package/lib/popconfirm.js +12 -12
- package/lib/popover.js +2009 -1824
- package/lib/process-config.js +1015 -986
- package/lib/process-module.js +1001 -972
- package/lib/process-rule.js +1019 -990
- package/lib/progress.js +5 -5
- package/lib/qr-code.js +4 -4
- package/lib/qrcode-login.js +1057 -1028
- package/lib/radio-button.js +2 -2
- package/lib/radio-group.js +998 -969
- package/lib/radio.js +2 -2
- package/lib/rate.js +907 -882
- package/lib/row.js +2 -2
- package/lib/scrollbar.js +904 -879
- package/lib/select.js +2135 -1945
- package/lib/selector-panel.js +1009 -980
- package/lib/selector.js +1001 -972
- package/lib/slider.js +2 -2
- package/lib/step.js +2172 -1977
- package/lib/steps.js +907 -882
- package/lib/submenu.js +1119 -959
- package/lib/switch.js +907 -882
- package/lib/tab-pane.js +2 -2
- package/lib/table-column.js +906 -881
- package/lib/table.js +2236 -2047
- package/lib/tabs.js +911 -886
- package/lib/tag.js +2 -2
- package/lib/theme-chalk/base.css +1 -1
- package/lib/theme-chalk/guide.css +1 -0
- package/lib/theme-chalk/icon.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/lowcode-view.css +1 -0
- package/lib/theme-chalk/lowcode.css +1 -1
- package/lib/theme-chalk/main.css +1 -1
- package/lib/theme-chalk/pagination.css +1 -1
- package/lib/theme-chalk/select-dropdown.css +1 -1
- package/lib/theme-chalk/select.css +1 -1
- package/lib/theme-chalk/wujie.css +1 -0
- package/lib/time-picker.js +1977 -1792
- package/lib/time-select.js +1978 -1793
- package/lib/timeline-item.js +2 -2
- package/lib/timeline.js +2 -2
- package/lib/tips.js +998 -969
- package/lib/toolbar.js +2 -2
- package/lib/tooltip.js +2006 -1821
- package/lib/transfer.js +916 -891
- package/lib/tree-group.js +978 -949
- package/lib/tree.js +999 -970
- package/lib/update-history.js +76 -72
- package/lib/upload.js +1028 -999
- package/lib/utils/frame.js +133 -0
- package/lib/wujie.js +5037 -0
- package/package.json +3 -2
- package/packages/cascader/src/cascader.vue +1 -1
- package/packages/date-picker/src/picker.vue +1 -1
- package/packages/form/src/form-item-render.vue +10 -6
- package/packages/guide/index.js +8 -0
- package/packages/guide/src/directive.js +47 -0
- package/packages/guide/src/guide.vue +89 -0
- package/packages/guide/src/manager.js +133 -0
- package/packages/input/src/input.vue +1 -1
- package/packages/lowcode/src/aside.vue +41 -8
- package/packages/lowcode/src/attribute/bind.vue +2 -4
- package/packages/lowcode/src/attribute/dependency.vue +3 -16
- package/packages/lowcode/src/attribute/function.vue +2 -4
- package/packages/lowcode/src/attribute/property.vue +3 -15
- package/packages/lowcode/src/attribute/styles.vue +105 -11
- package/packages/lowcode/src/attribute.vue +5 -35
- package/packages/lowcode/src/canvas.vue +223 -97
- package/packages/lowcode/src/iframe.vue +60 -0
- package/packages/lowcode/src/lowcode.vue +32 -8
- package/packages/lowcode/src/pages.vue +1 -1
- package/packages/lowcode/src/render.vue +312 -70
- package/packages/lowcode/src/util/source-generator.js +7 -11
- package/packages/lowcode/src/util/source-parser.js +1 -1
- package/packages/lowcode-view/index.js +1 -1
- package/packages/lowcode-view/src/Iframe.vue +55 -0
- package/packages/lowcode-view/src/Modulels.vue +239 -0
- package/packages/lowcode-view/src/render.vue +337 -0
- package/packages/lowcode-view/src/view.vue +763 -0
- package/packages/main/src/components/pages.vue +11 -2
- package/packages/main/src/event-center.js +160 -0
- package/packages/main/src/minxs.js +60 -90
- package/packages/progress/src/progress.vue +1 -1
- package/packages/select/src/select.vue +2 -1
- package/packages/theme-chalk/src/common/var.scss +34 -10
- package/packages/theme-chalk/src/guide.scss +93 -0
- package/packages/theme-chalk/src/icon.scss +425 -426
- package/packages/theme-chalk/src/index.scss +2 -0
- package/packages/theme-chalk/src/lowcode-view.scss +288 -0
- package/packages/theme-chalk/src/lowcode.scss +11 -1
- package/packages/theme-chalk/src/select-dropdown.scss +1 -1
- package/packages/theme-chalk/src/wujie.scss +5 -0
- package/packages/wujie/index.js +10 -0
- package/packages/wujie/src/wujie.vue +205 -0
- package/src/config/api.js +3 -0
- package/src/index.js +325 -319
- package/src/utils/frame.js +102 -0
- package/packages/lowcode/src/view.vue +0 -187
package/lib/time-select.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 166);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ({
|
|
@@ -565,7 +565,7 @@ function scrollMove(wrap) {
|
|
|
565
565
|
|
|
566
566
|
/***/ }),
|
|
567
567
|
|
|
568
|
-
/***/
|
|
568
|
+
/***/ 166:
|
|
569
569
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
570
570
|
|
|
571
571
|
"use strict";
|
|
@@ -582,7 +582,7 @@ _date_picker_src_picker_time_select__WEBPACK_IMPORTED_MODULE_0__[/* default */ "
|
|
|
582
582
|
|
|
583
583
|
/***/ }),
|
|
584
584
|
|
|
585
|
-
/***/
|
|
585
|
+
/***/ 18:
|
|
586
586
|
/***/ (function(module, exports) {
|
|
587
587
|
|
|
588
588
|
module.exports = require("eoss/lib/input");
|
|
@@ -639,736 +639,759 @@ module.exports = require("eoss/lib/input");
|
|
|
639
639
|
/* unused harmony export getSecond */
|
|
640
640
|
/* unused harmony export getWeekday */
|
|
641
641
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
/* Modified from https://github.com/taylorhakes/fecha
|
|
643
|
+
*
|
|
644
|
+
* The MIT License (MIT)
|
|
645
|
+
*
|
|
646
|
+
* Copyright (c) 2015 Taylor Hakes
|
|
647
|
+
*
|
|
648
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
649
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
650
|
+
* in the Software without restriction, including without limitation the rights
|
|
651
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
652
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
653
|
+
* furnished to do so, subject to the following conditions:
|
|
654
|
+
*
|
|
655
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
656
|
+
* copies or substantial portions of the Software.
|
|
657
|
+
*
|
|
658
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
659
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
660
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
661
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
662
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
663
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
664
|
+
* SOFTWARE.
|
|
665
|
+
*/
|
|
666
|
+
|
|
667
|
+
/*eslint-disable*/
|
|
668
|
+
// 把 YYYY-MM-DD 改成了 yyyy-MM-dd
|
|
669
|
+
|
|
670
|
+
|
|
644
671
|
/**
|
|
645
672
|
* Parse or format dates
|
|
646
673
|
* @class fecha
|
|
647
|
-
*/
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
function regexEscape(str) {
|
|
658
|
-
return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
function shorten(arr, sLen) {
|
|
662
|
-
|
|
663
|
-
for (
|
|
664
|
-
newArr.push(arr[i].substr(0, sLen));
|
|
665
|
-
}
|
|
666
|
-
return newArr;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
function monthUpdate() {
|
|
670
|
-
return function (d, v) {
|
|
671
|
-
|
|
672
|
-
if (~index) {
|
|
673
|
-
d.month = index;
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
function pad(val, len) {
|
|
679
|
-
val = String(val);
|
|
680
|
-
len = len || 2;
|
|
681
|
-
while (val.length < len) {
|
|
682
|
-
val = '0' + val;
|
|
683
|
-
}
|
|
684
|
-
return val;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
// 直接使用中文日期名称常量
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
return D + '日';
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
D: function
|
|
699
|
-
return dateObj.getDay();
|
|
700
|
-
},
|
|
701
|
-
DD: function
|
|
702
|
-
return pad(dateObj.getDay());
|
|
703
|
-
},
|
|
704
|
-
Do: function
|
|
705
|
-
return DoFn(dateObj.getDate());
|
|
706
|
-
},
|
|
707
|
-
d: function
|
|
708
|
-
return dateObj.getDate();
|
|
709
|
-
},
|
|
710
|
-
dd: function
|
|
711
|
-
return pad(dateObj.getDate());
|
|
712
|
-
},
|
|
713
|
-
ddd: function
|
|
714
|
-
return dayNamesShort[dateObj.getDay()];
|
|
715
|
-
},
|
|
716
|
-
dddd: function
|
|
717
|
-
return dayNames[dateObj.getDay()];
|
|
718
|
-
},
|
|
719
|
-
M: function
|
|
720
|
-
return dateObj.getMonth() + 1;
|
|
721
|
-
},
|
|
722
|
-
MM: function
|
|
723
|
-
return pad(dateObj.getMonth() + 1);
|
|
724
|
-
},
|
|
725
|
-
MMM: function
|
|
726
|
-
return monthNamesShort[dateObj.getMonth()];
|
|
727
|
-
},
|
|
728
|
-
MMMM: function
|
|
729
|
-
return monthNames[dateObj.getMonth()];
|
|
730
|
-
},
|
|
731
|
-
yy: function
|
|
732
|
-
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
733
|
-
},
|
|
734
|
-
yyyy: function
|
|
735
|
-
return pad(dateObj.getFullYear(), 4);
|
|
736
|
-
},
|
|
737
|
-
h: function
|
|
738
|
-
return dateObj.getHours() % 12 || 12;
|
|
739
|
-
},
|
|
740
|
-
hh: function
|
|
741
|
-
return pad(dateObj.getHours() % 12 || 12);
|
|
742
|
-
},
|
|
743
|
-
H: function
|
|
744
|
-
return dateObj.getHours();
|
|
745
|
-
},
|
|
746
|
-
HH: function
|
|
747
|
-
return pad(dateObj.getHours());
|
|
748
|
-
},
|
|
749
|
-
m: function
|
|
750
|
-
return dateObj.getMinutes();
|
|
751
|
-
},
|
|
752
|
-
mm: function
|
|
753
|
-
return pad(dateObj.getMinutes());
|
|
754
|
-
},
|
|
755
|
-
s: function
|
|
756
|
-
return dateObj.getSeconds();
|
|
757
|
-
},
|
|
758
|
-
ss: function
|
|
759
|
-
return pad(dateObj.getSeconds());
|
|
760
|
-
},
|
|
761
|
-
S: function
|
|
762
|
-
return Math.round(dateObj.getMilliseconds() / 100);
|
|
763
|
-
},
|
|
764
|
-
SS: function
|
|
765
|
-
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
766
|
-
},
|
|
767
|
-
SSS: function
|
|
768
|
-
return pad(dateObj.getMilliseconds(), 3);
|
|
769
|
-
},
|
|
770
|
-
a: function
|
|
771
|
-
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
772
|
-
},
|
|
773
|
-
A: function
|
|
774
|
-
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
775
|
-
},
|
|
776
|
-
ZZ: function
|
|
777
|
-
|
|
778
|
-
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
d: [twoDigits, function (d, v) {
|
|
784
|
-
d.day = v;
|
|
785
|
-
}],
|
|
786
|
-
Do: [twoDigits + word, function (d, v) {
|
|
787
|
-
d.day = parseInt(v, 10);
|
|
788
|
-
}],
|
|
789
|
-
M: [twoDigits, function (d, v) {
|
|
790
|
-
d.month = v - 1;
|
|
791
|
-
}],
|
|
792
|
-
yy: [twoDigits, function (d, v) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
parseFlags.
|
|
841
|
-
parseFlags.
|
|
842
|
-
parseFlags.
|
|
843
|
-
parseFlags.
|
|
844
|
-
parseFlags.
|
|
845
|
-
parseFlags.
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
674
|
+
*/
|
|
675
|
+
const fecha = {};
|
|
676
|
+
const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
|
677
|
+
const twoDigits = '\\d\\d?';
|
|
678
|
+
const threeDigits = '\\d{3}';
|
|
679
|
+
const fourDigits = '\\d{4}';
|
|
680
|
+
const word = '[^\\s]+';
|
|
681
|
+
const literal = /\[([^]*?)\]/gm;
|
|
682
|
+
const noop = function () {};
|
|
683
|
+
|
|
684
|
+
function regexEscape(str) {
|
|
685
|
+
return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function shorten(arr, sLen) {
|
|
689
|
+
const newArr = [];
|
|
690
|
+
for (let i = 0, len = arr.length; i < len; i++) {
|
|
691
|
+
newArr.push(arr[i].substr(0, sLen));
|
|
692
|
+
}
|
|
693
|
+
return newArr;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function monthUpdate() {
|
|
697
|
+
return function (d, v) {
|
|
698
|
+
const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
|
|
699
|
+
if (~index) {
|
|
700
|
+
d.month = index;
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function pad(val, len) {
|
|
706
|
+
val = String(val);
|
|
707
|
+
len = len || 2;
|
|
708
|
+
while (val.length < len) {
|
|
709
|
+
val = '0' + val;
|
|
710
|
+
}
|
|
711
|
+
return val;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// 直接使用中文日期名称常量
|
|
715
|
+
const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
|
|
716
|
+
const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
|
|
717
|
+
const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
|
|
718
|
+
const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
|
|
719
|
+
const amPm = ['上午', '下午'];
|
|
720
|
+
const DoFn = function DoFn(D) {
|
|
721
|
+
return D + '日';
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
const formatFlags = {
|
|
725
|
+
D: function(dateObj) {
|
|
726
|
+
return dateObj.getDay();
|
|
727
|
+
},
|
|
728
|
+
DD: function(dateObj) {
|
|
729
|
+
return pad(dateObj.getDay());
|
|
730
|
+
},
|
|
731
|
+
Do: function(dateObj) {
|
|
732
|
+
return DoFn(dateObj.getDate());
|
|
733
|
+
},
|
|
734
|
+
d: function(dateObj) {
|
|
735
|
+
return dateObj.getDate();
|
|
736
|
+
},
|
|
737
|
+
dd: function(dateObj) {
|
|
738
|
+
return pad(dateObj.getDate());
|
|
739
|
+
},
|
|
740
|
+
ddd: function(dateObj) {
|
|
741
|
+
return dayNamesShort[dateObj.getDay()];
|
|
742
|
+
},
|
|
743
|
+
dddd: function(dateObj) {
|
|
744
|
+
return dayNames[dateObj.getDay()];
|
|
745
|
+
},
|
|
746
|
+
M: function(dateObj) {
|
|
747
|
+
return dateObj.getMonth() + 1;
|
|
748
|
+
},
|
|
749
|
+
MM: function(dateObj) {
|
|
750
|
+
return pad(dateObj.getMonth() + 1);
|
|
751
|
+
},
|
|
752
|
+
MMM: function(dateObj) {
|
|
753
|
+
return monthNamesShort[dateObj.getMonth()];
|
|
754
|
+
},
|
|
755
|
+
MMMM: function(dateObj) {
|
|
756
|
+
return monthNames[dateObj.getMonth()];
|
|
757
|
+
},
|
|
758
|
+
yy: function(dateObj) {
|
|
759
|
+
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
760
|
+
},
|
|
761
|
+
yyyy: function(dateObj) {
|
|
762
|
+
return pad(dateObj.getFullYear(), 4);
|
|
763
|
+
},
|
|
764
|
+
h: function(dateObj) {
|
|
765
|
+
return dateObj.getHours() % 12 || 12;
|
|
766
|
+
},
|
|
767
|
+
hh: function(dateObj) {
|
|
768
|
+
return pad(dateObj.getHours() % 12 || 12);
|
|
769
|
+
},
|
|
770
|
+
H: function(dateObj) {
|
|
771
|
+
return dateObj.getHours();
|
|
772
|
+
},
|
|
773
|
+
HH: function(dateObj) {
|
|
774
|
+
return pad(dateObj.getHours());
|
|
775
|
+
},
|
|
776
|
+
m: function(dateObj) {
|
|
777
|
+
return dateObj.getMinutes();
|
|
778
|
+
},
|
|
779
|
+
mm: function(dateObj) {
|
|
780
|
+
return pad(dateObj.getMinutes());
|
|
781
|
+
},
|
|
782
|
+
s: function(dateObj) {
|
|
783
|
+
return dateObj.getSeconds();
|
|
784
|
+
},
|
|
785
|
+
ss: function(dateObj) {
|
|
786
|
+
return pad(dateObj.getSeconds());
|
|
787
|
+
},
|
|
788
|
+
S: function(dateObj) {
|
|
789
|
+
return Math.round(dateObj.getMilliseconds() / 100);
|
|
790
|
+
},
|
|
791
|
+
SS: function(dateObj) {
|
|
792
|
+
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
793
|
+
},
|
|
794
|
+
SSS: function(dateObj) {
|
|
795
|
+
return pad(dateObj.getMilliseconds(), 3);
|
|
796
|
+
},
|
|
797
|
+
a: function(dateObj) {
|
|
798
|
+
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
799
|
+
},
|
|
800
|
+
A: function(dateObj) {
|
|
801
|
+
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
802
|
+
},
|
|
803
|
+
ZZ: function(dateObj) {
|
|
804
|
+
const o = dateObj.getTimezoneOffset();
|
|
805
|
+
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
const parseFlags = {
|
|
810
|
+
d: [twoDigits, function (d, v) {
|
|
811
|
+
d.day = v;
|
|
812
|
+
}],
|
|
813
|
+
Do: [twoDigits + word, function (d, v) {
|
|
814
|
+
d.day = parseInt(v, 10);
|
|
815
|
+
}],
|
|
816
|
+
M: [twoDigits, function (d, v) {
|
|
817
|
+
d.month = v - 1;
|
|
818
|
+
}],
|
|
819
|
+
yy: [twoDigits, function (d, v) {
|
|
820
|
+
const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
|
|
821
|
+
d.year = '' + (v > 68 ? cent - 1 : cent) + v;
|
|
822
|
+
}],
|
|
823
|
+
h: [twoDigits, function (d, v) {
|
|
824
|
+
d.hour = v;
|
|
825
|
+
}],
|
|
826
|
+
m: [twoDigits, function (d, v) {
|
|
827
|
+
d.minute = v;
|
|
828
|
+
}],
|
|
829
|
+
s: [twoDigits, function (d, v) {
|
|
830
|
+
d.second = v;
|
|
831
|
+
}],
|
|
832
|
+
yyyy: [fourDigits, function (d, v) {
|
|
833
|
+
d.year = v;
|
|
834
|
+
}],
|
|
835
|
+
S: ['\\d', function (d, v) {
|
|
836
|
+
d.millisecond = v * 100;
|
|
837
|
+
}],
|
|
838
|
+
SS: ['\\d{2}', function (d, v) {
|
|
839
|
+
d.millisecond = v * 10;
|
|
840
|
+
}],
|
|
841
|
+
SSS: [threeDigits, function (d, v) {
|
|
842
|
+
d.millisecond = v;
|
|
843
|
+
}],
|
|
844
|
+
D: [twoDigits, noop],
|
|
845
|
+
ddd: [word, noop],
|
|
846
|
+
MMM: [word, monthUpdate('monthNamesShort')],
|
|
847
|
+
MMMM: [word, monthUpdate('monthNames')],
|
|
848
|
+
a: [word, function (d, v) {
|
|
849
|
+
const val = v.toLowerCase();
|
|
850
|
+
if (val === '上午') {
|
|
851
|
+
d.isPm = false;
|
|
852
|
+
} else if (val === '下午') {
|
|
853
|
+
d.isPm = true;
|
|
854
|
+
}
|
|
855
|
+
}],
|
|
856
|
+
ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
|
|
857
|
+
let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
|
|
858
|
+
|
|
859
|
+
if (parts) {
|
|
860
|
+
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
|
|
861
|
+
d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
|
|
862
|
+
}
|
|
863
|
+
}]
|
|
864
|
+
};
|
|
865
|
+
parseFlags.dd = parseFlags.d;
|
|
866
|
+
parseFlags.dddd = parseFlags.ddd;
|
|
867
|
+
parseFlags.DD = parseFlags.D;
|
|
868
|
+
parseFlags.mm = parseFlags.m;
|
|
869
|
+
parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
|
|
870
|
+
parseFlags.MM = parseFlags.M;
|
|
871
|
+
parseFlags.ss = parseFlags.s;
|
|
872
|
+
parseFlags.A = parseFlags.a;
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
// Some common format strings
|
|
876
|
+
fecha.masks = {
|
|
877
|
+
default: 'ddd MMM dd yyyy HH:mm:ss',
|
|
878
|
+
shortDate: 'M/D/yy',
|
|
879
|
+
mediumDate: 'MMM d, yyyy',
|
|
880
|
+
longDate: 'MMMM d, yyyy',
|
|
881
|
+
fullDate: 'dddd, MMMM d, yyyy',
|
|
882
|
+
shortTime: 'HH:mm',
|
|
883
|
+
mediumTime: 'HH:mm:ss',
|
|
884
|
+
longTime: 'HH:mm:ss.SSS'
|
|
885
|
+
};
|
|
886
|
+
|
|
861
887
|
/***
|
|
862
888
|
* Format a date
|
|
863
889
|
* @method format
|
|
864
890
|
* @param {Date|number} dateObj
|
|
865
891
|
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
|
866
|
-
*/
|
|
867
|
-
fecha.format = function (dateObj, mask) {
|
|
868
|
-
if (typeof dateObj === 'number') {
|
|
869
|
-
dateObj = new Date(dateObj);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
|
873
|
-
throw new Error('Invalid Date in fecha.format');
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
// Make literals inactive by replacing them with ??
|
|
881
|
-
mask = mask.replace(literal, function
|
|
882
|
-
literals.push($1);
|
|
883
|
-
return '@@@';
|
|
884
|
-
});
|
|
885
|
-
// Apply formatting rules
|
|
886
|
-
mask = mask.replace(token, function ($0) {
|
|
887
|
-
return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
|
|
888
|
-
});
|
|
889
|
-
// Inline literal values back into the formatted value
|
|
890
|
-
return mask.replace(/@@@/g, function
|
|
891
|
-
return literals.shift();
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
|
|
892
|
+
*/
|
|
893
|
+
fecha.format = function (dateObj, mask) {
|
|
894
|
+
if (typeof dateObj === 'number') {
|
|
895
|
+
dateObj = new Date(dateObj);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
|
899
|
+
throw new Error('Invalid Date in fecha.format');
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
903
|
+
|
|
904
|
+
const literals = [];
|
|
905
|
+
|
|
906
|
+
// Make literals inactive by replacing them with ??
|
|
907
|
+
mask = mask.replace(literal, function($0, $1) {
|
|
908
|
+
literals.push($1);
|
|
909
|
+
return '@@@';
|
|
910
|
+
});
|
|
911
|
+
// Apply formatting rules
|
|
912
|
+
mask = mask.replace(token, function ($0) {
|
|
913
|
+
return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
|
|
914
|
+
});
|
|
915
|
+
// Inline literal values back into the formatted value
|
|
916
|
+
return mask.replace(/@@@/g, function() {
|
|
917
|
+
return literals.shift();
|
|
918
|
+
});
|
|
919
|
+
};
|
|
920
|
+
|
|
895
921
|
/**
|
|
896
922
|
* Parse a date string into an object, changes - into /
|
|
897
923
|
* @method parse
|
|
898
924
|
* @param {string} dateStr Date string
|
|
899
925
|
* @param {string} format Date parse format
|
|
900
926
|
* @returns {Date|boolean}
|
|
901
|
-
*/
|
|
902
|
-
fecha.parse = function (dateStr, format) {
|
|
903
|
-
if (typeof format !== 'string') {
|
|
904
|
-
throw new Error('Invalid format in fecha.parse');
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
format = fecha.masks[format] || format;
|
|
908
|
-
|
|
909
|
-
// Avoid regular expression denial of service, fail early for really long strings
|
|
910
|
-
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
|
911
|
-
if (dateStr.length > 1000) {
|
|
912
|
-
return null;
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
format = format.replace(literal, function
|
|
919
|
-
literals.push($1);
|
|
920
|
-
return '@@@';
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
if (parseFlags[$0]) {
|
|
924
|
-
|
|
925
|
-
parseInfo.push(info[1]);
|
|
926
|
-
return '(' + info[0] + ')';
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
return $0;
|
|
930
|
-
});
|
|
931
|
-
newFormat = newFormat.replace(/@@@/g, function
|
|
932
|
-
return literals.shift();
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
if (!matches) {
|
|
936
|
-
return null;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
for (
|
|
940
|
-
parseInfo[i - 1](dateInfo, matches[i]);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
|
945
|
-
dateInfo.hour = +dateInfo.hour + 12;
|
|
946
|
-
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
|
947
|
-
dateInfo.hour = 0;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
if (dateInfo.timezoneOffset != null) {
|
|
952
|
-
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
953
|
-
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if (
|
|
990
|
-
return
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
// 处理多种输入类型
|
|
1001
|
-
if (!date) return '';
|
|
1002
|
-
|
|
1003
|
-
// 如果是时间戳,转成日期对象
|
|
1004
|
-
if (typeof date === 'number') {
|
|
1005
|
-
date = new Date(date);
|
|
1006
|
-
}
|
|
1007
|
-
// 如果是字符串,转成日期对象
|
|
1008
|
-
if (typeof date === 'string') {
|
|
1009
|
-
date = new Date(date);
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// 调用toDate进一步验证和转换
|
|
1013
|
-
date = toDate(date);
|
|
1014
|
-
if (!date) return '';
|
|
1015
|
-
|
|
1016
|
-
// 兼容大写和小写的格式标记
|
|
1017
|
-
// 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
return
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
//
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
|
|
1063
|
-
};
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
return prevDate(result,
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
//
|
|
1097
|
-
|
|
1098
|
-
//
|
|
1099
|
-
|
|
1100
|
-
//
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
for (
|
|
1120
|
-
hours[i] =
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
return
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
return
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
return
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
};
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
return
|
|
1284
|
-
};
|
|
1285
|
-
|
|
1286
|
-
var extractTimeFormat = function extractTimeFormat(format) {
|
|
1287
|
-
return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
|
-
var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
|
|
1291
|
-
return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
|
|
1292
|
-
};
|
|
1293
|
-
|
|
927
|
+
*/
|
|
928
|
+
fecha.parse = function (dateStr, format) {
|
|
929
|
+
if (typeof format !== 'string') {
|
|
930
|
+
throw new Error('Invalid format in fecha.parse');
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
format = fecha.masks[format] || format;
|
|
934
|
+
|
|
935
|
+
// Avoid regular expression denial of service, fail early for really long strings
|
|
936
|
+
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
|
937
|
+
if (dateStr.length > 1000) {
|
|
938
|
+
return null;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
const dateInfo = {};
|
|
942
|
+
const parseInfo = [];
|
|
943
|
+
const literals = [];
|
|
944
|
+
format = format.replace(literal, function($0, $1) {
|
|
945
|
+
literals.push($1);
|
|
946
|
+
return '@@@';
|
|
947
|
+
});
|
|
948
|
+
let newFormat = regexEscape(format).replace(token, function ($0) {
|
|
949
|
+
if (parseFlags[$0]) {
|
|
950
|
+
const info = parseFlags[$0];
|
|
951
|
+
parseInfo.push(info[1]);
|
|
952
|
+
return '(' + info[0] + ')';
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
return $0;
|
|
956
|
+
});
|
|
957
|
+
newFormat = newFormat.replace(/@@@/g, function() {
|
|
958
|
+
return literals.shift();
|
|
959
|
+
});
|
|
960
|
+
const matches = dateStr.match(new RegExp(newFormat, 'i'));
|
|
961
|
+
if (!matches) {
|
|
962
|
+
return null;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
for (let i = 1; i < matches.length; i++) {
|
|
966
|
+
parseInfo[i - 1](dateInfo, matches[i]);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
const today = new Date();
|
|
970
|
+
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
|
971
|
+
dateInfo.hour = +dateInfo.hour + 12;
|
|
972
|
+
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
|
973
|
+
dateInfo.hour = 0;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
let date;
|
|
977
|
+
if (dateInfo.timezoneOffset != null) {
|
|
978
|
+
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
979
|
+
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
|
980
|
+
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
|
|
981
|
+
} else {
|
|
982
|
+
date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
|
983
|
+
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
|
|
984
|
+
}
|
|
985
|
+
return date;
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
// 导出fecha对象
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
// 以下是从date-util.js合并的函数
|
|
992
|
+
const newArray = function(start, end) {
|
|
993
|
+
let result = [];
|
|
994
|
+
for (let i = start; i <= end; i++) {
|
|
995
|
+
result.push(i);
|
|
996
|
+
}
|
|
997
|
+
return result;
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
const getSettings = () => {
|
|
1001
|
+
return {
|
|
1002
|
+
dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
|
|
1003
|
+
dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
|
1004
|
+
monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
|
1005
|
+
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
|
1006
|
+
amPm: ['上午', '下午']
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
const toDate = function(date) {
|
|
1011
|
+
return isDate(date) ? new Date(date) : null;
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
const isDate = function(date) {
|
|
1015
|
+
if (date === null || date === undefined) return false;
|
|
1016
|
+
if (isNaN(new Date(date).getTime())) return false;
|
|
1017
|
+
if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
|
|
1018
|
+
return true;
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
const isDateObject = function(val) {
|
|
1022
|
+
return val instanceof Date;
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
const formatDate = function (date, format = 'yyyy-MM-dd') {
|
|
1026
|
+
// 处理多种输入类型
|
|
1027
|
+
if (!date) return '';
|
|
1028
|
+
|
|
1029
|
+
// 如果是时间戳,转成日期对象
|
|
1030
|
+
if (typeof date === 'number') {
|
|
1031
|
+
date = new Date(date);
|
|
1032
|
+
}
|
|
1033
|
+
// 如果是字符串,转成日期对象
|
|
1034
|
+
if (typeof date === 'string') {
|
|
1035
|
+
date = new Date(date);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// 调用toDate进一步验证和转换
|
|
1039
|
+
date = toDate(date);
|
|
1040
|
+
if (!date) return '';
|
|
1041
|
+
|
|
1042
|
+
// 兼容大写和小写的格式标记
|
|
1043
|
+
// 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
|
|
1044
|
+
const lowercaseFormat = format
|
|
1045
|
+
.replace(/YYYY/g, 'yyyy')
|
|
1046
|
+
.replace(/D/g, 'd')
|
|
1047
|
+
|
|
1048
|
+
// 使用fecha库进行格式化,支持中文配置
|
|
1049
|
+
const str = fecha.format(date, lowercaseFormat, getSettings());
|
|
1050
|
+
return str;
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
const parseDate = function(string, format) {
|
|
1054
|
+
return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
const getDayCountOfMonth = function(year, month) {
|
|
1058
|
+
if (month === 3 || month === 5 || month === 8 || month === 10) {
|
|
1059
|
+
return 30;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
if (month === 1) {
|
|
1063
|
+
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
|
|
1064
|
+
return 29;
|
|
1065
|
+
} else {
|
|
1066
|
+
return 28;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
return 31;
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
const getDayCountOfYear = function(year) {
|
|
1074
|
+
const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
|
|
1075
|
+
return isLeapYear ? 366 : 365;
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
const getFirstDayOfMonth = function(date) {
|
|
1079
|
+
const temp = new Date(date.getTime());
|
|
1080
|
+
temp.setDate(1);
|
|
1081
|
+
return temp.getDay();
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
// see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
|
|
1085
|
+
// {prev, next} Date should work for Daylight Saving Time
|
|
1086
|
+
// Adding 24 * 60 * 60 * 1000 does not work in the above scenario
|
|
1087
|
+
const prevDate = function(date, amount = 1) {
|
|
1088
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1091
|
+
const nextDate = function(date, amount = 1) {
|
|
1092
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
const getStartDateOfMonth = function(year, month) {
|
|
1096
|
+
const result = new Date(year, month, 1);
|
|
1097
|
+
const day = result.getDay();
|
|
1098
|
+
|
|
1099
|
+
if (day === 0) {
|
|
1100
|
+
return prevDate(result, 7);
|
|
1101
|
+
} else {
|
|
1102
|
+
return prevDate(result, day);
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
const getWeekNumber = function(date) {
|
|
1107
|
+
// 支持多种输入类型
|
|
1108
|
+
if (!date||!isDate(date)) {
|
|
1109
|
+
date = new Date();
|
|
1110
|
+
}
|
|
1111
|
+
if (typeof date === 'string') {
|
|
1112
|
+
date = new Date(date);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// 验证日期有效性
|
|
1116
|
+
if (!isDate(date)) return null;
|
|
1117
|
+
|
|
1118
|
+
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
1119
|
+
// 设置为最近的星期四:当前日期 + 4 - 当前星期数
|
|
1120
|
+
// 将星期日的星期数设为7
|
|
1121
|
+
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
|
|
1122
|
+
// 获取当年的第一天
|
|
1123
|
+
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
1124
|
+
// 计算到最近的星期四的完整周数
|
|
1125
|
+
const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
|
|
1126
|
+
// 返回周数
|
|
1127
|
+
return weekNo;
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
const getRangeHours = function(ranges) {
|
|
1131
|
+
const hours = [];
|
|
1132
|
+
let disabledHours = [];
|
|
1133
|
+
|
|
1134
|
+
(ranges || []).forEach(range => {
|
|
1135
|
+
const value = range.map(date => date.getHours());
|
|
1136
|
+
|
|
1137
|
+
disabledHours = disabledHours.concat(newArray(value[0], value[1]));
|
|
1138
|
+
});
|
|
1139
|
+
|
|
1140
|
+
if (disabledHours.length) {
|
|
1141
|
+
for (let i = 0; i < 24; i++) {
|
|
1142
|
+
hours[i] = disabledHours.indexOf(i) === -1;
|
|
1143
|
+
}
|
|
1144
|
+
} else {
|
|
1145
|
+
for (let i = 0; i < 24; i++) {
|
|
1146
|
+
hours[i] = false;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
return hours;
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
const getPrevMonthLastDays = (date, amount) => {
|
|
1154
|
+
if (amount <= 0) return [];
|
|
1155
|
+
const temp = new Date(date.getTime());
|
|
1156
|
+
temp.setDate(0);
|
|
1157
|
+
const lastDay = temp.getDate();
|
|
1158
|
+
return range(amount).map((_, index) => lastDay - (amount - index - 1));
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
const getMonthDays = (date) => {
|
|
1162
|
+
const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
1163
|
+
const days = temp.getDate();
|
|
1164
|
+
return range(days).map((_, index) => index + 1);
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
function setRangeData(arr, start, end, value) {
|
|
1168
|
+
for (let i = start; i < end; i++) {
|
|
1169
|
+
arr[i] = value;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
const getRangeMinutes = function(ranges, hour) {
|
|
1174
|
+
const minutes = new Array(60);
|
|
1175
|
+
|
|
1176
|
+
if (ranges.length > 0) {
|
|
1177
|
+
ranges.forEach(range => {
|
|
1178
|
+
const start = range[0];
|
|
1179
|
+
const end = range[1];
|
|
1180
|
+
const startHour = start.getHours();
|
|
1181
|
+
const startMinute = start.getMinutes();
|
|
1182
|
+
const endHour = end.getHours();
|
|
1183
|
+
const endMinute = end.getMinutes();
|
|
1184
|
+
if (startHour === hour && endHour !== hour) {
|
|
1185
|
+
setRangeData(minutes, startMinute, 60, true);
|
|
1186
|
+
} else if (startHour === hour && endHour === hour) {
|
|
1187
|
+
setRangeData(minutes, startMinute, endMinute + 1, true);
|
|
1188
|
+
} else if (startHour !== hour && endHour === hour) {
|
|
1189
|
+
setRangeData(minutes, 0, endMinute + 1, true);
|
|
1190
|
+
} else if (startHour < hour && endHour > hour) {
|
|
1191
|
+
setRangeData(minutes, 0, 60, true);
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
} else {
|
|
1195
|
+
setRangeData(minutes, 0, 60, true);
|
|
1196
|
+
}
|
|
1197
|
+
return minutes;
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
const range = function(n) {
|
|
1201
|
+
// see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
|
|
1202
|
+
return Array.apply(null, {length: n}).map((_, n) => n);
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
const modifyDate = function(date, y, m, d) {
|
|
1206
|
+
return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
const modifyTime = function(date, h, m, s) {
|
|
1210
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
const modifyWithTimeString = (date, time) => {
|
|
1214
|
+
if (date == null || !time) {
|
|
1215
|
+
return date;
|
|
1216
|
+
}
|
|
1217
|
+
time = parseDate(time, 'HH:mm:ss');
|
|
1218
|
+
return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
|
|
1219
|
+
};
|
|
1220
|
+
|
|
1221
|
+
const clearTime = function(date) {
|
|
1222
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1225
|
+
const clearMilliseconds = function(date) {
|
|
1226
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
|
|
1230
|
+
// TODO: refactory a more elegant solution
|
|
1231
|
+
if (ranges.length === 0) return date;
|
|
1232
|
+
const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
|
|
1233
|
+
const ndate = normalizeDate(date);
|
|
1234
|
+
const nranges = ranges.map(range => range.map(normalizeDate));
|
|
1235
|
+
if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
|
|
1236
|
+
|
|
1237
|
+
let minDate = nranges[0][0];
|
|
1238
|
+
let maxDate = nranges[0][0];
|
|
1239
|
+
|
|
1240
|
+
nranges.forEach(nrange => {
|
|
1241
|
+
minDate = new Date(Math.min(nrange[0], minDate));
|
|
1242
|
+
maxDate = new Date(Math.max(nrange[1], minDate));
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1245
|
+
const ret = ndate < minDate ? minDate : maxDate;
|
|
1246
|
+
// preserve Year/Month/Date
|
|
1247
|
+
return modifyDate(
|
|
1248
|
+
ret,
|
|
1249
|
+
date.getFullYear(),
|
|
1250
|
+
date.getMonth(),
|
|
1251
|
+
date.getDate()
|
|
1252
|
+
);
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
const timeWithinRange = function(date, selectableRange, format) {
|
|
1256
|
+
const limitedDate = limitTimeRange(date, selectableRange, format);
|
|
1257
|
+
return limitedDate.getTime() === date.getTime();
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1260
|
+
const changeYearMonthAndClampDate = function(date, year, month) {
|
|
1261
|
+
// clamp date to the number of days in `year`, `month`
|
|
1262
|
+
// eg: (2010-1-31, 2010, 2) => 2010-2-28
|
|
1263
|
+
const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
|
|
1264
|
+
return modifyDate(date, year, month, monthDate);
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
const prevMonth = function(date) {
|
|
1268
|
+
const year = date.getFullYear();
|
|
1269
|
+
const month = date.getMonth();
|
|
1270
|
+
return month === 0
|
|
1271
|
+
? changeYearMonthAndClampDate(date, year - 1, 11)
|
|
1272
|
+
: changeYearMonthAndClampDate(date, year, month - 1);
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
const nextMonth = function(date) {
|
|
1276
|
+
const year = date.getFullYear();
|
|
1277
|
+
const month = date.getMonth();
|
|
1278
|
+
return month === 11
|
|
1279
|
+
? changeYearMonthAndClampDate(date, year + 1, 0)
|
|
1280
|
+
: changeYearMonthAndClampDate(date, year, month + 1);
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
const prevYear = function(date, amount = 1) {
|
|
1284
|
+
const year = date.getFullYear();
|
|
1285
|
+
const month = date.getMonth();
|
|
1286
|
+
return changeYearMonthAndClampDate(date, year - amount, month);
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
const nextYear = function(date, amount = 1) {
|
|
1290
|
+
const year = date.getFullYear();
|
|
1291
|
+
const month = date.getMonth();
|
|
1292
|
+
return changeYearMonthAndClampDate(date, year + amount, month);
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
const extractDateFormat = function(format) {
|
|
1296
|
+
return format
|
|
1297
|
+
.replace(/\W?m{1,2}|\W?ZZ/g, '')
|
|
1298
|
+
.replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
|
|
1299
|
+
.trim();
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
const extractTimeFormat = function(format) {
|
|
1303
|
+
return format
|
|
1304
|
+
.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
|
|
1305
|
+
.trim();
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1308
|
+
const validateRangeInOneMonth = function(start, end) {
|
|
1309
|
+
return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1294
1312
|
/**
|
|
1295
1313
|
* 计算两个日期之间的工作日数量(不包括周末和节假日)
|
|
1296
1314
|
* @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
|
|
1297
1315
|
* @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
|
|
1298
1316
|
* @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
|
|
1299
1317
|
* @returns {number} 工作日数量
|
|
1300
|
-
*/
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
1312
|
-
throw new Error(
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1318
|
+
*/
|
|
1319
|
+
const calculateNetworkDays = function (start_date, end_date, holidays = []) {
|
|
1320
|
+
if (typeof start_date !== 'string' || typeof end_date !== 'string') {
|
|
1321
|
+
throw new Error(
|
|
1322
|
+
"Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
const startDateObj = new Date(start_date);
|
|
1327
|
+
const endDateObj = new Date(end_date);
|
|
1328
|
+
|
|
1329
|
+
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
1330
|
+
throw new Error(
|
|
1331
|
+
"Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
if (startDateObj > endDateObj) {
|
|
1336
|
+
throw new Error('Start date should be earlier than or equal to end date.');
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
let workdays = 0;
|
|
1340
|
+
|
|
1341
|
+
// Iterate through each day in the date range
|
|
1342
|
+
for (
|
|
1343
|
+
let currentDate = new Date(startDateObj);
|
|
1344
|
+
currentDate <= endDateObj;
|
|
1345
|
+
currentDate.setDate(currentDate.getDate() + 1)
|
|
1346
|
+
) {
|
|
1347
|
+
// Check if the current day is a weekend (Saturday or Sunday)
|
|
1348
|
+
const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
|
|
1349
|
+
|
|
1350
|
+
// Check if the current day is a holiday
|
|
1351
|
+
const isHoliday = holidays.some((holiday) => {
|
|
1352
|
+
const holidayDate = new Date(holiday);
|
|
1353
|
+
return currentDate.toDateString() === holidayDate.toDateString();
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
// If it's a workday (not a weekend or holiday), increment the workdays count
|
|
1357
|
+
if (!isWeekend && !isHoliday) {
|
|
1358
|
+
workdays++;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
return workdays;
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1346
1365
|
/**
|
|
1347
1366
|
* 日期加减天数
|
|
1348
1367
|
* @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
|
|
1349
1368
|
* @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
|
|
1350
1369
|
* @returns {string} 结果日期,格式为 "YYYY-MM-DD"
|
|
1351
|
-
*/
|
|
1352
|
-
|
|
1353
|
-
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
1354
|
-
throw new Error(
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1370
|
+
*/
|
|
1371
|
+
const dateAddDays = function (start_date, days) {
|
|
1372
|
+
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
1373
|
+
throw new Error(
|
|
1374
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
const startDateObj = new Date(start_date);
|
|
1379
|
+
if (isNaN(startDateObj.getTime())) {
|
|
1380
|
+
throw new Error(
|
|
1381
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
const resultDateObj = new Date(startDateObj);
|
|
1386
|
+
resultDateObj.setDate(resultDateObj.getDate() + days);
|
|
1387
|
+
|
|
1388
|
+
const resultYear = resultDateObj.getFullYear();
|
|
1389
|
+
const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
|
|
1390
|
+
const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
|
|
1391
|
+
|
|
1392
|
+
return `${resultYear}-${resultMonth}-${resultDay}`;
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1372
1395
|
/**
|
|
1373
1396
|
* 计算两个日期之间的差值
|
|
1374
1397
|
* @date 2023年12月14日
|
|
@@ -1376,180 +1399,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
|
|
|
1376
1399
|
* @param {String} end_date - 结束日期字符串
|
|
1377
1400
|
* @param {String} unit - 单位:year/month/day
|
|
1378
1401
|
* @returns {Number} 差值
|
|
1379
|
-
*/
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
if (unit === '
|
|
1393
|
-
return
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1402
|
+
*/
|
|
1403
|
+
const dateDiff = function (start_date, end_date, unit = 'day') {
|
|
1404
|
+
// Assuming date strings are in "YYYY-MM-DD" format
|
|
1405
|
+
var startDate = new Date(start_date);
|
|
1406
|
+
var endDate = new Date(end_date);
|
|
1407
|
+
|
|
1408
|
+
// If the date is invalid, return 0
|
|
1409
|
+
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
|
1410
|
+
return 0;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
if (unit === 'year') {
|
|
1414
|
+
return endDate.getFullYear() - startDate.getFullYear();
|
|
1415
|
+
} else if (unit === 'month') {
|
|
1416
|
+
return (
|
|
1417
|
+
(endDate.getFullYear() - startDate.getFullYear()) * 12 +
|
|
1418
|
+
(endDate.getMonth() - startDate.getMonth())
|
|
1419
|
+
);
|
|
1420
|
+
} else {
|
|
1421
|
+
// Default to day
|
|
1422
|
+
var timeDifference = endDate - startDate;
|
|
1423
|
+
// Calculate days (86400000 milliseconds per day)
|
|
1424
|
+
return Math.floor(timeDifference / 86400000);
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1404
1428
|
/**
|
|
1405
1429
|
* 获取月份中的日期
|
|
1406
1430
|
* @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
|
|
1407
1431
|
* @returns {number} 月份中的日期(1-31)
|
|
1408
|
-
*/
|
|
1409
|
-
|
|
1410
|
-
if (typeof date !== 'string') {
|
|
1411
|
-
throw new Error(
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1432
|
+
*/
|
|
1433
|
+
const dayOfMonth = function (date) {
|
|
1434
|
+
if (typeof date !== 'string') {
|
|
1435
|
+
throw new Error(
|
|
1436
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1437
|
+
);
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
const dateObj = new Date(date);
|
|
1441
|
+
if (isNaN(dateObj.getTime())) {
|
|
1442
|
+
throw new Error(
|
|
1443
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
return dateObj.getDate();
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1422
1450
|
/**
|
|
1423
1451
|
* 获取当前日期
|
|
1424
1452
|
* @date 2022年5月7日
|
|
1425
1453
|
* @param {string} format - 日期格式,默认为'YYYY-MM-DD'
|
|
1426
1454
|
* @returns {string} 当前日期的格式化字符串
|
|
1427
|
-
*/
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
};
|
|
1433
|
-
|
|
1455
|
+
*/
|
|
1456
|
+
const getCurrentDate = function (format = 'YYYY-MM-DD') {
|
|
1457
|
+
return formatDate(new Date(), format);
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1434
1460
|
/**
|
|
1435
1461
|
* 获取当前日期时间
|
|
1436
1462
|
* @date 2022年5月7日
|
|
1437
1463
|
* @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
|
|
1438
1464
|
* @returns {string} 当前日期时间的格式化字符串
|
|
1439
|
-
*/
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
};
|
|
1445
|
-
|
|
1465
|
+
*/
|
|
1466
|
+
const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
|
|
1467
|
+
return formatDate(new Date(), format);
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1446
1470
|
/**
|
|
1447
1471
|
* 获取小时
|
|
1448
1472
|
* @date 2022年5月7日
|
|
1449
1473
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
1450
1474
|
* @returns {number} 小时数(0-23)
|
|
1451
|
-
*/
|
|
1452
|
-
|
|
1453
|
-
if (!date) {
|
|
1454
|
-
return new Date().getHours();
|
|
1455
|
-
}
|
|
1456
|
-
if (typeof date === 'string') {
|
|
1457
|
-
date = new Date(date);
|
|
1458
|
-
}
|
|
1459
|
-
return date.getHours();
|
|
1460
|
-
};
|
|
1461
|
-
|
|
1475
|
+
*/
|
|
1476
|
+
const getHour = function (date) {
|
|
1477
|
+
if (!date) {
|
|
1478
|
+
return new Date().getHours();
|
|
1479
|
+
}
|
|
1480
|
+
if (typeof date === 'string') {
|
|
1481
|
+
date = new Date(date);
|
|
1482
|
+
}
|
|
1483
|
+
return date.getHours();
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1462
1486
|
/**
|
|
1463
1487
|
* 获取分钟
|
|
1464
1488
|
* @date 2022年5月7日
|
|
1465
1489
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
1466
1490
|
* @returns {number} 分钟数(0-59)
|
|
1467
|
-
*/
|
|
1468
|
-
|
|
1469
|
-
if (!date) {
|
|
1470
|
-
return new Date().getMinutes();
|
|
1471
|
-
}
|
|
1472
|
-
if (typeof date === 'string') {
|
|
1473
|
-
date = new Date(date);
|
|
1474
|
-
}
|
|
1475
|
-
return date.getMinutes();
|
|
1476
|
-
};
|
|
1477
|
-
|
|
1491
|
+
*/
|
|
1492
|
+
const getMinute = function (date) {
|
|
1493
|
+
if (!date) {
|
|
1494
|
+
return new Date().getMinutes();
|
|
1495
|
+
}
|
|
1496
|
+
if (typeof date === 'string') {
|
|
1497
|
+
date = new Date(date);
|
|
1498
|
+
}
|
|
1499
|
+
return date.getMinutes();
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1478
1502
|
/**
|
|
1479
1503
|
* 获取月份
|
|
1480
1504
|
* @date 2022年5月7日
|
|
1481
1505
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
1482
1506
|
* @returns {number} 月份数(1-12)
|
|
1483
|
-
*/
|
|
1484
|
-
|
|
1485
|
-
if (!date) {
|
|
1486
|
-
return new Date().getMonth() + 1;
|
|
1487
|
-
}
|
|
1488
|
-
if (typeof date === 'string') {
|
|
1489
|
-
date = new Date(date);
|
|
1490
|
-
}
|
|
1491
|
-
return date.getMonth() + 1;
|
|
1492
|
-
};
|
|
1493
|
-
|
|
1507
|
+
*/
|
|
1508
|
+
const getMonth = function (date) {
|
|
1509
|
+
if (!date) {
|
|
1510
|
+
return new Date().getMonth() + 1;
|
|
1511
|
+
}
|
|
1512
|
+
if (typeof date === 'string') {
|
|
1513
|
+
date = new Date(date);
|
|
1514
|
+
}
|
|
1515
|
+
return date.getMonth() + 1;
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1494
1518
|
/**
|
|
1495
1519
|
* 获取秒
|
|
1496
1520
|
* @date 2022年5月7日
|
|
1497
1521
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
1498
1522
|
* @returns {number} 秒数(0-59)
|
|
1499
|
-
*/
|
|
1500
|
-
|
|
1501
|
-
if (!date) {
|
|
1502
|
-
return new Date().getSeconds();
|
|
1503
|
-
}
|
|
1504
|
-
if (typeof date === 'string') {
|
|
1505
|
-
date = new Date(date);
|
|
1506
|
-
}
|
|
1507
|
-
return date.getSeconds();
|
|
1508
|
-
};
|
|
1509
|
-
|
|
1523
|
+
*/
|
|
1524
|
+
const getSecond = function (date) {
|
|
1525
|
+
if (!date) {
|
|
1526
|
+
return new Date().getSeconds();
|
|
1527
|
+
}
|
|
1528
|
+
if (typeof date === 'string') {
|
|
1529
|
+
date = new Date(date);
|
|
1530
|
+
}
|
|
1531
|
+
return date.getSeconds();
|
|
1532
|
+
};
|
|
1533
|
+
|
|
1510
1534
|
/**
|
|
1511
1535
|
* 获取星期几
|
|
1512
1536
|
* @date 2022年5月7日
|
|
1513
1537
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
1514
1538
|
* @returns {number} 星期几(0-6,0表示星期日)
|
|
1515
|
-
*/
|
|
1516
|
-
|
|
1517
|
-
if (!date) {
|
|
1518
|
-
return new Date().getDay();
|
|
1519
|
-
}
|
|
1520
|
-
if (typeof date === 'string') {
|
|
1521
|
-
date = new Date(date);
|
|
1522
|
-
}
|
|
1523
|
-
return date.getDay();
|
|
1524
|
-
};
|
|
1525
|
-
|
|
1539
|
+
*/
|
|
1540
|
+
const getWeekday = function (date) {
|
|
1541
|
+
if (!date) {
|
|
1542
|
+
return new Date().getDay();
|
|
1543
|
+
}
|
|
1544
|
+
if (typeof date === 'string') {
|
|
1545
|
+
date = new Date(date);
|
|
1546
|
+
}
|
|
1547
|
+
return date.getDay();
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
|
|
1526
1551
|
/**
|
|
1527
1552
|
* @desc 获取上午/下午/晚上
|
|
1528
1553
|
* @author huangbo
|
|
1529
1554
|
* @date 2022年5月7日
|
|
1530
1555
|
* @param {String} [time] - 时间
|
|
1531
|
-
**/
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
if (!time) {
|
|
1535
|
-
hour = new Date().getHours();
|
|
1536
|
-
} else if (typeof time === 'string') {
|
|
1537
|
-
// 从时间字符串中提取小时
|
|
1538
|
-
|
|
1539
|
-
if (match) {
|
|
1540
|
-
hour = parseInt(match[1], 10);
|
|
1541
|
-
}
|
|
1542
|
-
} else if (typeof time === 'number') {
|
|
1543
|
-
hour = time;
|
|
1544
|
-
}
|
|
1545
|
-
// 判断时间段
|
|
1546
|
-
if (hour >= 5 && hour < 12) {
|
|
1547
|
-
return '上午';
|
|
1548
|
-
} else if (hour >= 12 && hour < 18) {
|
|
1549
|
-
return '下午';
|
|
1550
|
-
} else {
|
|
1551
|
-
return '晚上';
|
|
1552
|
-
}
|
|
1556
|
+
**/
|
|
1557
|
+
const timeCycle = function (time) {
|
|
1558
|
+
let hour = 0;
|
|
1559
|
+
if (!time) {
|
|
1560
|
+
hour = new Date().getHours();
|
|
1561
|
+
} else if (typeof time === 'string') {
|
|
1562
|
+
// 从时间字符串中提取小时
|
|
1563
|
+
const match = time.match(/^(\d{1,2})/);
|
|
1564
|
+
if (match) {
|
|
1565
|
+
hour = parseInt(match[1], 10);
|
|
1566
|
+
}
|
|
1567
|
+
} else if (typeof time === 'number') {
|
|
1568
|
+
hour = time;
|
|
1569
|
+
}
|
|
1570
|
+
// 判断时间段
|
|
1571
|
+
if (hour >= 5 && hour < 12) {
|
|
1572
|
+
return '上午';
|
|
1573
|
+
} else if (hour >= 12 && hour < 18) {
|
|
1574
|
+
return '下午';
|
|
1575
|
+
} else {
|
|
1576
|
+
return '晚上';
|
|
1577
|
+
}
|
|
1553
1578
|
};
|
|
1554
1579
|
|
|
1555
1580
|
/***/ }),
|
|
@@ -2254,7 +2279,7 @@ module.exports = require("vue");
|
|
|
2254
2279
|
|
|
2255
2280
|
"use strict";
|
|
2256
2281
|
|
|
2257
|
-
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/picker.vue?vue&type=template&id=
|
|
2282
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/picker.vue?vue&type=template&id=684f520c&
|
|
2258
2283
|
var render = function () {
|
|
2259
2284
|
var _vm = this
|
|
2260
2285
|
var _h = _vm.$createElement
|
|
@@ -2434,7 +2459,7 @@ var staticRenderFns = []
|
|
|
2434
2459
|
render._withStripped = true
|
|
2435
2460
|
|
|
2436
2461
|
|
|
2437
|
-
// CONCATENATED MODULE: ./packages/date-picker/src/picker.vue?vue&type=template&id=
|
|
2462
|
+
// CONCATENATED MODULE: ./packages/date-picker/src/picker.vue?vue&type=template&id=684f520c&
|
|
2438
2463
|
|
|
2439
2464
|
// EXTERNAL MODULE: external "vue"
|
|
2440
2465
|
var external_vue_ = __webpack_require__(4);
|
|
@@ -2453,7 +2478,7 @@ var vue_popper = __webpack_require__(13);
|
|
|
2453
2478
|
var emitter = __webpack_require__(10);
|
|
2454
2479
|
|
|
2455
2480
|
// EXTERNAL MODULE: external "eoss/lib/input"
|
|
2456
|
-
var input_ = __webpack_require__(
|
|
2481
|
+
var input_ = __webpack_require__(18);
|
|
2457
2482
|
var input_default = /*#__PURE__*/__webpack_require__.n(input_);
|
|
2458
2483
|
|
|
2459
2484
|
// EXTERNAL MODULE: ./src/utils/merge.js
|
|
@@ -2860,7 +2885,7 @@ var validator = function validator(val) {
|
|
|
2860
2885
|
*/
|
|
2861
2886
|
clearIcon: {
|
|
2862
2887
|
type: String,
|
|
2863
|
-
default: 'es-icon-circle-
|
|
2888
|
+
default: 'es-icon-circle-guanbi'
|
|
2864
2889
|
},
|
|
2865
2890
|
/**
|
|
2866
2891
|
* 原生属性
|
|
@@ -3643,9 +3668,7 @@ var component = Object(componentNormalizer["a" /* default */])(
|
|
|
3643
3668
|
/***/ 42:
|
|
3644
3669
|
/***/ (function(module, exports, __webpack_require__) {
|
|
3645
3670
|
|
|
3646
|
-
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__
|
|
3647
|
-
|
|
3648
|
-
/**
|
|
3671
|
+
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
3649
3672
|
* @fileOverview Kickass library to create and place poppers near their reference elements.
|
|
3650
3673
|
* @version {{version}}
|
|
3651
3674
|
* @license
|
|
@@ -3668,60 +3691,68 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
3668
3691
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3669
3692
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
3670
3693
|
* SOFTWARE.
|
|
3671
|
-
*/
|
|
3672
|
-
|
|
3673
|
-
//
|
|
3674
|
-
// Cross module loader
|
|
3675
|
-
// Supported: Node, AMD, Browser globals
|
|
3676
|
-
//
|
|
3677
|
-
(function (root, factory) {
|
|
3678
|
-
if (true) {
|
|
3679
|
-
// AMD. Register as an anonymous module.
|
|
3694
|
+
*/
|
|
3695
|
+
|
|
3696
|
+
//
|
|
3697
|
+
// Cross module loader
|
|
3698
|
+
// Supported: Node, AMD, Browser globals
|
|
3699
|
+
//
|
|
3700
|
+
(function (root, factory) {
|
|
3701
|
+
if (true) {
|
|
3702
|
+
// AMD. Register as an anonymous module.
|
|
3680
3703
|
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
|
3681
3704
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
|
3682
3705
|
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
|
|
3683
3706
|
__WEBPACK_AMD_DEFINE_FACTORY__),
|
|
3684
|
-
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
3685
|
-
} else {}
|
|
3686
|
-
})(this, function () {
|
|
3687
|
-
'use strict';
|
|
3688
|
-
|
|
3689
|
-
var root =
|
|
3690
|
-
// default options
|
|
3691
|
-
var DEFAULTS = {
|
|
3692
|
-
// placement of the popper
|
|
3693
|
-
placement: 'bottom',
|
|
3694
|
-
|
|
3695
|
-
gpuAcceleration: true,
|
|
3696
|
-
|
|
3697
|
-
// shift popper from its origin by the given amount of pixels (can be negative)
|
|
3698
|
-
offset: 0,
|
|
3699
|
-
|
|
3700
|
-
// the element which will act as boundary of the popper
|
|
3701
|
-
boundariesElement: 'viewport',
|
|
3702
|
-
|
|
3703
|
-
// amount of pixel used to define a minimum distance between the boundaries and the popper
|
|
3704
|
-
boundariesPadding: 5,
|
|
3705
|
-
|
|
3706
|
-
// popper will try to prevent overflow following this order,
|
|
3707
|
-
// by default, then, it could overflow on the left and on top of the boundariesElement
|
|
3708
|
-
preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
|
|
3709
|
-
|
|
3710
|
-
// the behavior used by flip to change the placement of the popper
|
|
3711
|
-
flipBehavior: 'flip',
|
|
3712
|
-
|
|
3713
|
-
arrowElement: '[x-arrow]',
|
|
3714
|
-
|
|
3715
|
-
arrowOffset: 0,
|
|
3716
|
-
|
|
3717
|
-
// list of functions used to modify the offsets before they are applied to the popper
|
|
3718
|
-
modifiers: [
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3707
|
+
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
3708
|
+
} else {}
|
|
3709
|
+
})(this, function () {
|
|
3710
|
+
'use strict';
|
|
3711
|
+
|
|
3712
|
+
var root = window;
|
|
3713
|
+
// default options
|
|
3714
|
+
var DEFAULTS = {
|
|
3715
|
+
// placement of the popper
|
|
3716
|
+
placement: 'bottom',
|
|
3717
|
+
|
|
3718
|
+
gpuAcceleration: true,
|
|
3719
|
+
|
|
3720
|
+
// shift popper from its origin by the given amount of pixels (can be negative)
|
|
3721
|
+
offset: 0,
|
|
3722
|
+
|
|
3723
|
+
// the element which will act as boundary of the popper
|
|
3724
|
+
boundariesElement: 'viewport',
|
|
3725
|
+
|
|
3726
|
+
// amount of pixel used to define a minimum distance between the boundaries and the popper
|
|
3727
|
+
boundariesPadding: 5,
|
|
3728
|
+
|
|
3729
|
+
// popper will try to prevent overflow following this order,
|
|
3730
|
+
// by default, then, it could overflow on the left and on top of the boundariesElement
|
|
3731
|
+
preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
|
|
3732
|
+
|
|
3733
|
+
// the behavior used by flip to change the placement of the popper
|
|
3734
|
+
flipBehavior: 'flip',
|
|
3735
|
+
|
|
3736
|
+
arrowElement: '[x-arrow]',
|
|
3737
|
+
|
|
3738
|
+
arrowOffset: 0,
|
|
3739
|
+
|
|
3740
|
+
// list of functions used to modify the offsets before they are applied to the popper
|
|
3741
|
+
modifiers: [
|
|
3742
|
+
'shift',
|
|
3743
|
+
'offset',
|
|
3744
|
+
'preventOverflow',
|
|
3745
|
+
'keepTogether',
|
|
3746
|
+
'arrow',
|
|
3747
|
+
'flip',
|
|
3748
|
+
'applyStyle'
|
|
3749
|
+
],
|
|
3750
|
+
|
|
3751
|
+
modifiersIgnored: [],
|
|
3752
|
+
|
|
3753
|
+
forceAbsolute: false
|
|
3754
|
+
};
|
|
3755
|
+
|
|
3725
3756
|
/**
|
|
3726
3757
|
* Create a new Popper.js instance
|
|
3727
3758
|
* @constructor Popper
|
|
@@ -3786,208 +3817,227 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
3786
3817
|
*
|
|
3787
3818
|
* @param {Boolean} [options.removeOnDestroy=false]
|
|
3788
3819
|
* Set to true if you want to automatically remove the popper when you call the `destroy` method.
|
|
3789
|
-
*/
|
|
3790
|
-
function Popper(reference, popper, options) {
|
|
3791
|
-
this._reference = reference.jquery ? reference[0] : reference;
|
|
3792
|
-
this.state = {};
|
|
3793
|
-
|
|
3794
|
-
// if the popper variable is a configuration object, parse it to generate an HTMLElement
|
|
3795
|
-
// generate a default popper if is not defined
|
|
3796
|
-
var isNotDefined = typeof popper === 'undefined' || popper === null;
|
|
3797
|
-
var isConfig =
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
this.
|
|
3830
|
-
|
|
3831
|
-
//
|
|
3832
|
-
this.
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3820
|
+
*/
|
|
3821
|
+
function Popper(reference, popper, options) {
|
|
3822
|
+
this._reference = reference.jquery ? reference[0] : reference;
|
|
3823
|
+
this.state = {};
|
|
3824
|
+
|
|
3825
|
+
// if the popper variable is a configuration object, parse it to generate an HTMLElement
|
|
3826
|
+
// generate a default popper if is not defined
|
|
3827
|
+
var isNotDefined = typeof popper === 'undefined' || popper === null;
|
|
3828
|
+
var isConfig =
|
|
3829
|
+
popper && Object.prototype.toString.call(popper) === '[object Object]';
|
|
3830
|
+
if (isNotDefined || isConfig) {
|
|
3831
|
+
this._popper = this.parse(isConfig ? popper : {});
|
|
3832
|
+
}
|
|
3833
|
+
// otherwise, use the given HTMLElement as popper
|
|
3834
|
+
else {
|
|
3835
|
+
this._popper = popper.jquery ? popper[0] : popper;
|
|
3836
|
+
}
|
|
3837
|
+
|
|
3838
|
+
// with {} we create a new object with the options inside it
|
|
3839
|
+
this._options = Object.assign({}, DEFAULTS, options);
|
|
3840
|
+
|
|
3841
|
+
// refactoring modifiers' list
|
|
3842
|
+
this._options.modifiers = this._options.modifiers.map(
|
|
3843
|
+
function (modifier) {
|
|
3844
|
+
// remove ignored modifiers
|
|
3845
|
+
if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
|
|
3846
|
+
|
|
3847
|
+
// set the x-placement attribute before everything else because it could be used to add margins to the popper
|
|
3848
|
+
// margins needs to be calculated to get the correct popper offsets
|
|
3849
|
+
if (modifier === 'applyStyle') {
|
|
3850
|
+
this._popper.setAttribute('x-placement', this._options.placement);
|
|
3851
|
+
}
|
|
3852
|
+
|
|
3853
|
+
// return predefined modifier identified by string or keep the custom one
|
|
3854
|
+
return this.modifiers[modifier] || modifier;
|
|
3855
|
+
}.bind(this)
|
|
3856
|
+
);
|
|
3857
|
+
|
|
3858
|
+
// make sure to apply the popper position before any computation
|
|
3859
|
+
this.state.position = this._getPosition(this._popper, this._reference);
|
|
3860
|
+
setStyle(this._popper, { position: this.state.position, top: 0 });
|
|
3861
|
+
|
|
3862
|
+
// fire the first update to position the popper in the right place
|
|
3863
|
+
this.update();
|
|
3864
|
+
|
|
3865
|
+
// setup event listeners, they will take care of update the position in specific situations
|
|
3866
|
+
this._setupEventListeners();
|
|
3867
|
+
return this;
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
//
|
|
3871
|
+
// Methods
|
|
3872
|
+
//
|
|
3839
3873
|
/**
|
|
3840
3874
|
* Destroy the popper
|
|
3841
3875
|
* @method
|
|
3842
3876
|
* @memberof Popper
|
|
3843
|
-
*/
|
|
3844
|
-
Popper.prototype.destroy = function () {
|
|
3845
|
-
this._popper.removeAttribute('x-placement');
|
|
3846
|
-
this._popper.style.left = '';
|
|
3847
|
-
this._popper.style.position = '';
|
|
3848
|
-
this._popper.style.top = '';
|
|
3849
|
-
this._popper.style[getSupportedPropertyName('transform')] = '';
|
|
3850
|
-
this._removeEventListeners();
|
|
3851
|
-
|
|
3852
|
-
// remove the popper if user explicity asked for the deletion on destroy
|
|
3853
|
-
if (this._options.removeOnDestroy) {
|
|
3854
|
-
this._popper.remove();
|
|
3855
|
-
}
|
|
3856
|
-
return this;
|
|
3857
|
-
};
|
|
3858
|
-
|
|
3877
|
+
*/
|
|
3878
|
+
Popper.prototype.destroy = function () {
|
|
3879
|
+
this._popper.removeAttribute('x-placement');
|
|
3880
|
+
this._popper.style.left = '';
|
|
3881
|
+
this._popper.style.position = '';
|
|
3882
|
+
this._popper.style.top = '';
|
|
3883
|
+
this._popper.style[getSupportedPropertyName('transform')] = '';
|
|
3884
|
+
this._removeEventListeners();
|
|
3885
|
+
|
|
3886
|
+
// remove the popper if user explicity asked for the deletion on destroy
|
|
3887
|
+
if (this._options.removeOnDestroy) {
|
|
3888
|
+
this._popper.remove();
|
|
3889
|
+
}
|
|
3890
|
+
return this;
|
|
3891
|
+
};
|
|
3892
|
+
|
|
3859
3893
|
/**
|
|
3860
3894
|
* Updates the position of the popper, computing the new offsets and applying the new style
|
|
3861
3895
|
* @method
|
|
3862
3896
|
* @memberof Popper
|
|
3863
|
-
*/
|
|
3864
|
-
Popper.prototype.update = function () {
|
|
3865
|
-
var data = { instance: this, styles: {} };
|
|
3866
|
-
|
|
3867
|
-
// store placement inside the data object, modifiers will be able to edit `placement` if needed
|
|
3868
|
-
// and refer to _originalPlacement to know the original value
|
|
3869
|
-
data.placement = this._options.placement;
|
|
3870
|
-
data._originalPlacement = this._options.placement;
|
|
3871
|
-
|
|
3872
|
-
// compute the popper and reference offsets and put them inside data.offsets
|
|
3873
|
-
data.offsets = this._getOffsets(
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3897
|
+
*/
|
|
3898
|
+
Popper.prototype.update = function () {
|
|
3899
|
+
var data = { instance: this, styles: {} };
|
|
3900
|
+
|
|
3901
|
+
// store placement inside the data object, modifiers will be able to edit `placement` if needed
|
|
3902
|
+
// and refer to _originalPlacement to know the original value
|
|
3903
|
+
data.placement = this._options.placement;
|
|
3904
|
+
data._originalPlacement = this._options.placement;
|
|
3905
|
+
|
|
3906
|
+
// compute the popper and reference offsets and put them inside data.offsets
|
|
3907
|
+
data.offsets = this._getOffsets(
|
|
3908
|
+
this._popper,
|
|
3909
|
+
this._reference,
|
|
3910
|
+
data.placement
|
|
3911
|
+
);
|
|
3912
|
+
|
|
3913
|
+
// get boundaries
|
|
3914
|
+
data.boundaries = this._getBoundaries(
|
|
3915
|
+
data,
|
|
3916
|
+
this._options.boundariesPadding,
|
|
3917
|
+
this._options.boundariesElement
|
|
3918
|
+
);
|
|
3919
|
+
|
|
3920
|
+
data = this.runModifiers(data, this._options.modifiers);
|
|
3921
|
+
|
|
3922
|
+
if (typeof this.state.updateCallback === 'function') {
|
|
3923
|
+
this.state.updateCallback(data);
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3885
3927
|
/**
|
|
3886
3928
|
* If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
|
|
3887
3929
|
* @method
|
|
3888
3930
|
* @memberof Popper
|
|
3889
3931
|
* @param {Function} callback
|
|
3890
|
-
*/
|
|
3891
|
-
Popper.prototype.onCreate = function (callback) {
|
|
3892
|
-
// the createCallbacks return as first argument the popper instance
|
|
3893
|
-
callback(this);
|
|
3894
|
-
return this;
|
|
3895
|
-
};
|
|
3896
|
-
|
|
3932
|
+
*/
|
|
3933
|
+
Popper.prototype.onCreate = function (callback) {
|
|
3934
|
+
// the createCallbacks return as first argument the popper instance
|
|
3935
|
+
callback(this);
|
|
3936
|
+
return this;
|
|
3937
|
+
};
|
|
3938
|
+
|
|
3897
3939
|
/**
|
|
3898
3940
|
* If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
|
|
3899
|
-
* used to style popper and its arrow.
|
|
3900
|
-
* NOTE: it doesn't get fired on the first call of the `Popper.update()` method inside the `Popper` constructor!
|
|
3901
|
-
* @method
|
|
3902
|
-
* @memberof Popper
|
|
3903
|
-
* @param {Function} callback
|
|
3904
|
-
*/
|
|
3905
|
-
Popper.prototype.onUpdate = function (callback) {
|
|
3906
|
-
this.state.updateCallback = callback;
|
|
3907
|
-
return this;
|
|
3908
|
-
};
|
|
3909
|
-
|
|
3910
|
-
/**
|
|
3911
|
-
* Helper used to generate poppers from a configuration file
|
|
3912
|
-
* @method
|
|
3913
|
-
* @memberof Popper
|
|
3914
|
-
* @param config {Object} configuration
|
|
3915
|
-
* @returns {HTMLElement} popper
|
|
3916
|
-
*/
|
|
3917
|
-
Popper.prototype.parse = function (config) {
|
|
3918
|
-
var defaultConfig = {
|
|
3919
|
-
tagName: 'div',
|
|
3920
|
-
classNames: ['popper'],
|
|
3921
|
-
attributes: [],
|
|
3922
|
-
parent: root.document.body,
|
|
3923
|
-
content: '',
|
|
3924
|
-
contentType: 'text',
|
|
3925
|
-
arrowTagName: 'div',
|
|
3926
|
-
arrowClassNames: ['popper__arrow'],
|
|
3927
|
-
arrowAttributes: ['x-arrow']
|
|
3928
|
-
};
|
|
3929
|
-
config = Object.assign({}, defaultConfig, config);
|
|
3930
|
-
|
|
3931
|
-
var d = root.document;
|
|
3932
|
-
|
|
3933
|
-
var popper = d.createElement(config.tagName);
|
|
3934
|
-
addClassNames(popper, config.classNames);
|
|
3935
|
-
addAttributes(popper, config.attributes);
|
|
3936
|
-
if (config.contentType === 'node') {
|
|
3937
|
-
popper.appendChild(
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
} else {
|
|
3941
|
-
popper.
|
|
3942
|
-
}
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
// if
|
|
3956
|
-
if
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
parent = parent[0];
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3973
|
-
//
|
|
3974
|
-
parent.
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3941
|
+
* used to style popper and its arrow.
|
|
3942
|
+
* NOTE: it doesn't get fired on the first call of the `Popper.update()` method inside the `Popper` constructor!
|
|
3943
|
+
* @method
|
|
3944
|
+
* @memberof Popper
|
|
3945
|
+
* @param {Function} callback
|
|
3946
|
+
*/
|
|
3947
|
+
Popper.prototype.onUpdate = function (callback) {
|
|
3948
|
+
this.state.updateCallback = callback;
|
|
3949
|
+
return this;
|
|
3950
|
+
};
|
|
3951
|
+
|
|
3952
|
+
/**
|
|
3953
|
+
* Helper used to generate poppers from a configuration file
|
|
3954
|
+
* @method
|
|
3955
|
+
* @memberof Popper
|
|
3956
|
+
* @param config {Object} configuration
|
|
3957
|
+
* @returns {HTMLElement} popper
|
|
3958
|
+
*/
|
|
3959
|
+
Popper.prototype.parse = function (config) {
|
|
3960
|
+
var defaultConfig = {
|
|
3961
|
+
tagName: 'div',
|
|
3962
|
+
classNames: ['popper'],
|
|
3963
|
+
attributes: [],
|
|
3964
|
+
parent: root.document.body,
|
|
3965
|
+
content: '',
|
|
3966
|
+
contentType: 'text',
|
|
3967
|
+
arrowTagName: 'div',
|
|
3968
|
+
arrowClassNames: ['popper__arrow'],
|
|
3969
|
+
arrowAttributes: ['x-arrow']
|
|
3970
|
+
};
|
|
3971
|
+
config = Object.assign({}, defaultConfig, config);
|
|
3972
|
+
|
|
3973
|
+
var d = root.document;
|
|
3974
|
+
|
|
3975
|
+
var popper = d.createElement(config.tagName);
|
|
3976
|
+
addClassNames(popper, config.classNames);
|
|
3977
|
+
addAttributes(popper, config.attributes);
|
|
3978
|
+
if (config.contentType === 'node') {
|
|
3979
|
+
popper.appendChild(
|
|
3980
|
+
config.content.jquery ? config.content[0] : config.content
|
|
3981
|
+
);
|
|
3982
|
+
} else if (config.contentType === 'html') {
|
|
3983
|
+
popper.innerHTML = config.content;
|
|
3984
|
+
} else {
|
|
3985
|
+
popper.textContent = config.content;
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
if (config.arrowTagName) {
|
|
3989
|
+
var arrow = d.createElement(config.arrowTagName);
|
|
3990
|
+
addClassNames(arrow, config.arrowClassNames);
|
|
3991
|
+
addAttributes(arrow, config.arrowAttributes);
|
|
3992
|
+
popper.appendChild(arrow);
|
|
3993
|
+
}
|
|
3994
|
+
|
|
3995
|
+
var parent = config.parent.jquery ? config.parent[0] : config.parent;
|
|
3996
|
+
|
|
3997
|
+
// if the given parent is a string, use it to match an element
|
|
3998
|
+
// if more than one element is matched, the first one will be used as parent
|
|
3999
|
+
// if no elements are matched, the script will throw an error
|
|
4000
|
+
if (typeof parent === 'string') {
|
|
4001
|
+
parent = d.querySelectorAll(config.parent);
|
|
4002
|
+
if (parent.length > 1) {
|
|
4003
|
+
console.warn(
|
|
4004
|
+
'WARNING: the given `parent` query(' +
|
|
4005
|
+
config.parent +
|
|
4006
|
+
') matched more than one element, the first one will be used'
|
|
4007
|
+
);
|
|
4008
|
+
}
|
|
4009
|
+
if (parent.length === 0) {
|
|
4010
|
+
throw "ERROR: the given `parent` doesn't exists!";
|
|
4011
|
+
}
|
|
4012
|
+
parent = parent[0];
|
|
4013
|
+
}
|
|
4014
|
+
// if the given parent is a DOM nodes list or an array of nodes with more than one element,
|
|
4015
|
+
// the first one will be used as parent
|
|
4016
|
+
if (parent.length > 1 && parent instanceof Element === false) {
|
|
4017
|
+
console.warn(
|
|
4018
|
+
'WARNING: you have passed as parent a list of elements, the first one will be used'
|
|
4019
|
+
);
|
|
4020
|
+
parent = parent[0];
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
// append the generated popper to its parent
|
|
4024
|
+
parent.appendChild(popper);
|
|
4025
|
+
|
|
4026
|
+
return popper;
|
|
4027
|
+
|
|
3978
4028
|
/**
|
|
3979
4029
|
* Adds class names to the given element
|
|
3980
4030
|
* @function
|
|
3981
4031
|
* @ignore
|
|
3982
4032
|
* @param {HTMLElement} target
|
|
3983
4033
|
* @param {Array} classes
|
|
3984
|
-
*/
|
|
3985
|
-
function addClassNames(element, classNames) {
|
|
3986
|
-
classNames.forEach(function (className) {
|
|
3987
|
-
element.classList.add(className);
|
|
3988
|
-
});
|
|
3989
|
-
}
|
|
3990
|
-
|
|
4034
|
+
*/
|
|
4035
|
+
function addClassNames(element, classNames) {
|
|
4036
|
+
classNames.forEach(function (className) {
|
|
4037
|
+
element.classList.add(className);
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
|
|
3991
4041
|
/**
|
|
3992
4042
|
* Adds attributes to the given element
|
|
3993
4043
|
* @function
|
|
@@ -3996,14 +4046,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
3996
4046
|
* @param {Array} attributes
|
|
3997
4047
|
* @example
|
|
3998
4048
|
* addAttributes(element, [ 'data-info:foobar' ]);
|
|
3999
|
-
*/
|
|
4000
|
-
function addAttributes(element, attributes) {
|
|
4001
|
-
attributes.forEach(function (attribute) {
|
|
4002
|
-
element.setAttribute(
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4049
|
+
*/
|
|
4050
|
+
function addAttributes(element, attributes) {
|
|
4051
|
+
attributes.forEach(function (attribute) {
|
|
4052
|
+
element.setAttribute(
|
|
4053
|
+
attribute.split(':')[0],
|
|
4054
|
+
attribute.split(':')[1] || ''
|
|
4055
|
+
);
|
|
4056
|
+
});
|
|
4057
|
+
}
|
|
4058
|
+
};
|
|
4059
|
+
|
|
4007
4060
|
/**
|
|
4008
4061
|
* Helper used to get the position which will be applied to the popper
|
|
4009
4062
|
* @method
|
|
@@ -4011,20 +4064,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4011
4064
|
* @param config {HTMLElement} popper element
|
|
4012
4065
|
* @param reference {HTMLElement} reference element
|
|
4013
4066
|
* @returns {String} position
|
|
4014
|
-
*/
|
|
4015
|
-
Popper.prototype._getPosition = function (popper, reference) {
|
|
4016
|
-
var container = getOffsetParent(reference);
|
|
4017
|
-
|
|
4018
|
-
if (this._options.forceAbsolute) {
|
|
4019
|
-
return 'absolute';
|
|
4020
|
-
}
|
|
4021
|
-
|
|
4022
|
-
// Decide if the popper will be fixed
|
|
4023
|
-
// If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
|
|
4024
|
-
var isParentFixed = isFixed(reference, container);
|
|
4025
|
-
return isParentFixed ? 'fixed' : 'absolute';
|
|
4026
|
-
};
|
|
4027
|
-
|
|
4067
|
+
*/
|
|
4068
|
+
Popper.prototype._getPosition = function (popper, reference) {
|
|
4069
|
+
var container = getOffsetParent(reference);
|
|
4070
|
+
|
|
4071
|
+
if (this._options.forceAbsolute) {
|
|
4072
|
+
return 'absolute';
|
|
4073
|
+
}
|
|
4074
|
+
|
|
4075
|
+
// Decide if the popper will be fixed
|
|
4076
|
+
// If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
|
|
4077
|
+
var isParentFixed = isFixed(reference, container);
|
|
4078
|
+
return isParentFixed ? 'fixed' : 'absolute';
|
|
4079
|
+
};
|
|
4080
|
+
|
|
4028
4081
|
/**
|
|
4029
4082
|
* Get offsets to the popper
|
|
4030
4083
|
* @method
|
|
@@ -4033,93 +4086,112 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4033
4086
|
* @param {Element} popper - the popper element
|
|
4034
4087
|
* @param {Element} reference - the reference element (the popper will be relative to this)
|
|
4035
4088
|
* @returns {Object} An object containing the offsets which will be applied to the popper
|
|
4036
|
-
*/
|
|
4037
|
-
Popper.prototype._getOffsets = function (popper, reference, placement) {
|
|
4038
|
-
placement = placement.split('-')[0];
|
|
4039
|
-
var popperOffsets = {};
|
|
4040
|
-
|
|
4041
|
-
popperOffsets.position = this.state.position;
|
|
4042
|
-
var isParentFixed = popperOffsets.position === 'fixed';
|
|
4043
|
-
|
|
4044
|
-
//
|
|
4045
|
-
// Get reference element position
|
|
4046
|
-
//
|
|
4047
|
-
var referenceOffsets = getOffsetRectRelativeToCustomParent(
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
//
|
|
4055
|
-
//
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
//
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
if (placement === '
|
|
4069
|
-
popperOffsets.
|
|
4070
|
-
} else {
|
|
4071
|
-
popperOffsets.
|
|
4072
|
-
}
|
|
4073
|
-
}
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4089
|
+
*/
|
|
4090
|
+
Popper.prototype._getOffsets = function (popper, reference, placement) {
|
|
4091
|
+
placement = placement.split('-')[0];
|
|
4092
|
+
var popperOffsets = {};
|
|
4093
|
+
|
|
4094
|
+
popperOffsets.position = this.state.position;
|
|
4095
|
+
var isParentFixed = popperOffsets.position === 'fixed';
|
|
4096
|
+
|
|
4097
|
+
//
|
|
4098
|
+
// Get reference element position
|
|
4099
|
+
//
|
|
4100
|
+
var referenceOffsets = getOffsetRectRelativeToCustomParent(
|
|
4101
|
+
reference,
|
|
4102
|
+
getOffsetParent(popper),
|
|
4103
|
+
isParentFixed
|
|
4104
|
+
);
|
|
4105
|
+
|
|
4106
|
+
//
|
|
4107
|
+
// Get popper sizes
|
|
4108
|
+
//
|
|
4109
|
+
var popperRect = getOuterSizes(popper);
|
|
4110
|
+
|
|
4111
|
+
//
|
|
4112
|
+
// Compute offsets of popper
|
|
4113
|
+
//
|
|
4114
|
+
|
|
4115
|
+
// depending by the popper placement we have to compute its offsets slightly differently
|
|
4116
|
+
if (['right', 'left'].indexOf(placement) !== -1) {
|
|
4117
|
+
popperOffsets.top =
|
|
4118
|
+
referenceOffsets.top +
|
|
4119
|
+
referenceOffsets.height / 2 -
|
|
4120
|
+
popperRect.height / 2;
|
|
4121
|
+
if (placement === 'left') {
|
|
4122
|
+
popperOffsets.left = referenceOffsets.left - popperRect.width;
|
|
4123
|
+
} else {
|
|
4124
|
+
popperOffsets.left = referenceOffsets.right;
|
|
4125
|
+
}
|
|
4126
|
+
} else {
|
|
4127
|
+
popperOffsets.left =
|
|
4128
|
+
referenceOffsets.left +
|
|
4129
|
+
referenceOffsets.width / 2 -
|
|
4130
|
+
popperRect.width / 2;
|
|
4131
|
+
if (placement === 'top') {
|
|
4132
|
+
popperOffsets.top = referenceOffsets.top - popperRect.height;
|
|
4133
|
+
} else {
|
|
4134
|
+
popperOffsets.top = referenceOffsets.bottom;
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
// Add width and height to our offsets object
|
|
4139
|
+
popperOffsets.width = popperRect.width;
|
|
4140
|
+
popperOffsets.height = popperRect.height;
|
|
4141
|
+
|
|
4142
|
+
return {
|
|
4143
|
+
popper: popperOffsets,
|
|
4144
|
+
reference: referenceOffsets
|
|
4145
|
+
};
|
|
4146
|
+
};
|
|
4147
|
+
|
|
4085
4148
|
/**
|
|
4086
4149
|
* Setup needed event listeners used to update the popper position
|
|
4087
4150
|
* @method
|
|
4088
4151
|
* @memberof Popper
|
|
4089
4152
|
* @access private
|
|
4090
|
-
*/
|
|
4091
|
-
Popper.prototype._setupEventListeners = function () {
|
|
4092
|
-
// NOTE: 1 DOM access here
|
|
4093
|
-
this.state.updateBound = this.update.bind(this);
|
|
4094
|
-
root.addEventListener('resize', this.state.updateBound);
|
|
4095
|
-
// if the boundariesElement is window we don't need to listen for the scroll event
|
|
4096
|
-
if (this._options.boundariesElement !== 'window') {
|
|
4097
|
-
var target = getScrollParent(this._reference);
|
|
4098
|
-
// here it could be both `body` or `documentElement` thanks to Firefox, we then check both
|
|
4099
|
-
if (
|
|
4100
|
-
target
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4153
|
+
*/
|
|
4154
|
+
Popper.prototype._setupEventListeners = function () {
|
|
4155
|
+
// NOTE: 1 DOM access here
|
|
4156
|
+
this.state.updateBound = this.update.bind(this);
|
|
4157
|
+
root.addEventListener('resize', this.state.updateBound);
|
|
4158
|
+
// if the boundariesElement is window we don't need to listen for the scroll event
|
|
4159
|
+
if (this._options.boundariesElement !== 'window') {
|
|
4160
|
+
var target = getScrollParent(this._reference);
|
|
4161
|
+
// here it could be both `body` or `documentElement` thanks to Firefox, we then check both
|
|
4162
|
+
if (
|
|
4163
|
+
target === root.document.body ||
|
|
4164
|
+
target === root.document.documentElement
|
|
4165
|
+
) {
|
|
4166
|
+
target = root;
|
|
4167
|
+
}
|
|
4168
|
+
target.addEventListener('scroll', this.state.updateBound);
|
|
4169
|
+
this.state.scrollTarget = target;
|
|
4170
|
+
}
|
|
4171
|
+
};
|
|
4172
|
+
|
|
4107
4173
|
/**
|
|
4108
4174
|
* Remove event listeners used to update the popper position
|
|
4109
4175
|
* @method
|
|
4110
4176
|
* @memberof Popper
|
|
4111
4177
|
* @access private
|
|
4112
|
-
*/
|
|
4113
|
-
Popper.prototype._removeEventListeners = function () {
|
|
4114
|
-
// NOTE: 1 DOM access here
|
|
4115
|
-
root.removeEventListener('resize', this.state.updateBound);
|
|
4116
|
-
if (
|
|
4117
|
-
this.
|
|
4118
|
-
this.state.scrollTarget
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4178
|
+
*/
|
|
4179
|
+
Popper.prototype._removeEventListeners = function () {
|
|
4180
|
+
// NOTE: 1 DOM access here
|
|
4181
|
+
root.removeEventListener('resize', this.state.updateBound);
|
|
4182
|
+
if (
|
|
4183
|
+
this._options.boundariesElement !== 'window' &&
|
|
4184
|
+
this.state.scrollTarget
|
|
4185
|
+
) {
|
|
4186
|
+
this.state.scrollTarget.removeEventListener(
|
|
4187
|
+
'scroll',
|
|
4188
|
+
this.state.updateBound
|
|
4189
|
+
);
|
|
4190
|
+
this.state.scrollTarget = null;
|
|
4191
|
+
}
|
|
4192
|
+
this.state.updateBound = null;
|
|
4193
|
+
};
|
|
4194
|
+
|
|
4123
4195
|
/**
|
|
4124
4196
|
* Computed the boundaries limits and return them
|
|
4125
4197
|
* @method
|
|
@@ -4129,66 +4201,98 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4129
4201
|
* @param {Number} padding - Boundaries padding
|
|
4130
4202
|
* @param {Element} boundariesElement - Element used to define the boundaries
|
|
4131
4203
|
* @returns {Object} Coordinates of the boundaries
|
|
4132
|
-
*/
|
|
4133
|
-
Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
|
|
4134
|
-
// NOTE: 1 DOM access here
|
|
4135
|
-
var boundaries = {};
|
|
4136
|
-
var width, height;
|
|
4137
|
-
if (boundariesElement === 'window') {
|
|
4138
|
-
var body = root.document.body,
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
height = Math.max(
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
};
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
var
|
|
4165
|
-
var
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
}
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4204
|
+
*/
|
|
4205
|
+
Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
|
|
4206
|
+
// NOTE: 1 DOM access here
|
|
4207
|
+
var boundaries = {};
|
|
4208
|
+
var width, height;
|
|
4209
|
+
if (boundariesElement === 'window') {
|
|
4210
|
+
var body = root.document.body,
|
|
4211
|
+
html = root.document.documentElement;
|
|
4212
|
+
|
|
4213
|
+
height = Math.max(
|
|
4214
|
+
body.scrollHeight,
|
|
4215
|
+
body.offsetHeight,
|
|
4216
|
+
html.clientHeight,
|
|
4217
|
+
html.scrollHeight,
|
|
4218
|
+
html.offsetHeight
|
|
4219
|
+
);
|
|
4220
|
+
width = Math.max(
|
|
4221
|
+
body.scrollWidth,
|
|
4222
|
+
body.offsetWidth,
|
|
4223
|
+
html.clientWidth,
|
|
4224
|
+
html.scrollWidth,
|
|
4225
|
+
html.offsetWidth
|
|
4226
|
+
);
|
|
4227
|
+
|
|
4228
|
+
boundaries = {
|
|
4229
|
+
top: 0,
|
|
4230
|
+
right: width,
|
|
4231
|
+
bottom: height,
|
|
4232
|
+
left: 0
|
|
4233
|
+
};
|
|
4234
|
+
} else if (boundariesElement === 'viewport') {
|
|
4235
|
+
var offsetParent = getOffsetParent(this._popper);
|
|
4236
|
+
var scrollParent = getScrollParent(this._popper);
|
|
4237
|
+
var offsetParentRect = getOffsetRect(offsetParent);
|
|
4238
|
+
|
|
4239
|
+
// Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
|
|
4240
|
+
var getScrollTopValue = function (element) {
|
|
4241
|
+
return element == document.body
|
|
4242
|
+
? Math.max(
|
|
4243
|
+
document.documentElement.scrollTop,
|
|
4244
|
+
document.body.scrollTop
|
|
4245
|
+
)
|
|
4246
|
+
: element.scrollTop;
|
|
4247
|
+
};
|
|
4248
|
+
var getScrollLeftValue = function (element) {
|
|
4249
|
+
return element == document.body
|
|
4250
|
+
? Math.max(
|
|
4251
|
+
document.documentElement.scrollLeft,
|
|
4252
|
+
document.body.scrollLeft
|
|
4253
|
+
)
|
|
4254
|
+
: element.scrollLeft;
|
|
4255
|
+
};
|
|
4256
|
+
|
|
4257
|
+
// if the popper is fixed we don't have to substract scrolling from the boundaries
|
|
4258
|
+
var scrollTop =
|
|
4259
|
+
data.offsets.popper.position === 'fixed'
|
|
4260
|
+
? 0
|
|
4261
|
+
: getScrollTopValue(scrollParent);
|
|
4262
|
+
var scrollLeft =
|
|
4263
|
+
data.offsets.popper.position === 'fixed'
|
|
4264
|
+
? 0
|
|
4265
|
+
: getScrollLeftValue(scrollParent);
|
|
4266
|
+
|
|
4267
|
+
boundaries = {
|
|
4268
|
+
top: 0 - (offsetParentRect.top - scrollTop),
|
|
4269
|
+
right:
|
|
4270
|
+
root.document.documentElement.clientWidth -
|
|
4271
|
+
(offsetParentRect.left - scrollLeft),
|
|
4272
|
+
bottom:
|
|
4273
|
+
root.document.documentElement.clientHeight -
|
|
4274
|
+
(offsetParentRect.top - scrollTop),
|
|
4275
|
+
left: 0 - (offsetParentRect.left - scrollLeft)
|
|
4276
|
+
};
|
|
4277
|
+
} else {
|
|
4278
|
+
if (getOffsetParent(this._popper) === boundariesElement) {
|
|
4279
|
+
boundaries = {
|
|
4280
|
+
top: 0,
|
|
4281
|
+
left: 0,
|
|
4282
|
+
right: boundariesElement.clientWidth,
|
|
4283
|
+
bottom: boundariesElement.clientHeight
|
|
4284
|
+
};
|
|
4285
|
+
} else {
|
|
4286
|
+
boundaries = getOffsetRect(boundariesElement);
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
boundaries.left += padding;
|
|
4290
|
+
boundaries.right -= padding;
|
|
4291
|
+
boundaries.top = boundaries.top + padding;
|
|
4292
|
+
boundaries.bottom = boundaries.bottom - padding;
|
|
4293
|
+
return boundaries;
|
|
4294
|
+
};
|
|
4295
|
+
|
|
4192
4296
|
/**
|
|
4193
4297
|
* Loop trough the list of modifiers and run them in order, each of them will then edit the data object
|
|
4194
4298
|
* @method
|
|
@@ -4197,22 +4301,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4197
4301
|
* @param {Object} data
|
|
4198
4302
|
* @param {Array} modifiers
|
|
4199
4303
|
* @param {Function} ends
|
|
4200
|
-
*/
|
|
4201
|
-
Popper.prototype.runModifiers = function (data, modifiers, ends) {
|
|
4202
|
-
var modifiersToRun = modifiers.slice();
|
|
4203
|
-
if (ends !== undefined) {
|
|
4204
|
-
modifiersToRun = this._options.modifiers.slice(
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4304
|
+
*/
|
|
4305
|
+
Popper.prototype.runModifiers = function (data, modifiers, ends) {
|
|
4306
|
+
var modifiersToRun = modifiers.slice();
|
|
4307
|
+
if (ends !== undefined) {
|
|
4308
|
+
modifiersToRun = this._options.modifiers.slice(
|
|
4309
|
+
0,
|
|
4310
|
+
getArrayKeyIndex(this._options.modifiers, ends)
|
|
4311
|
+
);
|
|
4312
|
+
}
|
|
4313
|
+
|
|
4314
|
+
modifiersToRun.forEach(
|
|
4315
|
+
function (modifier) {
|
|
4316
|
+
if (isFunction(modifier)) {
|
|
4317
|
+
data = modifier.call(this, data);
|
|
4318
|
+
}
|
|
4319
|
+
}.bind(this)
|
|
4320
|
+
);
|
|
4321
|
+
|
|
4322
|
+
return data;
|
|
4323
|
+
};
|
|
4324
|
+
|
|
4216
4325
|
/**
|
|
4217
4326
|
* Helper used to know if the given modifier depends from another one.
|
|
4218
4327
|
* @method
|
|
@@ -4220,191 +4329,204 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4220
4329
|
* @param {String} requesting - name of requesting modifier
|
|
4221
4330
|
* @param {String} requested - name of requested modifier
|
|
4222
4331
|
* @returns {Boolean}
|
|
4223
|
-
*/
|
|
4224
|
-
Popper.prototype.isModifierRequired = function (requesting, requested) {
|
|
4225
|
-
var index = getArrayKeyIndex(this._options.modifiers, requesting);
|
|
4226
|
-
return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
|
|
4227
|
-
return modifier === requested;
|
|
4228
|
-
}).length;
|
|
4229
|
-
};
|
|
4230
|
-
|
|
4231
|
-
//
|
|
4232
|
-
// Modifiers
|
|
4233
|
-
//
|
|
4234
|
-
|
|
4332
|
+
*/
|
|
4333
|
+
Popper.prototype.isModifierRequired = function (requesting, requested) {
|
|
4334
|
+
var index = getArrayKeyIndex(this._options.modifiers, requesting);
|
|
4335
|
+
return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
|
|
4336
|
+
return modifier === requested;
|
|
4337
|
+
}).length;
|
|
4338
|
+
};
|
|
4339
|
+
|
|
4340
|
+
//
|
|
4341
|
+
// Modifiers
|
|
4342
|
+
//
|
|
4343
|
+
|
|
4235
4344
|
/**
|
|
4236
4345
|
* Modifiers list
|
|
4237
4346
|
* @namespace Popper.modifiers
|
|
4238
4347
|
* @memberof Popper
|
|
4239
4348
|
* @type {Object}
|
|
4240
|
-
*/
|
|
4241
|
-
Popper.prototype.modifiers = {};
|
|
4242
|
-
|
|
4349
|
+
*/
|
|
4350
|
+
Popper.prototype.modifiers = {};
|
|
4351
|
+
|
|
4243
4352
|
/**
|
|
4244
4353
|
* Apply the computed styles to the popper element
|
|
4245
4354
|
* @method
|
|
4246
4355
|
* @memberof Popper.modifiers
|
|
4247
4356
|
* @argument {Object} data - The data object generated by `update` method
|
|
4248
4357
|
* @returns {Object} The same data object
|
|
4249
|
-
*/
|
|
4250
|
-
Popper.prototype.modifiers.applyStyle = function (data) {
|
|
4251
|
-
// apply the final offsets to the popper
|
|
4252
|
-
// NOTE: 1 DOM access here
|
|
4253
|
-
var styles = {
|
|
4254
|
-
position: data.offsets.popper.position
|
|
4255
|
-
};
|
|
4256
|
-
|
|
4257
|
-
// round top and left to avoid blurry text
|
|
4258
|
-
var left = Math.round(data.offsets.popper.left);
|
|
4259
|
-
var top = Math.round(data.offsets.popper.top);
|
|
4260
|
-
|
|
4261
|
-
// if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
|
|
4262
|
-
// we automatically use the supported prefixed version if needed
|
|
4263
|
-
var prefixedProperty;
|
|
4264
|
-
if (
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
this._popper
|
|
4286
|
-
|
|
4287
|
-
//
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4358
|
+
*/
|
|
4359
|
+
Popper.prototype.modifiers.applyStyle = function (data) {
|
|
4360
|
+
// apply the final offsets to the popper
|
|
4361
|
+
// NOTE: 1 DOM access here
|
|
4362
|
+
var styles = {
|
|
4363
|
+
position: data.offsets.popper.position
|
|
4364
|
+
};
|
|
4365
|
+
|
|
4366
|
+
// round top and left to avoid blurry text
|
|
4367
|
+
var left = Math.round(data.offsets.popper.left);
|
|
4368
|
+
var top = Math.round(data.offsets.popper.top);
|
|
4369
|
+
|
|
4370
|
+
// if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
|
|
4371
|
+
// we automatically use the supported prefixed version if needed
|
|
4372
|
+
var prefixedProperty;
|
|
4373
|
+
if (
|
|
4374
|
+
this._options.gpuAcceleration &&
|
|
4375
|
+
(prefixedProperty = getSupportedPropertyName('transform'))
|
|
4376
|
+
) {
|
|
4377
|
+
styles[prefixedProperty] =
|
|
4378
|
+
'translate3d(' + left + 'px, ' + top + 'px, 0)';
|
|
4379
|
+
styles.top = 0;
|
|
4380
|
+
styles.left = 0;
|
|
4381
|
+
}
|
|
4382
|
+
// othwerise, we use the standard `left` and `top` properties
|
|
4383
|
+
else {
|
|
4384
|
+
styles.left = left;
|
|
4385
|
+
styles.top = top;
|
|
4386
|
+
}
|
|
4387
|
+
|
|
4388
|
+
// any property present in `data.styles` will be applied to the popper,
|
|
4389
|
+
// in this way we can make the 3rd party modifiers add custom styles to it
|
|
4390
|
+
// Be aware, modifiers could override the properties defined in the previous
|
|
4391
|
+
// lines of this modifier!
|
|
4392
|
+
Object.assign(styles, data.styles);
|
|
4393
|
+
|
|
4394
|
+
setStyle(this._popper, styles);
|
|
4395
|
+
|
|
4396
|
+
// set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
|
|
4397
|
+
// NOTE: 1 DOM access here
|
|
4398
|
+
this._popper.setAttribute('x-placement', data.placement);
|
|
4399
|
+
|
|
4400
|
+
// if the arrow modifier is required and the arrow style has been computed, apply the arrow style
|
|
4401
|
+
if (
|
|
4402
|
+
this.isModifierRequired(
|
|
4403
|
+
this.modifiers.applyStyle,
|
|
4404
|
+
this.modifiers.arrow
|
|
4405
|
+
) &&
|
|
4406
|
+
data.offsets.arrow
|
|
4407
|
+
) {
|
|
4408
|
+
setStyle(data.arrowElement, data.offsets.arrow);
|
|
4409
|
+
}
|
|
4410
|
+
|
|
4411
|
+
return data;
|
|
4412
|
+
};
|
|
4413
|
+
|
|
4295
4414
|
/**
|
|
4296
4415
|
* Modifier used to shift the popper on the start or end of its reference element side
|
|
4297
4416
|
* @method
|
|
4298
4417
|
* @memberof Popper.modifiers
|
|
4299
4418
|
* @argument {Object} data - The data object generated by `update` method
|
|
4300
4419
|
* @returns {Object} The data object, properly modified
|
|
4301
|
-
*/
|
|
4302
|
-
Popper.prototype.modifiers.shift = function (data) {
|
|
4303
|
-
var placement = data.placement;
|
|
4304
|
-
var basePlacement = placement.split('-')[0];
|
|
4305
|
-
var shiftVariation = placement.split('-')[1];
|
|
4306
|
-
|
|
4307
|
-
// if shift shiftVariation is specified, run the modifier
|
|
4308
|
-
if (shiftVariation) {
|
|
4309
|
-
var reference = data.offsets.reference;
|
|
4310
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
4311
|
-
|
|
4312
|
-
var shiftOffsets = {
|
|
4313
|
-
y: {
|
|
4314
|
-
start: { top: reference.top },
|
|
4315
|
-
end: { top: reference.top + reference.height - popper.height }
|
|
4316
|
-
},
|
|
4317
|
-
x: {
|
|
4318
|
-
start: { left: reference.left },
|
|
4319
|
-
end: { left: reference.left + reference.width - popper.width }
|
|
4320
|
-
}
|
|
4321
|
-
};
|
|
4322
|
-
|
|
4323
|
-
var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
|
|
4324
|
-
|
|
4325
|
-
data.offsets.popper = Object.assign(
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4420
|
+
*/
|
|
4421
|
+
Popper.prototype.modifiers.shift = function (data) {
|
|
4422
|
+
var placement = data.placement;
|
|
4423
|
+
var basePlacement = placement.split('-')[0];
|
|
4424
|
+
var shiftVariation = placement.split('-')[1];
|
|
4425
|
+
|
|
4426
|
+
// if shift shiftVariation is specified, run the modifier
|
|
4427
|
+
if (shiftVariation) {
|
|
4428
|
+
var reference = data.offsets.reference;
|
|
4429
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
4430
|
+
|
|
4431
|
+
var shiftOffsets = {
|
|
4432
|
+
y: {
|
|
4433
|
+
start: { top: reference.top },
|
|
4434
|
+
end: { top: reference.top + reference.height - popper.height }
|
|
4435
|
+
},
|
|
4436
|
+
x: {
|
|
4437
|
+
start: { left: reference.left },
|
|
4438
|
+
end: { left: reference.left + reference.width - popper.width }
|
|
4439
|
+
}
|
|
4440
|
+
};
|
|
4441
|
+
|
|
4442
|
+
var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
|
|
4443
|
+
|
|
4444
|
+
data.offsets.popper = Object.assign(
|
|
4445
|
+
popper,
|
|
4446
|
+
shiftOffsets[axis][shiftVariation]
|
|
4447
|
+
);
|
|
4448
|
+
}
|
|
4449
|
+
|
|
4450
|
+
return data;
|
|
4451
|
+
};
|
|
4452
|
+
|
|
4331
4453
|
/**
|
|
4332
4454
|
* Modifier used to make sure the popper does not overflows from it's boundaries
|
|
4333
4455
|
* @method
|
|
4334
4456
|
* @memberof Popper.modifiers
|
|
4335
4457
|
* @argument {Object} data - The data object generated by `update` method
|
|
4336
4458
|
* @returns {Object} The data object, properly modified
|
|
4337
|
-
*/
|
|
4338
|
-
Popper.prototype.modifiers.preventOverflow = function (data) {
|
|
4339
|
-
var order = this._options.preventOverflowOrder;
|
|
4340
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
4341
|
-
|
|
4342
|
-
var check = {
|
|
4343
|
-
left: function
|
|
4344
|
-
var left = popper.left;
|
|
4345
|
-
if (popper.left < data.boundaries.left) {
|
|
4346
|
-
left = Math.max(popper.left, data.boundaries.left);
|
|
4347
|
-
}
|
|
4348
|
-
return { left: left };
|
|
4349
|
-
},
|
|
4350
|
-
right: function
|
|
4351
|
-
var left = popper.left;
|
|
4352
|
-
if (popper.right > data.boundaries.right) {
|
|
4353
|
-
left = Math.min(popper.left, data.boundaries.right - popper.width);
|
|
4354
|
-
}
|
|
4355
|
-
return { left: left };
|
|
4356
|
-
},
|
|
4357
|
-
top: function
|
|
4358
|
-
var top = popper.top;
|
|
4359
|
-
if (popper.top < data.boundaries.top) {
|
|
4360
|
-
top = Math.max(popper.top, data.boundaries.top);
|
|
4361
|
-
}
|
|
4362
|
-
return { top: top };
|
|
4363
|
-
},
|
|
4364
|
-
bottom: function
|
|
4365
|
-
var top = popper.top;
|
|
4366
|
-
if (popper.bottom > data.boundaries.bottom) {
|
|
4367
|
-
top = Math.min(popper.top, data.boundaries.bottom - popper.height);
|
|
4368
|
-
}
|
|
4369
|
-
return { top: top };
|
|
4370
|
-
}
|
|
4371
|
-
};
|
|
4372
|
-
|
|
4373
|
-
order.forEach(function (direction) {
|
|
4374
|
-
data.offsets.popper = Object.assign(popper, check[direction]());
|
|
4375
|
-
});
|
|
4376
|
-
|
|
4377
|
-
return data;
|
|
4378
|
-
};
|
|
4379
|
-
|
|
4459
|
+
*/
|
|
4460
|
+
Popper.prototype.modifiers.preventOverflow = function (data) {
|
|
4461
|
+
var order = this._options.preventOverflowOrder;
|
|
4462
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
4463
|
+
|
|
4464
|
+
var check = {
|
|
4465
|
+
left: function () {
|
|
4466
|
+
var left = popper.left;
|
|
4467
|
+
if (popper.left < data.boundaries.left) {
|
|
4468
|
+
left = Math.max(popper.left, data.boundaries.left);
|
|
4469
|
+
}
|
|
4470
|
+
return { left: left };
|
|
4471
|
+
},
|
|
4472
|
+
right: function () {
|
|
4473
|
+
var left = popper.left;
|
|
4474
|
+
if (popper.right > data.boundaries.right) {
|
|
4475
|
+
left = Math.min(popper.left, data.boundaries.right - popper.width);
|
|
4476
|
+
}
|
|
4477
|
+
return { left: left };
|
|
4478
|
+
},
|
|
4479
|
+
top: function () {
|
|
4480
|
+
var top = popper.top;
|
|
4481
|
+
if (popper.top < data.boundaries.top) {
|
|
4482
|
+
top = Math.max(popper.top, data.boundaries.top);
|
|
4483
|
+
}
|
|
4484
|
+
return { top: top };
|
|
4485
|
+
},
|
|
4486
|
+
bottom: function () {
|
|
4487
|
+
var top = popper.top;
|
|
4488
|
+
if (popper.bottom > data.boundaries.bottom) {
|
|
4489
|
+
top = Math.min(popper.top, data.boundaries.bottom - popper.height);
|
|
4490
|
+
}
|
|
4491
|
+
return { top: top };
|
|
4492
|
+
}
|
|
4493
|
+
};
|
|
4494
|
+
|
|
4495
|
+
order.forEach(function (direction) {
|
|
4496
|
+
data.offsets.popper = Object.assign(popper, check[direction]());
|
|
4497
|
+
});
|
|
4498
|
+
|
|
4499
|
+
return data;
|
|
4500
|
+
};
|
|
4501
|
+
|
|
4380
4502
|
/**
|
|
4381
4503
|
* Modifier used to make sure the popper is always near its reference
|
|
4382
4504
|
* @method
|
|
4383
4505
|
* @memberof Popper.modifiers
|
|
4384
4506
|
* @argument {Object} data - The data object generated by _update method
|
|
4385
4507
|
* @returns {Object} The data object, properly modified
|
|
4386
|
-
*/
|
|
4387
|
-
Popper.prototype.modifiers.keepTogether = function (data) {
|
|
4388
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
4389
|
-
var reference = data.offsets.reference;
|
|
4390
|
-
var f = Math.floor;
|
|
4391
|
-
|
|
4392
|
-
if (popper.right < f(reference.left)) {
|
|
4393
|
-
data.offsets.popper.left = f(reference.left) - popper.width;
|
|
4394
|
-
}
|
|
4395
|
-
if (popper.left > f(reference.right)) {
|
|
4396
|
-
data.offsets.popper.left = f(reference.right);
|
|
4397
|
-
}
|
|
4398
|
-
if (popper.bottom < f(reference.top)) {
|
|
4399
|
-
data.offsets.popper.top = f(reference.top) - popper.height;
|
|
4400
|
-
}
|
|
4401
|
-
if (popper.top > f(reference.bottom)) {
|
|
4402
|
-
data.offsets.popper.top = f(reference.bottom);
|
|
4403
|
-
}
|
|
4404
|
-
|
|
4405
|
-
return data;
|
|
4406
|
-
};
|
|
4407
|
-
|
|
4508
|
+
*/
|
|
4509
|
+
Popper.prototype.modifiers.keepTogether = function (data) {
|
|
4510
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
4511
|
+
var reference = data.offsets.reference;
|
|
4512
|
+
var f = Math.floor;
|
|
4513
|
+
|
|
4514
|
+
if (popper.right < f(reference.left)) {
|
|
4515
|
+
data.offsets.popper.left = f(reference.left) - popper.width;
|
|
4516
|
+
}
|
|
4517
|
+
if (popper.left > f(reference.right)) {
|
|
4518
|
+
data.offsets.popper.left = f(reference.right);
|
|
4519
|
+
}
|
|
4520
|
+
if (popper.bottom < f(reference.top)) {
|
|
4521
|
+
data.offsets.popper.top = f(reference.top) - popper.height;
|
|
4522
|
+
}
|
|
4523
|
+
if (popper.top > f(reference.bottom)) {
|
|
4524
|
+
data.offsets.popper.top = f(reference.bottom);
|
|
4525
|
+
}
|
|
4526
|
+
|
|
4527
|
+
return data;
|
|
4528
|
+
};
|
|
4529
|
+
|
|
4408
4530
|
/**
|
|
4409
4531
|
* Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
|
|
4410
4532
|
* Requires the `preventOverflow` modifier before it in order to work.
|
|
@@ -4413,61 +4535,81 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4413
4535
|
* @memberof Popper.modifiers
|
|
4414
4536
|
* @argument {Object} data - The data object generated by _update method
|
|
4415
4537
|
* @returns {Object} The data object, properly modified
|
|
4416
|
-
*/
|
|
4417
|
-
Popper.prototype.modifiers.flip = function (data) {
|
|
4418
|
-
// check if preventOverflow is in the list of modifiers before the flip modifier.
|
|
4419
|
-
// otherwise flip would not work as expected.
|
|
4420
|
-
if (
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
flipOrder
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4538
|
+
*/
|
|
4539
|
+
Popper.prototype.modifiers.flip = function (data) {
|
|
4540
|
+
// check if preventOverflow is in the list of modifiers before the flip modifier.
|
|
4541
|
+
// otherwise flip would not work as expected.
|
|
4542
|
+
if (
|
|
4543
|
+
!this.isModifierRequired(
|
|
4544
|
+
this.modifiers.flip,
|
|
4545
|
+
this.modifiers.preventOverflow
|
|
4546
|
+
)
|
|
4547
|
+
) {
|
|
4548
|
+
console.warn(
|
|
4549
|
+
'WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!'
|
|
4550
|
+
);
|
|
4551
|
+
return data;
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4554
|
+
if (data.flipped && data.placement === data._originalPlacement) {
|
|
4555
|
+
// seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
|
|
4556
|
+
return data;
|
|
4557
|
+
}
|
|
4558
|
+
|
|
4559
|
+
var placement = data.placement.split('-')[0];
|
|
4560
|
+
var placementOpposite = getOppositePlacement(placement);
|
|
4561
|
+
var variation = data.placement.split('-')[1] || '';
|
|
4562
|
+
|
|
4563
|
+
var flipOrder = [];
|
|
4564
|
+
if (this._options.flipBehavior === 'flip') {
|
|
4565
|
+
flipOrder = [placement, placementOpposite];
|
|
4566
|
+
} else {
|
|
4567
|
+
flipOrder = this._options.flipBehavior;
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4570
|
+
flipOrder.forEach(
|
|
4571
|
+
function (step, index) {
|
|
4572
|
+
if (placement !== step || flipOrder.length === index + 1) {
|
|
4573
|
+
return;
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4576
|
+
placement = data.placement.split('-')[0];
|
|
4577
|
+
placementOpposite = getOppositePlacement(placement);
|
|
4578
|
+
|
|
4579
|
+
var popperOffsets = getPopperClientRect(data.offsets.popper);
|
|
4580
|
+
|
|
4581
|
+
// this boolean is used to distinguish right and bottom from top and left
|
|
4582
|
+
// they need different computations to get flipped
|
|
4583
|
+
var a = ['right', 'bottom'].indexOf(placement) !== -1;
|
|
4584
|
+
|
|
4585
|
+
// using Math.floor because the reference offsets may contain decimals we are not going to consider here
|
|
4586
|
+
if (
|
|
4587
|
+
(a &&
|
|
4588
|
+
Math.floor(data.offsets.reference[placement]) >
|
|
4589
|
+
Math.floor(popperOffsets[placementOpposite])) ||
|
|
4590
|
+
(!a &&
|
|
4591
|
+
Math.floor(data.offsets.reference[placement]) <
|
|
4592
|
+
Math.floor(popperOffsets[placementOpposite]))
|
|
4593
|
+
) {
|
|
4594
|
+
// we'll use this boolean to detect any flip loop
|
|
4595
|
+
data.flipped = true;
|
|
4596
|
+
data.placement = flipOrder[index + 1];
|
|
4597
|
+
if (variation) {
|
|
4598
|
+
data.placement += '-' + variation;
|
|
4599
|
+
}
|
|
4600
|
+
data.offsets.popper = this._getOffsets(
|
|
4601
|
+
this._popper,
|
|
4602
|
+
this._reference,
|
|
4603
|
+
data.placement
|
|
4604
|
+
).popper;
|
|
4605
|
+
|
|
4606
|
+
data = this.runModifiers(data, this._options.modifiers, this._flip);
|
|
4607
|
+
}
|
|
4608
|
+
}.bind(this)
|
|
4609
|
+
);
|
|
4610
|
+
return data;
|
|
4611
|
+
};
|
|
4612
|
+
|
|
4471
4613
|
/**
|
|
4472
4614
|
* Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
|
|
4473
4615
|
* The offsets will shift the popper on the side of its reference element.
|
|
@@ -4475,23 +4617,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4475
4617
|
* @memberof Popper.modifiers
|
|
4476
4618
|
* @argument {Object} data - The data object generated by _update method
|
|
4477
4619
|
* @returns {Object} The data object, properly modified
|
|
4478
|
-
*/
|
|
4479
|
-
Popper.prototype.modifiers.offset = function (data) {
|
|
4480
|
-
var offset = this._options.offset;
|
|
4481
|
-
var popper = data.offsets.popper;
|
|
4482
|
-
|
|
4483
|
-
if (data.placement.indexOf('left') !== -1) {
|
|
4484
|
-
popper.top -= offset;
|
|
4485
|
-
} else if (data.placement.indexOf('right') !== -1) {
|
|
4486
|
-
popper.top += offset;
|
|
4487
|
-
} else if (data.placement.indexOf('top') !== -1) {
|
|
4488
|
-
popper.left -= offset;
|
|
4489
|
-
} else if (data.placement.indexOf('bottom') !== -1) {
|
|
4490
|
-
popper.left += offset;
|
|
4491
|
-
}
|
|
4492
|
-
return data;
|
|
4493
|
-
};
|
|
4494
|
-
|
|
4620
|
+
*/
|
|
4621
|
+
Popper.prototype.modifiers.offset = function (data) {
|
|
4622
|
+
var offset = this._options.offset;
|
|
4623
|
+
var popper = data.offsets.popper;
|
|
4624
|
+
|
|
4625
|
+
if (data.placement.indexOf('left') !== -1) {
|
|
4626
|
+
popper.top -= offset;
|
|
4627
|
+
} else if (data.placement.indexOf('right') !== -1) {
|
|
4628
|
+
popper.top += offset;
|
|
4629
|
+
} else if (data.placement.indexOf('top') !== -1) {
|
|
4630
|
+
popper.left -= offset;
|
|
4631
|
+
} else if (data.placement.indexOf('bottom') !== -1) {
|
|
4632
|
+
popper.left += offset;
|
|
4633
|
+
}
|
|
4634
|
+
return data;
|
|
4635
|
+
};
|
|
4636
|
+
|
|
4495
4637
|
/**
|
|
4496
4638
|
* Modifier used to move the arrows on the edge of the popper to make sure them are always between the popper and the reference element
|
|
4497
4639
|
* It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
|
|
@@ -4499,136 +4641,147 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4499
4641
|
* @memberof Popper.modifiers
|
|
4500
4642
|
* @argument {Object} data - The data object generated by _update method
|
|
4501
4643
|
* @returns {Object} The data object, properly modified
|
|
4502
|
-
*/
|
|
4503
|
-
Popper.prototype.modifiers.arrow = function (data) {
|
|
4504
|
-
var arrow = this._options.arrowElement;
|
|
4505
|
-
var arrowOffset = this._options.arrowOffset;
|
|
4506
|
-
|
|
4507
|
-
// if the arrowElement is a string, suppose it's a CSS selector
|
|
4508
|
-
if (typeof arrow === 'string') {
|
|
4509
|
-
arrow = this._popper.querySelector(arrow);
|
|
4510
|
-
}
|
|
4511
|
-
|
|
4512
|
-
// if arrow element is not found, don't run the modifier
|
|
4513
|
-
if (!arrow) {
|
|
4514
|
-
return data;
|
|
4515
|
-
}
|
|
4516
|
-
|
|
4517
|
-
// the arrow element must be child of its popper
|
|
4518
|
-
if (!this._popper.contains(arrow)) {
|
|
4519
|
-
console.warn(
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
var
|
|
4539
|
-
var
|
|
4540
|
-
var
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
//
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
//
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4644
|
+
*/
|
|
4645
|
+
Popper.prototype.modifiers.arrow = function (data) {
|
|
4646
|
+
var arrow = this._options.arrowElement;
|
|
4647
|
+
var arrowOffset = this._options.arrowOffset;
|
|
4648
|
+
|
|
4649
|
+
// if the arrowElement is a string, suppose it's a CSS selector
|
|
4650
|
+
if (typeof arrow === 'string') {
|
|
4651
|
+
arrow = this._popper.querySelector(arrow);
|
|
4652
|
+
}
|
|
4653
|
+
|
|
4654
|
+
// if arrow element is not found, don't run the modifier
|
|
4655
|
+
if (!arrow) {
|
|
4656
|
+
return data;
|
|
4657
|
+
}
|
|
4658
|
+
|
|
4659
|
+
// the arrow element must be child of its popper
|
|
4660
|
+
if (!this._popper.contains(arrow)) {
|
|
4661
|
+
console.warn(
|
|
4662
|
+
'WARNING: `arrowElement` must be child of its popper element!'
|
|
4663
|
+
);
|
|
4664
|
+
return data;
|
|
4665
|
+
}
|
|
4666
|
+
|
|
4667
|
+
// arrow depends on keepTogether in order to work
|
|
4668
|
+
if (
|
|
4669
|
+
!this.isModifierRequired(
|
|
4670
|
+
this.modifiers.arrow,
|
|
4671
|
+
this.modifiers.keepTogether
|
|
4672
|
+
)
|
|
4673
|
+
) {
|
|
4674
|
+
console.warn(
|
|
4675
|
+
'WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!'
|
|
4676
|
+
);
|
|
4677
|
+
return data;
|
|
4678
|
+
}
|
|
4679
|
+
|
|
4680
|
+
var arrowStyle = {};
|
|
4681
|
+
var placement = data.placement.split('-')[0];
|
|
4682
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
4683
|
+
var reference = data.offsets.reference;
|
|
4684
|
+
var isVertical = ['left', 'right'].indexOf(placement) !== -1;
|
|
4685
|
+
|
|
4686
|
+
var len = isVertical ? 'height' : 'width';
|
|
4687
|
+
var side = isVertical ? 'top' : 'left';
|
|
4688
|
+
var translate = isVertical ? 'translateY' : 'translateX';
|
|
4689
|
+
var altSide = isVertical ? 'left' : 'top';
|
|
4690
|
+
var opSide = isVertical ? 'bottom' : 'right';
|
|
4691
|
+
var arrowSize = getOuterSizes(arrow)[len];
|
|
4692
|
+
|
|
4693
|
+
//
|
|
4694
|
+
// extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
|
|
4695
|
+
//
|
|
4696
|
+
|
|
4697
|
+
// top/left side
|
|
4698
|
+
if (reference[opSide] - arrowSize < popper[side]) {
|
|
4699
|
+
data.offsets.popper[side] -=
|
|
4700
|
+
popper[side] - (reference[opSide] - arrowSize);
|
|
4701
|
+
}
|
|
4702
|
+
// bottom/right side
|
|
4703
|
+
if (reference[side] + arrowSize > popper[opSide]) {
|
|
4704
|
+
data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
|
|
4705
|
+
}
|
|
4706
|
+
|
|
4707
|
+
// compute center of the popper
|
|
4708
|
+
var center =
|
|
4709
|
+
reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
|
|
4710
|
+
|
|
4711
|
+
var sideValue = center - popper[side];
|
|
4712
|
+
|
|
4713
|
+
// prevent arrow from being placed not contiguously to its popper
|
|
4714
|
+
sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
|
|
4715
|
+
arrowStyle[side] = sideValue;
|
|
4716
|
+
arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
|
|
4717
|
+
|
|
4718
|
+
data.offsets.arrow = arrowStyle;
|
|
4719
|
+
data.arrowElement = arrow;
|
|
4720
|
+
|
|
4721
|
+
return data;
|
|
4722
|
+
};
|
|
4723
|
+
|
|
4724
|
+
//
|
|
4725
|
+
// Helpers
|
|
4726
|
+
//
|
|
4727
|
+
|
|
4575
4728
|
/**
|
|
4576
4729
|
* Get the outer sizes of the given element (offset size + margins)
|
|
4577
4730
|
* @function
|
|
4578
4731
|
* @ignore
|
|
4579
4732
|
* @argument {Element} element
|
|
4580
4733
|
* @returns {Object} object containing width and height properties
|
|
4581
|
-
*/
|
|
4582
|
-
function getOuterSizes(element) {
|
|
4583
|
-
// NOTE: 1 DOM access here
|
|
4584
|
-
var _display = element.style.display,
|
|
4585
|
-
|
|
4586
|
-
element.style.display = 'block';
|
|
4587
|
-
element.style.visibility = 'hidden';
|
|
4588
|
-
var calcWidthToForceRepaint = element.offsetWidth;
|
|
4589
|
-
// original method
|
|
4590
|
-
var styles = root.getComputedStyle(element);
|
|
4591
|
-
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
4592
|
-
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
4593
|
-
var result = {
|
|
4594
|
-
width: element.offsetWidth + y,
|
|
4595
|
-
height: element.offsetHeight + x
|
|
4596
|
-
};
|
|
4597
|
-
|
|
4598
|
-
// reset element styles
|
|
4599
|
-
element.style.display = _display;
|
|
4600
|
-
element.style.visibility = _visibility;
|
|
4601
|
-
return result;
|
|
4602
|
-
}
|
|
4603
|
-
|
|
4734
|
+
*/
|
|
4735
|
+
function getOuterSizes(element) {
|
|
4736
|
+
// NOTE: 1 DOM access here
|
|
4737
|
+
var _display = element.style.display,
|
|
4738
|
+
_visibility = element.style.visibility;
|
|
4739
|
+
element.style.display = 'block';
|
|
4740
|
+
element.style.visibility = 'hidden';
|
|
4741
|
+
var calcWidthToForceRepaint = element.offsetWidth;
|
|
4742
|
+
// original method
|
|
4743
|
+
var styles = root.getComputedStyle(element);
|
|
4744
|
+
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
4745
|
+
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
4746
|
+
var result = {
|
|
4747
|
+
width: element.offsetWidth + y,
|
|
4748
|
+
height: element.offsetHeight + x
|
|
4749
|
+
};
|
|
4750
|
+
|
|
4751
|
+
// reset element styles
|
|
4752
|
+
element.style.display = _display;
|
|
4753
|
+
element.style.visibility = _visibility;
|
|
4754
|
+
return result;
|
|
4755
|
+
}
|
|
4756
|
+
|
|
4604
4757
|
/**
|
|
4605
4758
|
* Get the opposite placement of the given one/
|
|
4606
4759
|
* @function
|
|
4607
4760
|
* @ignore
|
|
4608
4761
|
* @argument {String} placement
|
|
4609
4762
|
* @returns {String} flipped placement
|
|
4610
|
-
*/
|
|
4611
|
-
function getOppositePlacement(placement) {
|
|
4612
|
-
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
|
4613
|
-
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
4614
|
-
return hash[matched];
|
|
4615
|
-
});
|
|
4616
|
-
}
|
|
4617
|
-
|
|
4763
|
+
*/
|
|
4764
|
+
function getOppositePlacement(placement) {
|
|
4765
|
+
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
|
4766
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
4767
|
+
return hash[matched];
|
|
4768
|
+
});
|
|
4769
|
+
}
|
|
4770
|
+
|
|
4618
4771
|
/**
|
|
4619
4772
|
* Given the popper offsets, generate an output similar to getBoundingClientRect
|
|
4620
4773
|
* @function
|
|
4621
4774
|
* @ignore
|
|
4622
4775
|
* @argument {Object} popperOffsets
|
|
4623
4776
|
* @returns {Object} ClientRect like output
|
|
4624
|
-
*/
|
|
4625
|
-
function getPopperClientRect(popperOffsets) {
|
|
4626
|
-
var offsets = Object.assign({}, popperOffsets);
|
|
4627
|
-
offsets.right = offsets.left + offsets.width;
|
|
4628
|
-
offsets.bottom = offsets.top + offsets.height;
|
|
4629
|
-
return offsets;
|
|
4630
|
-
}
|
|
4631
|
-
|
|
4777
|
+
*/
|
|
4778
|
+
function getPopperClientRect(popperOffsets) {
|
|
4779
|
+
var offsets = Object.assign({}, popperOffsets);
|
|
4780
|
+
offsets.right = offsets.left + offsets.width;
|
|
4781
|
+
offsets.bottom = offsets.top + offsets.height;
|
|
4782
|
+
return offsets;
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4632
4785
|
/**
|
|
4633
4786
|
* Given an array and the key to find, returns its index
|
|
4634
4787
|
* @function
|
|
@@ -4636,76 +4789,88 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4636
4789
|
* @argument {Array} arr
|
|
4637
4790
|
* @argument keyToFind
|
|
4638
4791
|
* @returns index or null
|
|
4639
|
-
*/
|
|
4640
|
-
function getArrayKeyIndex(arr, keyToFind) {
|
|
4641
|
-
var i = 0,
|
|
4642
|
-
|
|
4643
|
-
for (key in arr) {
|
|
4644
|
-
if (arr[key] === keyToFind) {
|
|
4645
|
-
return i;
|
|
4646
|
-
}
|
|
4647
|
-
i++;
|
|
4648
|
-
}
|
|
4649
|
-
return null;
|
|
4650
|
-
}
|
|
4651
|
-
|
|
4792
|
+
*/
|
|
4793
|
+
function getArrayKeyIndex(arr, keyToFind) {
|
|
4794
|
+
var i = 0,
|
|
4795
|
+
key;
|
|
4796
|
+
for (key in arr) {
|
|
4797
|
+
if (arr[key] === keyToFind) {
|
|
4798
|
+
return i;
|
|
4799
|
+
}
|
|
4800
|
+
i++;
|
|
4801
|
+
}
|
|
4802
|
+
return null;
|
|
4803
|
+
}
|
|
4804
|
+
|
|
4652
4805
|
/**
|
|
4653
4806
|
* Get CSS computed property of the given element
|
|
4654
4807
|
* @function
|
|
4655
4808
|
* @ignore
|
|
4656
4809
|
* @argument {Eement} element
|
|
4657
4810
|
* @argument {String} property
|
|
4658
|
-
*/
|
|
4659
|
-
function getStyleComputedProperty(element, property) {
|
|
4660
|
-
// NOTE: 1 DOM access here
|
|
4661
|
-
var css = root.getComputedStyle(element, null);
|
|
4662
|
-
return css[property];
|
|
4663
|
-
}
|
|
4811
|
+
*/
|
|
4812
|
+
function getStyleComputedProperty(element, property) {
|
|
4813
|
+
// NOTE: 1 DOM access here
|
|
4814
|
+
var css = root.getComputedStyle(element, null);
|
|
4815
|
+
return css[property];
|
|
4816
|
+
}
|
|
4664
4817
|
/**
|
|
4665
4818
|
* Returns the offset parent of the given element
|
|
4666
4819
|
* @function
|
|
4667
4820
|
* @ignore
|
|
4668
4821
|
* @argument {Element} element
|
|
4669
4822
|
* @returns {Element} offset parent
|
|
4670
|
-
*/
|
|
4671
|
-
function getOffsetParent(element) {
|
|
4672
|
-
var offsetParent = element.offsetParent;
|
|
4673
|
-
return offsetParent === root.document.body || !offsetParent
|
|
4674
|
-
|
|
4675
|
-
|
|
4823
|
+
*/
|
|
4824
|
+
function getOffsetParent(element) {
|
|
4825
|
+
var offsetParent = element.offsetParent;
|
|
4826
|
+
return offsetParent === root.document.body || !offsetParent
|
|
4827
|
+
? root.document.documentElement
|
|
4828
|
+
: offsetParent;
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4676
4831
|
/**
|
|
4677
4832
|
* Returns the scrolling parent of the given element
|
|
4678
4833
|
* @function
|
|
4679
4834
|
* @ignore
|
|
4680
4835
|
* @argument {Element} element
|
|
4681
4836
|
* @returns {Element} offset parent
|
|
4682
|
-
*/
|
|
4683
|
-
function getScrollParent(element) {
|
|
4684
|
-
var parent = element.parentNode;
|
|
4685
|
-
if (!parent || parent.nodeType !== 1) {
|
|
4686
|
-
return element;
|
|
4687
|
-
}
|
|
4688
|
-
|
|
4689
|
-
if (parent === root.document) {
|
|
4690
|
-
// Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
|
|
4691
|
-
// greater than 0 and return the proper element
|
|
4692
|
-
if (root.document.body.scrollTop || root.document.body.scrollLeft) {
|
|
4693
|
-
return root.document.body;
|
|
4694
|
-
} else {
|
|
4695
|
-
return root.document.documentElement;
|
|
4696
|
-
}
|
|
4697
|
-
}
|
|
4698
|
-
|
|
4699
|
-
// Firefox want us to check `-x` and `-y` variations as well
|
|
4700
|
-
if (
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4837
|
+
*/
|
|
4838
|
+
function getScrollParent(element) {
|
|
4839
|
+
var parent = element.parentNode;
|
|
4840
|
+
if (!parent || parent.nodeType !== 1) {
|
|
4841
|
+
return element;
|
|
4842
|
+
}
|
|
4843
|
+
|
|
4844
|
+
if (parent === root.document) {
|
|
4845
|
+
// Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
|
|
4846
|
+
// greater than 0 and return the proper element
|
|
4847
|
+
if (root.document.body.scrollTop || root.document.body.scrollLeft) {
|
|
4848
|
+
return root.document.body;
|
|
4849
|
+
} else {
|
|
4850
|
+
return root.document.documentElement;
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
|
|
4854
|
+
// Firefox want us to check `-x` and `-y` variations as well
|
|
4855
|
+
if (
|
|
4856
|
+
['scroll', 'auto'].indexOf(
|
|
4857
|
+
getStyleComputedProperty(parent, 'overflow')
|
|
4858
|
+
) !== -1 ||
|
|
4859
|
+
['scroll', 'auto'].indexOf(
|
|
4860
|
+
getStyleComputedProperty(parent, 'overflow-x')
|
|
4861
|
+
) !== -1 ||
|
|
4862
|
+
['scroll', 'auto'].indexOf(
|
|
4863
|
+
getStyleComputedProperty(parent, 'overflow-y')
|
|
4864
|
+
) !== -1
|
|
4865
|
+
) {
|
|
4866
|
+
// If the detected scrollParent is body, we perform an additional check on its parentNode
|
|
4867
|
+
// in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
|
|
4868
|
+
// fixes issue #65
|
|
4869
|
+
return parent;
|
|
4870
|
+
}
|
|
4871
|
+
return getScrollParent(element.parentNode);
|
|
4872
|
+
}
|
|
4873
|
+
|
|
4709
4874
|
/**
|
|
4710
4875
|
* Check if the given element is fixed or is inside a fixed parent
|
|
4711
4876
|
* @function
|
|
@@ -4713,109 +4878,122 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4713
4878
|
* @argument {Element} element
|
|
4714
4879
|
* @argument {Element} customContainer
|
|
4715
4880
|
* @returns {Boolean} answer to "isFixed?"
|
|
4716
|
-
*/
|
|
4717
|
-
function isFixed(element) {
|
|
4718
|
-
if (element === root.document.body) {
|
|
4719
|
-
return false;
|
|
4720
|
-
}
|
|
4721
|
-
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
|
4722
|
-
return true;
|
|
4723
|
-
}
|
|
4724
|
-
return element.parentNode && element.parentNode.nodeType === 1
|
|
4725
|
-
|
|
4726
|
-
|
|
4881
|
+
*/
|
|
4882
|
+
function isFixed(element) {
|
|
4883
|
+
if (element === root.document.body) {
|
|
4884
|
+
return false;
|
|
4885
|
+
}
|
|
4886
|
+
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
|
4887
|
+
return true;
|
|
4888
|
+
}
|
|
4889
|
+
return element.parentNode && element.parentNode.nodeType === 1
|
|
4890
|
+
? isFixed(element.parentNode)
|
|
4891
|
+
: element;
|
|
4892
|
+
}
|
|
4893
|
+
|
|
4727
4894
|
/**
|
|
4728
4895
|
* Set the style to the given popper
|
|
4729
4896
|
* @function
|
|
4730
4897
|
* @ignore
|
|
4731
4898
|
* @argument {Element} element - Element to apply the style to
|
|
4732
4899
|
* @argument {Object} styles - Object with a list of properties and values which will be applied to the element
|
|
4733
|
-
*/
|
|
4734
|
-
function setStyle(element, styles) {
|
|
4735
|
-
function is_numeric(n) {
|
|
4736
|
-
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
|
4737
|
-
}
|
|
4738
|
-
Object.keys(styles).forEach(function (prop) {
|
|
4739
|
-
var unit = '';
|
|
4740
|
-
// add unit if the value is numeric and is one of the following
|
|
4741
|
-
if (
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4900
|
+
*/
|
|
4901
|
+
function setStyle(element, styles) {
|
|
4902
|
+
function is_numeric(n) {
|
|
4903
|
+
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
|
4904
|
+
}
|
|
4905
|
+
Object.keys(styles).forEach(function (prop) {
|
|
4906
|
+
var unit = '';
|
|
4907
|
+
// add unit if the value is numeric and is one of the following
|
|
4908
|
+
if (
|
|
4909
|
+
['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !==
|
|
4910
|
+
-1 &&
|
|
4911
|
+
is_numeric(styles[prop])
|
|
4912
|
+
) {
|
|
4913
|
+
unit = 'px';
|
|
4914
|
+
}
|
|
4915
|
+
element.style[prop] = styles[prop] + unit;
|
|
4916
|
+
});
|
|
4917
|
+
}
|
|
4918
|
+
|
|
4748
4919
|
/**
|
|
4749
4920
|
* Check if the given variable is a function
|
|
4750
4921
|
* @function
|
|
4751
4922
|
* @ignore
|
|
4752
4923
|
* @argument {*} functionToCheck - variable to check
|
|
4753
4924
|
* @returns {Boolean} answer to: is a function?
|
|
4754
|
-
*/
|
|
4755
|
-
function isFunction(functionToCheck) {
|
|
4756
|
-
var getType = {};
|
|
4757
|
-
return
|
|
4758
|
-
|
|
4759
|
-
|
|
4925
|
+
*/
|
|
4926
|
+
function isFunction(functionToCheck) {
|
|
4927
|
+
var getType = {};
|
|
4928
|
+
return (
|
|
4929
|
+
functionToCheck &&
|
|
4930
|
+
getType.toString.call(functionToCheck) === '[object Function]'
|
|
4931
|
+
);
|
|
4932
|
+
}
|
|
4933
|
+
|
|
4760
4934
|
/**
|
|
4761
4935
|
* Get the position of the given element, relative to its offset parent
|
|
4762
4936
|
* @function
|
|
4763
4937
|
* @ignore
|
|
4764
4938
|
* @param {Element} element
|
|
4765
4939
|
* @return {Object} position - Coordinates of the element and its `scrollTop`
|
|
4766
|
-
*/
|
|
4767
|
-
function getOffsetRect(element) {
|
|
4768
|
-
var transform = getStyle(element, 'transform')
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4940
|
+
*/
|
|
4941
|
+
function getOffsetRect(element) {
|
|
4942
|
+
var transform = getStyle(element, 'transform')
|
|
4943
|
+
.replace(/[^0-9\-,]/g, '')
|
|
4944
|
+
.split(',');
|
|
4945
|
+
var elementRect = {
|
|
4946
|
+
width: element.offsetWidth,
|
|
4947
|
+
height: element.offsetHeight,
|
|
4948
|
+
left:
|
|
4949
|
+
element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
|
|
4950
|
+
top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
|
|
4951
|
+
};
|
|
4952
|
+
|
|
4953
|
+
elementRect.right = elementRect.left + elementRect.width;
|
|
4954
|
+
elementRect.bottom = elementRect.top + elementRect.height;
|
|
4955
|
+
|
|
4956
|
+
// position
|
|
4957
|
+
return elementRect;
|
|
4958
|
+
}
|
|
4959
|
+
|
|
4783
4960
|
/**
|
|
4784
4961
|
* Get bounding client rect of given element
|
|
4785
4962
|
* @function
|
|
4786
4963
|
* @ignore
|
|
4787
4964
|
* @param {HTMLElement} element
|
|
4788
4965
|
* @return {Object} client rect
|
|
4789
|
-
*/
|
|
4790
|
-
function getBoundingClientRect(element) {
|
|
4791
|
-
var rect = element.getBoundingClientRect();
|
|
4792
|
-
|
|
4793
|
-
// whether the IE version is lower than 11
|
|
4794
|
-
var isIE = /MSIE|Trident/.test(navigator.userAgent);
|
|
4795
|
-
|
|
4796
|
-
// fix ie document bounding top always 0 bug
|
|
4797
|
-
var rectTop =
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4966
|
+
*/
|
|
4967
|
+
function getBoundingClientRect(element) {
|
|
4968
|
+
var rect = element.getBoundingClientRect();
|
|
4969
|
+
|
|
4970
|
+
// whether the IE version is lower than 11
|
|
4971
|
+
var isIE = /MSIE|Trident/.test(navigator.userAgent);
|
|
4972
|
+
|
|
4973
|
+
// fix ie document bounding top always 0 bug
|
|
4974
|
+
var rectTop =
|
|
4975
|
+
isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
|
|
4976
|
+
|
|
4977
|
+
return {
|
|
4978
|
+
left: rect.left,
|
|
4979
|
+
top: rectTop,
|
|
4980
|
+
right: rect.right,
|
|
4981
|
+
bottom: rect.bottom,
|
|
4982
|
+
width: rect.right - rect.left,
|
|
4983
|
+
height: rect.bottom - rectTop
|
|
4984
|
+
};
|
|
4985
|
+
}
|
|
4986
|
+
|
|
4987
|
+
function getStyle(dom, attr) {
|
|
4988
|
+
if (dom.style[attr]) {
|
|
4989
|
+
return dom.style[attr];
|
|
4990
|
+
}
|
|
4991
|
+
if (window.getComputedStyle) {
|
|
4992
|
+
return getComputedStyle(dom, null)[attr];
|
|
4993
|
+
}
|
|
4994
|
+
return dom.currentStyle[attr];
|
|
4995
|
+
}
|
|
4996
|
+
|
|
4819
4997
|
/**
|
|
4820
4998
|
* Given an element and one of its parents, return the offset
|
|
4821
4999
|
* @function
|
|
@@ -4823,49 +5001,51 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4823
5001
|
* @param {HTMLElement} element
|
|
4824
5002
|
* @param {HTMLElement} parent
|
|
4825
5003
|
* @return {Object} rect
|
|
4826
|
-
*/
|
|
4827
|
-
function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
|
|
4828
|
-
var elementRect = getBoundingClientRect(element);
|
|
4829
|
-
var parentRect = getBoundingClientRect(parent);
|
|
4830
|
-
|
|
4831
|
-
if (fixed) {
|
|
4832
|
-
var scrollParent = getScrollParent(parent);
|
|
4833
|
-
parentRect.top += scrollParent.scrollTop;
|
|
4834
|
-
parentRect.bottom += scrollParent.scrollTop;
|
|
4835
|
-
parentRect.left += scrollParent.scrollLeft;
|
|
4836
|
-
parentRect.right += scrollParent.scrollLeft;
|
|
4837
|
-
}
|
|
4838
|
-
|
|
4839
|
-
var rect = {
|
|
4840
|
-
top: elementRect.top - parentRect.top,
|
|
4841
|
-
left: elementRect.left - parentRect.left,
|
|
4842
|
-
bottom: elementRect.top - parentRect.top + elementRect.height,
|
|
4843
|
-
right: elementRect.left - parentRect.left + elementRect.width,
|
|
4844
|
-
width: elementRect.width,
|
|
4845
|
-
height: elementRect.height
|
|
4846
|
-
};
|
|
4847
|
-
return rect;
|
|
4848
|
-
}
|
|
4849
|
-
|
|
5004
|
+
*/
|
|
5005
|
+
function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
|
|
5006
|
+
var elementRect = getBoundingClientRect(element);
|
|
5007
|
+
var parentRect = getBoundingClientRect(parent);
|
|
5008
|
+
|
|
5009
|
+
if (fixed) {
|
|
5010
|
+
var scrollParent = getScrollParent(parent);
|
|
5011
|
+
parentRect.top += scrollParent.scrollTop;
|
|
5012
|
+
parentRect.bottom += scrollParent.scrollTop;
|
|
5013
|
+
parentRect.left += scrollParent.scrollLeft;
|
|
5014
|
+
parentRect.right += scrollParent.scrollLeft;
|
|
5015
|
+
}
|
|
5016
|
+
|
|
5017
|
+
var rect = {
|
|
5018
|
+
top: elementRect.top - parentRect.top,
|
|
5019
|
+
left: elementRect.left - parentRect.left,
|
|
5020
|
+
bottom: elementRect.top - parentRect.top + elementRect.height,
|
|
5021
|
+
right: elementRect.left - parentRect.left + elementRect.width,
|
|
5022
|
+
width: elementRect.width,
|
|
5023
|
+
height: elementRect.height
|
|
5024
|
+
};
|
|
5025
|
+
return rect;
|
|
5026
|
+
}
|
|
5027
|
+
|
|
4850
5028
|
/**
|
|
4851
5029
|
* Get the prefixed supported property name
|
|
4852
5030
|
* @function
|
|
4853
5031
|
* @ignore
|
|
4854
5032
|
* @argument {String} property (camelCase)
|
|
4855
5033
|
* @returns {String} prefixed property (camelCase)
|
|
4856
|
-
*/
|
|
4857
|
-
function getSupportedPropertyName(property) {
|
|
4858
|
-
var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
|
|
4859
|
-
|
|
4860
|
-
for (var i = 0; i < prefixes.length; i++) {
|
|
4861
|
-
var toCheck = prefixes[i]
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
5034
|
+
*/
|
|
5035
|
+
function getSupportedPropertyName(property) {
|
|
5036
|
+
var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
|
|
5037
|
+
|
|
5038
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
5039
|
+
var toCheck = prefixes[i]
|
|
5040
|
+
? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1)
|
|
5041
|
+
: property;
|
|
5042
|
+
if (typeof root.document.body.style[toCheck] !== 'undefined') {
|
|
5043
|
+
return toCheck;
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
return null;
|
|
5047
|
+
}
|
|
5048
|
+
|
|
4869
5049
|
/**
|
|
4870
5050
|
* The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
|
|
4871
5051
|
* objects to a target object. It will return the target object.
|
|
@@ -4873,41 +5053,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
|
|
|
4873
5053
|
* Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
4874
5054
|
* @function
|
|
4875
5055
|
* @ignore
|
|
4876
|
-
*/
|
|
4877
|
-
if (!Object.assign) {
|
|
4878
|
-
Object.defineProperty(Object, 'assign', {
|
|
4879
|
-
enumerable: false,
|
|
4880
|
-
configurable: true,
|
|
4881
|
-
writable: true,
|
|
4882
|
-
value: function
|
|
4883
|
-
if (target === undefined || target === null) {
|
|
4884
|
-
throw new TypeError('Cannot convert first argument to object');
|
|
4885
|
-
}
|
|
4886
|
-
|
|
4887
|
-
var to = Object(target);
|
|
4888
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
4889
|
-
var nextSource = arguments[i];
|
|
4890
|
-
if (nextSource === undefined || nextSource === null) {
|
|
4891
|
-
continue;
|
|
4892
|
-
}
|
|
4893
|
-
nextSource = Object(nextSource);
|
|
4894
|
-
|
|
4895
|
-
var keysArray = Object.keys(nextSource);
|
|
4896
|
-
for (
|
|
4897
|
-
var
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
5056
|
+
*/
|
|
5057
|
+
if (!Object.assign) {
|
|
5058
|
+
Object.defineProperty(Object, 'assign', {
|
|
5059
|
+
enumerable: false,
|
|
5060
|
+
configurable: true,
|
|
5061
|
+
writable: true,
|
|
5062
|
+
value: function (target) {
|
|
5063
|
+
if (target === undefined || target === null) {
|
|
5064
|
+
throw new TypeError('Cannot convert first argument to object');
|
|
5065
|
+
}
|
|
5066
|
+
|
|
5067
|
+
var to = Object(target);
|
|
5068
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
5069
|
+
var nextSource = arguments[i];
|
|
5070
|
+
if (nextSource === undefined || nextSource === null) {
|
|
5071
|
+
continue;
|
|
5072
|
+
}
|
|
5073
|
+
nextSource = Object(nextSource);
|
|
5074
|
+
|
|
5075
|
+
var keysArray = Object.keys(nextSource);
|
|
5076
|
+
for (
|
|
5077
|
+
var nextIndex = 0, len = keysArray.length;
|
|
5078
|
+
nextIndex < len;
|
|
5079
|
+
nextIndex++
|
|
5080
|
+
) {
|
|
5081
|
+
var nextKey = keysArray[nextIndex];
|
|
5082
|
+
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
|
5083
|
+
if (desc !== undefined && desc.enumerable) {
|
|
5084
|
+
to[nextKey] = nextSource[nextKey];
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
return to;
|
|
5089
|
+
}
|
|
5090
|
+
});
|
|
5091
|
+
}
|
|
5092
|
+
|
|
5093
|
+
return Popper;
|
|
5094
|
+
});
|
|
4908
5095
|
|
|
4909
|
-
return Popper;
|
|
4910
|
-
});
|
|
4911
5096
|
|
|
4912
5097
|
/***/ }),
|
|
4913
5098
|
|