eoss 0.1.0-alpha.39 → 0.1.0-alpha.40
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 +837 -862
- package/lib/alert.js +2 -2
- package/lib/aside.js +2 -2
- package/lib/audit-trajectory.js +4 -4
- package/lib/autocomplete.js +1813 -1988
- 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 +4 -4
- package/lib/button.js +2 -2
- package/lib/ca-login.js +837 -862
- package/lib/calendar.js +839 -864
- package/lib/card.js +2 -2
- package/lib/carousel-item.js +846 -871
- package/lib/carousel.js +839 -864
- package/lib/cascader-panel.js +852 -877
- package/lib/cascader.js +2048 -2223
- package/lib/checkbox-button.js +4 -4
- package/lib/checkbox-group.js +859 -884
- package/lib/checkbox.js +4 -4
- package/lib/col.js +2 -2
- package/lib/collapse-item.js +1040 -1065
- package/lib/collapse.js +1040 -1065
- package/lib/color-picker.js +972 -1122
- package/lib/container.js +2 -2
- package/lib/cron.js +12 -12
- package/lib/data-table.js +843 -868
- package/lib/date-picker.js +10520 -10695
- package/lib/descriptions-item.js +4 -4
- package/lib/descriptions.js +4 -4
- package/lib/dialog.js +837 -862
- package/lib/divider.js +2 -2
- package/lib/drawer.js +2 -2
- package/lib/dropdown-item.js +4 -4
- package/lib/dropdown-menu.js +974 -1124
- package/lib/dropdown.js +841 -866
- package/lib/email-login.js +837 -862
- package/lib/empty.js +2 -2
- package/lib/eoss.common.js +4023 -2668
- package/lib/flip.js +2 -2
- package/lib/flow-group.js +853 -878
- package/lib/flow.js +868 -893
- package/lib/flows.js +854 -879
- package/lib/footer.js +2 -2
- package/lib/form-item.js +860 -885
- package/lib/form.js +933 -950
- package/lib/guide.js +2 -2
- package/lib/header.js +2 -2
- package/lib/icon.js +837 -862
- package/lib/icons.js +2 -2
- package/lib/image-viewer.js +837 -862
- package/lib/image.js +4 -4
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +2 -2
- package/lib/input-number.js +6 -6
- package/lib/input.js +839 -864
- package/lib/link.js +2 -2
- package/lib/loading.js +2 -2
- package/lib/login.js +867 -891
- package/lib/lowcode-view.js +1843 -1185
- package/lib/lowcode.js +3050 -1569
- package/lib/main.js +970 -988
- package/lib/marquee.js +837 -862
- package/lib/menu-item-group.js +15 -15
- package/lib/menu-item.js +6 -6
- package/lib/menu.js +2227 -2368
- package/lib/message-box.js +843 -868
- package/lib/message.js +839 -864
- package/lib/notification.js +861 -886
- package/lib/option-group.js +4 -4
- package/lib/option.js +839 -864
- package/lib/page-header.js +2 -2
- package/lib/pagination.js +839 -864
- package/lib/phone-login.js +847 -866
- package/lib/popconfirm.js +4 -4
- package/lib/popover.js +1831 -2006
- package/lib/process-config.js +839 -864
- package/lib/process-module.js +846 -871
- package/lib/process-rule.js +905 -930
- package/lib/progress.js +2 -2
- package/lib/qr-code.js +4 -4
- package/lib/qrcode-login.js +839 -864
- package/lib/radio-button.js +4 -4
- package/lib/radio-group.js +850 -875
- package/lib/radio.js +4 -4
- package/lib/rate.js +837 -862
- package/lib/retrial-auth.js +837 -862
- package/lib/row.js +2 -2
- package/lib/scrollbar.js +839 -864
- package/lib/select.js +2139 -2314
- package/lib/selector-panel.js +940 -965
- package/lib/selector.js +852 -877
- package/lib/slider.js +4 -4
- package/lib/step.js +32 -32
- package/lib/steps.js +874 -899
- package/lib/submenu.js +1269 -1385
- package/lib/switch.js +839 -864
- package/lib/tab-pane.js +4 -4
- package/lib/table-column.js +840 -865
- package/lib/table.js +1825 -2000
- package/lib/tabs.js +846 -871
- package/lib/tag.js +2 -2
- package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
- package/lib/theme-chalk/fonts/iconfont.woff +0 -0
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/lowcode.css +1 -1
- package/lib/time-picker.js +6471 -6646
- package/lib/time-select.js +5039 -5214
- package/lib/timeline-item.js +2 -2
- package/lib/timeline.js +2 -2
- package/lib/tips.js +837 -862
- package/lib/toolbar.js +4 -4
- package/lib/tooltip.js +1813 -1988
- package/lib/transfer.js +837 -862
- package/lib/tree-group.js +853 -878
- package/lib/tree.js +1026 -1051
- package/lib/update-history.js +4 -4
- package/lib/upload.js +859 -884
- package/lib/wujie.js +841 -866
- package/package.json +1 -1
- package/packages/flow-group/src/main.vue +2 -2
- package/packages/form/src/form-item-render.vue +1 -0
- package/packages/form/src/form-item.vue +12 -6
- package/packages/form/src/form.vue +5 -5
- package/packages/login/src/login.vue +1 -0
- package/packages/lowcode/src/attribute/function.vue +28 -9
- package/packages/lowcode/src/attribute/props.vue +202 -0
- package/packages/lowcode/src/attribute/styles.vue +79 -5
- package/packages/lowcode/src/attribute.vue +61 -4
- package/packages/lowcode/src/canvas.vue +159 -2
- package/packages/lowcode/src/form-render.vue +305 -0
- package/packages/lowcode/src/lowcode.vue +33 -13
- package/packages/lowcode/src/modules.vue +53 -37
- package/packages/lowcode/src/render.vue +80 -25
- package/packages/lowcode/src/util/components.js +100 -0
- package/packages/lowcode/src/util/props-util.js +67 -0
- package/packages/lowcode/src/util/source-generator.js +69 -9
- package/packages/lowcode/src/util/source-parser.js +64 -10
- package/packages/lowcode-view/src/render.vue +48 -18
- package/packages/main/src/components/userinfo.vue +0 -1
- package/packages/menu/src/menu-item-group.vue +1 -1
- package/packages/menu/src/mixins.js +8 -4
- package/packages/menu/src/submenu.vue +35 -5
- package/packages/phone-login/src/phone-login.vue +5 -2
- package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
- package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
- package/packages/theme-chalk/src/lowcode.scss +21 -2
- package/src/index.js +336 -336
package/lib/autocomplete.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 = 207);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ({
|
|
@@ -3788,7 +3788,7 @@ module.exports = require("vue");
|
|
|
3788
3788
|
|
|
3789
3789
|
/***/ }),
|
|
3790
3790
|
|
|
3791
|
-
/***/
|
|
3791
|
+
/***/ 207:
|
|
3792
3792
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3793
3793
|
|
|
3794
3794
|
"use strict";
|
|
@@ -4150,7 +4150,7 @@ var migrating = __webpack_require__(46);
|
|
|
4150
4150
|
var util = __webpack_require__(1);
|
|
4151
4151
|
|
|
4152
4152
|
// EXTERNAL MODULE: ./src/mixins/focus.js
|
|
4153
|
-
var mixins_focus = __webpack_require__(
|
|
4153
|
+
var mixins_focus = __webpack_require__(86);
|
|
4154
4154
|
|
|
4155
4155
|
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/autocomplete/src/autocomplete.vue?vue&type=script&lang=js&
|
|
4156
4156
|
//
|
|
@@ -4694,7 +4694,7 @@ module.exports = require("throttle-debounce");
|
|
|
4694
4694
|
|
|
4695
4695
|
|
|
4696
4696
|
|
|
4697
|
-
var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(
|
|
4697
|
+
var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(53);
|
|
4698
4698
|
var stopPropagation = function stopPropagation(e) {
|
|
4699
4699
|
return e.stopPropagation();
|
|
4700
4700
|
};
|
|
@@ -5854,10 +5854,12 @@ function insertAfter(newEl, targetEl) {
|
|
|
5854
5854
|
|
|
5855
5855
|
/***/ }),
|
|
5856
5856
|
|
|
5857
|
-
/***/
|
|
5857
|
+
/***/ 53:
|
|
5858
5858
|
/***/ (function(module, exports, __webpack_require__) {
|
|
5859
5859
|
|
|
5860
|
-
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__
|
|
5860
|
+
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
5861
|
+
|
|
5862
|
+
/**
|
|
5861
5863
|
* @fileOverview Kickass library to create and place poppers near their reference elements.
|
|
5862
5864
|
* @version {{version}}
|
|
5863
5865
|
* @license
|
|
@@ -5880,68 +5882,60 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
5880
5882
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
5881
5883
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
5882
5884
|
* SOFTWARE.
|
|
5883
|
-
*/
|
|
5884
|
-
|
|
5885
|
-
//
|
|
5886
|
-
// Cross module loader
|
|
5887
|
-
// Supported: Node, AMD, Browser globals
|
|
5888
|
-
//
|
|
5889
|
-
(function (root, factory) {
|
|
5890
|
-
if (true) {
|
|
5891
|
-
// AMD. Register as an anonymous module.
|
|
5885
|
+
*/
|
|
5886
|
+
|
|
5887
|
+
//
|
|
5888
|
+
// Cross module loader
|
|
5889
|
+
// Supported: Node, AMD, Browser globals
|
|
5890
|
+
//
|
|
5891
|
+
(function (root, factory) {
|
|
5892
|
+
if (true) {
|
|
5893
|
+
// AMD. Register as an anonymous module.
|
|
5892
5894
|
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
|
5893
5895
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
|
5894
5896
|
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
|
|
5895
5897
|
__WEBPACK_AMD_DEFINE_FACTORY__),
|
|
5896
|
-
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
5897
|
-
} else {}
|
|
5898
|
-
})(this, function () {
|
|
5899
|
-
'use strict';
|
|
5900
|
-
|
|
5901
|
-
var root =
|
|
5902
|
-
// default options
|
|
5903
|
-
var DEFAULTS = {
|
|
5904
|
-
// placement of the popper
|
|
5905
|
-
placement: 'bottom',
|
|
5906
|
-
|
|
5907
|
-
gpuAcceleration: true,
|
|
5908
|
-
|
|
5909
|
-
// shift popper from its origin by the given amount of pixels (can be negative)
|
|
5910
|
-
offset: 0,
|
|
5911
|
-
|
|
5912
|
-
// the element which will act as boundary of the popper
|
|
5913
|
-
boundariesElement: 'viewport',
|
|
5914
|
-
|
|
5915
|
-
// amount of pixel used to define a minimum distance between the boundaries and the popper
|
|
5916
|
-
boundariesPadding: 5,
|
|
5917
|
-
|
|
5918
|
-
// popper will try to prevent overflow following this order,
|
|
5919
|
-
// by default, then, it could overflow on the left and on top of the boundariesElement
|
|
5920
|
-
preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
|
|
5921
|
-
|
|
5922
|
-
// the behavior used by flip to change the placement of the popper
|
|
5923
|
-
flipBehavior: 'flip',
|
|
5924
|
-
|
|
5925
|
-
arrowElement: '[x-arrow]',
|
|
5926
|
-
|
|
5927
|
-
arrowOffset: 0,
|
|
5928
|
-
|
|
5929
|
-
// list of functions used to modify the offsets before they are applied to the popper
|
|
5930
|
-
modifiers: [
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
'applyStyle'
|
|
5938
|
-
],
|
|
5939
|
-
|
|
5940
|
-
modifiersIgnored: [],
|
|
5941
|
-
|
|
5942
|
-
forceAbsolute: false
|
|
5943
|
-
};
|
|
5944
|
-
|
|
5898
|
+
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
5899
|
+
} else {}
|
|
5900
|
+
})(this, function () {
|
|
5901
|
+
'use strict';
|
|
5902
|
+
|
|
5903
|
+
var root = window;
|
|
5904
|
+
// default options
|
|
5905
|
+
var DEFAULTS = {
|
|
5906
|
+
// placement of the popper
|
|
5907
|
+
placement: 'bottom',
|
|
5908
|
+
|
|
5909
|
+
gpuAcceleration: true,
|
|
5910
|
+
|
|
5911
|
+
// shift popper from its origin by the given amount of pixels (can be negative)
|
|
5912
|
+
offset: 0,
|
|
5913
|
+
|
|
5914
|
+
// the element which will act as boundary of the popper
|
|
5915
|
+
boundariesElement: 'viewport',
|
|
5916
|
+
|
|
5917
|
+
// amount of pixel used to define a minimum distance between the boundaries and the popper
|
|
5918
|
+
boundariesPadding: 5,
|
|
5919
|
+
|
|
5920
|
+
// popper will try to prevent overflow following this order,
|
|
5921
|
+
// by default, then, it could overflow on the left and on top of the boundariesElement
|
|
5922
|
+
preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
|
|
5923
|
+
|
|
5924
|
+
// the behavior used by flip to change the placement of the popper
|
|
5925
|
+
flipBehavior: 'flip',
|
|
5926
|
+
|
|
5927
|
+
arrowElement: '[x-arrow]',
|
|
5928
|
+
|
|
5929
|
+
arrowOffset: 0,
|
|
5930
|
+
|
|
5931
|
+
// list of functions used to modify the offsets before they are applied to the popper
|
|
5932
|
+
modifiers: ['shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
|
|
5933
|
+
|
|
5934
|
+
modifiersIgnored: [],
|
|
5935
|
+
|
|
5936
|
+
forceAbsolute: false
|
|
5937
|
+
};
|
|
5938
|
+
|
|
5945
5939
|
/**
|
|
5946
5940
|
* Create a new Popper.js instance
|
|
5947
5941
|
* @constructor Popper
|
|
@@ -6006,125 +6000,114 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6006
6000
|
*
|
|
6007
6001
|
* @param {Boolean} [options.removeOnDestroy=false]
|
|
6008
6002
|
* Set to true if you want to automatically remove the popper when you call the `destroy` method.
|
|
6009
|
-
*/
|
|
6010
|
-
function Popper(reference, popper, options) {
|
|
6011
|
-
this._reference = reference.jquery ? reference[0] : reference;
|
|
6012
|
-
this.state = {};
|
|
6013
|
-
|
|
6014
|
-
// if the popper variable is a configuration object, parse it to generate an HTMLElement
|
|
6015
|
-
// generate a default popper if is not defined
|
|
6016
|
-
var isNotDefined = typeof popper === 'undefined' || popper === null;
|
|
6017
|
-
var isConfig =
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
);
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
//
|
|
6052
|
-
this.
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
//
|
|
6060
|
-
// Methods
|
|
6061
|
-
//
|
|
6003
|
+
*/
|
|
6004
|
+
function Popper(reference, popper, options) {
|
|
6005
|
+
this._reference = reference.jquery ? reference[0] : reference;
|
|
6006
|
+
this.state = {};
|
|
6007
|
+
|
|
6008
|
+
// if the popper variable is a configuration object, parse it to generate an HTMLElement
|
|
6009
|
+
// generate a default popper if is not defined
|
|
6010
|
+
var isNotDefined = typeof popper === 'undefined' || popper === null;
|
|
6011
|
+
var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
|
|
6012
|
+
if (isNotDefined || isConfig) {
|
|
6013
|
+
this._popper = this.parse(isConfig ? popper : {});
|
|
6014
|
+
}
|
|
6015
|
+
// otherwise, use the given HTMLElement as popper
|
|
6016
|
+
else {
|
|
6017
|
+
this._popper = popper.jquery ? popper[0] : popper;
|
|
6018
|
+
}
|
|
6019
|
+
|
|
6020
|
+
// with {} we create a new object with the options inside it
|
|
6021
|
+
this._options = Object.assign({}, DEFAULTS, options);
|
|
6022
|
+
|
|
6023
|
+
// refactoring modifiers' list
|
|
6024
|
+
this._options.modifiers = this._options.modifiers.map(function (modifier) {
|
|
6025
|
+
// remove ignored modifiers
|
|
6026
|
+
if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
|
|
6027
|
+
|
|
6028
|
+
// set the x-placement attribute before everything else because it could be used to add margins to the popper
|
|
6029
|
+
// margins needs to be calculated to get the correct popper offsets
|
|
6030
|
+
if (modifier === 'applyStyle') {
|
|
6031
|
+
this._popper.setAttribute('x-placement', this._options.placement);
|
|
6032
|
+
}
|
|
6033
|
+
|
|
6034
|
+
// return predefined modifier identified by string or keep the custom one
|
|
6035
|
+
return this.modifiers[modifier] || modifier;
|
|
6036
|
+
}.bind(this));
|
|
6037
|
+
|
|
6038
|
+
// make sure to apply the popper position before any computation
|
|
6039
|
+
this.state.position = this._getPosition(this._popper, this._reference);
|
|
6040
|
+
setStyle(this._popper, { position: this.state.position, top: 0 });
|
|
6041
|
+
|
|
6042
|
+
// fire the first update to position the popper in the right place
|
|
6043
|
+
this.update();
|
|
6044
|
+
|
|
6045
|
+
// setup event listeners, they will take care of update the position in specific situations
|
|
6046
|
+
this._setupEventListeners();
|
|
6047
|
+
return this;
|
|
6048
|
+
}
|
|
6049
|
+
|
|
6050
|
+
//
|
|
6051
|
+
// Methods
|
|
6052
|
+
//
|
|
6062
6053
|
/**
|
|
6063
6054
|
* Destroy the popper
|
|
6064
6055
|
* @method
|
|
6065
6056
|
* @memberof Popper
|
|
6066
|
-
*/
|
|
6067
|
-
Popper.prototype.destroy = function () {
|
|
6068
|
-
this._popper.removeAttribute('x-placement');
|
|
6069
|
-
this._popper.style.left = '';
|
|
6070
|
-
this._popper.style.position = '';
|
|
6071
|
-
this._popper.style.top = '';
|
|
6072
|
-
this._popper.style[getSupportedPropertyName('transform')] = '';
|
|
6073
|
-
this._removeEventListeners();
|
|
6074
|
-
|
|
6075
|
-
// remove the popper if user explicity asked for the deletion on destroy
|
|
6076
|
-
if (this._options.removeOnDestroy) {
|
|
6077
|
-
this._popper.remove();
|
|
6078
|
-
}
|
|
6079
|
-
return this;
|
|
6080
|
-
};
|
|
6081
|
-
|
|
6057
|
+
*/
|
|
6058
|
+
Popper.prototype.destroy = function () {
|
|
6059
|
+
this._popper.removeAttribute('x-placement');
|
|
6060
|
+
this._popper.style.left = '';
|
|
6061
|
+
this._popper.style.position = '';
|
|
6062
|
+
this._popper.style.top = '';
|
|
6063
|
+
this._popper.style[getSupportedPropertyName('transform')] = '';
|
|
6064
|
+
this._removeEventListeners();
|
|
6065
|
+
|
|
6066
|
+
// remove the popper if user explicity asked for the deletion on destroy
|
|
6067
|
+
if (this._options.removeOnDestroy) {
|
|
6068
|
+
this._popper.remove();
|
|
6069
|
+
}
|
|
6070
|
+
return this;
|
|
6071
|
+
};
|
|
6072
|
+
|
|
6082
6073
|
/**
|
|
6083
6074
|
* Updates the position of the popper, computing the new offsets and applying the new style
|
|
6084
6075
|
* @method
|
|
6085
6076
|
* @memberof Popper
|
|
6086
|
-
*/
|
|
6087
|
-
Popper.prototype.update = function () {
|
|
6088
|
-
var data = { instance: this, styles: {} };
|
|
6089
|
-
|
|
6090
|
-
// store placement inside the data object, modifiers will be able to edit `placement` if needed
|
|
6091
|
-
// and refer to _originalPlacement to know the original value
|
|
6092
|
-
data.placement = this._options.placement;
|
|
6093
|
-
data._originalPlacement = this._options.placement;
|
|
6094
|
-
|
|
6095
|
-
// compute the popper and reference offsets and put them inside data.offsets
|
|
6096
|
-
data.offsets = this._getOffsets(
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
data
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
data = this.runModifiers(data, this._options.modifiers);
|
|
6110
|
-
|
|
6111
|
-
if (typeof this.state.updateCallback === 'function') {
|
|
6112
|
-
this.state.updateCallback(data);
|
|
6113
|
-
}
|
|
6114
|
-
};
|
|
6115
|
-
|
|
6077
|
+
*/
|
|
6078
|
+
Popper.prototype.update = function () {
|
|
6079
|
+
var data = { instance: this, styles: {} };
|
|
6080
|
+
|
|
6081
|
+
// store placement inside the data object, modifiers will be able to edit `placement` if needed
|
|
6082
|
+
// and refer to _originalPlacement to know the original value
|
|
6083
|
+
data.placement = this._options.placement;
|
|
6084
|
+
data._originalPlacement = this._options.placement;
|
|
6085
|
+
|
|
6086
|
+
// compute the popper and reference offsets and put them inside data.offsets
|
|
6087
|
+
data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
|
|
6088
|
+
|
|
6089
|
+
// get boundaries
|
|
6090
|
+
data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
|
|
6091
|
+
|
|
6092
|
+
data = this.runModifiers(data, this._options.modifiers);
|
|
6093
|
+
|
|
6094
|
+
if (typeof this.state.updateCallback === 'function') {
|
|
6095
|
+
this.state.updateCallback(data);
|
|
6096
|
+
}
|
|
6097
|
+
};
|
|
6098
|
+
|
|
6116
6099
|
/**
|
|
6117
6100
|
* If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
|
|
6118
6101
|
* @method
|
|
6119
6102
|
* @memberof Popper
|
|
6120
6103
|
* @param {Function} callback
|
|
6121
|
-
*/
|
|
6122
|
-
Popper.prototype.onCreate = function (callback) {
|
|
6123
|
-
// the createCallbacks return as first argument the popper instance
|
|
6124
|
-
callback(this);
|
|
6125
|
-
return this;
|
|
6126
|
-
};
|
|
6127
|
-
|
|
6104
|
+
*/
|
|
6105
|
+
Popper.prototype.onCreate = function (callback) {
|
|
6106
|
+
// the createCallbacks return as first argument the popper instance
|
|
6107
|
+
callback(this);
|
|
6108
|
+
return this;
|
|
6109
|
+
};
|
|
6110
|
+
|
|
6128
6111
|
/**
|
|
6129
6112
|
* If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
|
|
6130
6113
|
* used to style popper and its arrow.
|
|
@@ -6132,101 +6115,93 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6132
6115
|
* @method
|
|
6133
6116
|
* @memberof Popper
|
|
6134
6117
|
* @param {Function} callback
|
|
6135
|
-
*/
|
|
6136
|
-
Popper.prototype.onUpdate = function (callback) {
|
|
6137
|
-
this.state.updateCallback = callback;
|
|
6138
|
-
return this;
|
|
6139
|
-
};
|
|
6140
|
-
|
|
6118
|
+
*/
|
|
6119
|
+
Popper.prototype.onUpdate = function (callback) {
|
|
6120
|
+
this.state.updateCallback = callback;
|
|
6121
|
+
return this;
|
|
6122
|
+
};
|
|
6123
|
+
|
|
6141
6124
|
/**
|
|
6142
6125
|
* Helper used to generate poppers from a configuration file
|
|
6143
6126
|
* @method
|
|
6144
6127
|
* @memberof Popper
|
|
6145
6128
|
* @param config {Object} configuration
|
|
6146
6129
|
* @returns {HTMLElement} popper
|
|
6147
|
-
*/
|
|
6148
|
-
Popper.prototype.parse = function (config) {
|
|
6149
|
-
var defaultConfig = {
|
|
6150
|
-
tagName: 'div',
|
|
6151
|
-
classNames: ['popper'],
|
|
6152
|
-
attributes: [],
|
|
6153
|
-
parent: root.document.body,
|
|
6154
|
-
content: '',
|
|
6155
|
-
contentType: 'text',
|
|
6156
|
-
arrowTagName: 'div',
|
|
6157
|
-
arrowClassNames: ['popper__arrow'],
|
|
6158
|
-
arrowAttributes: ['x-arrow']
|
|
6159
|
-
};
|
|
6160
|
-
config = Object.assign({}, defaultConfig, config);
|
|
6161
|
-
|
|
6162
|
-
var d = root.document;
|
|
6163
|
-
|
|
6164
|
-
var popper = d.createElement(config.tagName);
|
|
6165
|
-
addClassNames(popper, config.classNames);
|
|
6166
|
-
addAttributes(popper, config.attributes);
|
|
6167
|
-
if (config.contentType === 'node') {
|
|
6168
|
-
popper.appendChild(
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
} else
|
|
6172
|
-
popper.
|
|
6173
|
-
}
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
// if
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
parent = parent[0];
|
|
6202
|
-
}
|
|
6203
|
-
|
|
6204
|
-
// the
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
parent = parent[0];
|
|
6210
|
-
}
|
|
6211
|
-
|
|
6212
|
-
// append the generated popper to its parent
|
|
6213
|
-
parent.appendChild(popper);
|
|
6214
|
-
|
|
6215
|
-
return popper;
|
|
6216
|
-
|
|
6130
|
+
*/
|
|
6131
|
+
Popper.prototype.parse = function (config) {
|
|
6132
|
+
var defaultConfig = {
|
|
6133
|
+
tagName: 'div',
|
|
6134
|
+
classNames: ['popper'],
|
|
6135
|
+
attributes: [],
|
|
6136
|
+
parent: root.document.body,
|
|
6137
|
+
content: '',
|
|
6138
|
+
contentType: 'text',
|
|
6139
|
+
arrowTagName: 'div',
|
|
6140
|
+
arrowClassNames: ['popper__arrow'],
|
|
6141
|
+
arrowAttributes: ['x-arrow']
|
|
6142
|
+
};
|
|
6143
|
+
config = Object.assign({}, defaultConfig, config);
|
|
6144
|
+
|
|
6145
|
+
var d = root.document;
|
|
6146
|
+
|
|
6147
|
+
var popper = d.createElement(config.tagName);
|
|
6148
|
+
addClassNames(popper, config.classNames);
|
|
6149
|
+
addAttributes(popper, config.attributes);
|
|
6150
|
+
if (config.contentType === 'node') {
|
|
6151
|
+
popper.appendChild(config.content.jquery ? config.content[0] : config.content);
|
|
6152
|
+
} else if (config.contentType === 'html') {
|
|
6153
|
+
popper.innerHTML = config.content;
|
|
6154
|
+
} else {
|
|
6155
|
+
popper.textContent = config.content;
|
|
6156
|
+
}
|
|
6157
|
+
|
|
6158
|
+
if (config.arrowTagName) {
|
|
6159
|
+
var arrow = d.createElement(config.arrowTagName);
|
|
6160
|
+
addClassNames(arrow, config.arrowClassNames);
|
|
6161
|
+
addAttributes(arrow, config.arrowAttributes);
|
|
6162
|
+
popper.appendChild(arrow);
|
|
6163
|
+
}
|
|
6164
|
+
|
|
6165
|
+
var parent = config.parent.jquery ? config.parent[0] : config.parent;
|
|
6166
|
+
|
|
6167
|
+
// if the given parent is a string, use it to match an element
|
|
6168
|
+
// if more than one element is matched, the first one will be used as parent
|
|
6169
|
+
// if no elements are matched, the script will throw an error
|
|
6170
|
+
if (typeof parent === 'string') {
|
|
6171
|
+
parent = d.querySelectorAll(config.parent);
|
|
6172
|
+
if (parent.length > 1) {
|
|
6173
|
+
console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
|
|
6174
|
+
}
|
|
6175
|
+
if (parent.length === 0) {
|
|
6176
|
+
throw "ERROR: the given `parent` doesn't exists!";
|
|
6177
|
+
}
|
|
6178
|
+
parent = parent[0];
|
|
6179
|
+
}
|
|
6180
|
+
// if the given parent is a DOM nodes list or an array of nodes with more than one element,
|
|
6181
|
+
// the first one will be used as parent
|
|
6182
|
+
if (parent.length > 1 && parent instanceof Element === false) {
|
|
6183
|
+
console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
|
|
6184
|
+
parent = parent[0];
|
|
6185
|
+
}
|
|
6186
|
+
|
|
6187
|
+
// append the generated popper to its parent
|
|
6188
|
+
parent.appendChild(popper);
|
|
6189
|
+
|
|
6190
|
+
return popper;
|
|
6191
|
+
|
|
6217
6192
|
/**
|
|
6218
6193
|
* Adds class names to the given element
|
|
6219
6194
|
* @function
|
|
6220
6195
|
* @ignore
|
|
6221
6196
|
* @param {HTMLElement} target
|
|
6222
6197
|
* @param {Array} classes
|
|
6223
|
-
*/
|
|
6224
|
-
function addClassNames(element, classNames) {
|
|
6225
|
-
classNames.forEach(function (className) {
|
|
6226
|
-
element.classList.add(className);
|
|
6227
|
-
});
|
|
6228
|
-
}
|
|
6229
|
-
|
|
6198
|
+
*/
|
|
6199
|
+
function addClassNames(element, classNames) {
|
|
6200
|
+
classNames.forEach(function (className) {
|
|
6201
|
+
element.classList.add(className);
|
|
6202
|
+
});
|
|
6203
|
+
}
|
|
6204
|
+
|
|
6230
6205
|
/**
|
|
6231
6206
|
* Adds attributes to the given element
|
|
6232
6207
|
* @function
|
|
@@ -6235,17 +6210,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6235
6210
|
* @param {Array} attributes
|
|
6236
6211
|
* @example
|
|
6237
6212
|
* addAttributes(element, [ 'data-info:foobar' ]);
|
|
6238
|
-
*/
|
|
6239
|
-
function addAttributes(element, attributes) {
|
|
6240
|
-
attributes.forEach(function (attribute) {
|
|
6241
|
-
element.setAttribute(
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
}
|
|
6247
|
-
};
|
|
6248
|
-
|
|
6213
|
+
*/
|
|
6214
|
+
function addAttributes(element, attributes) {
|
|
6215
|
+
attributes.forEach(function (attribute) {
|
|
6216
|
+
element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
|
|
6217
|
+
});
|
|
6218
|
+
}
|
|
6219
|
+
};
|
|
6220
|
+
|
|
6249
6221
|
/**
|
|
6250
6222
|
* Helper used to get the position which will be applied to the popper
|
|
6251
6223
|
* @method
|
|
@@ -6253,20 +6225,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6253
6225
|
* @param config {HTMLElement} popper element
|
|
6254
6226
|
* @param reference {HTMLElement} reference element
|
|
6255
6227
|
* @returns {String} position
|
|
6256
|
-
*/
|
|
6257
|
-
Popper.prototype._getPosition = function (popper, reference) {
|
|
6258
|
-
var container = getOffsetParent(reference);
|
|
6259
|
-
|
|
6260
|
-
if (this._options.forceAbsolute) {
|
|
6261
|
-
return 'absolute';
|
|
6262
|
-
}
|
|
6263
|
-
|
|
6264
|
-
// Decide if the popper will be fixed
|
|
6265
|
-
// If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
|
|
6266
|
-
var isParentFixed = isFixed(reference, container);
|
|
6267
|
-
return isParentFixed ? 'fixed' : 'absolute';
|
|
6268
|
-
};
|
|
6269
|
-
|
|
6228
|
+
*/
|
|
6229
|
+
Popper.prototype._getPosition = function (popper, reference) {
|
|
6230
|
+
var container = getOffsetParent(reference);
|
|
6231
|
+
|
|
6232
|
+
if (this._options.forceAbsolute) {
|
|
6233
|
+
return 'absolute';
|
|
6234
|
+
}
|
|
6235
|
+
|
|
6236
|
+
// Decide if the popper will be fixed
|
|
6237
|
+
// If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
|
|
6238
|
+
var isParentFixed = isFixed(reference, container);
|
|
6239
|
+
return isParentFixed ? 'fixed' : 'absolute';
|
|
6240
|
+
};
|
|
6241
|
+
|
|
6270
6242
|
/**
|
|
6271
6243
|
* Get offsets to the popper
|
|
6272
6244
|
* @method
|
|
@@ -6275,110 +6247,91 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6275
6247
|
* @param {Element} popper - the popper element
|
|
6276
6248
|
* @param {Element} reference - the reference element (the popper will be relative to this)
|
|
6277
6249
|
* @returns {Object} An object containing the offsets which will be applied to the popper
|
|
6278
|
-
*/
|
|
6279
|
-
Popper.prototype._getOffsets = function (popper, reference, placement) {
|
|
6280
|
-
placement = placement.split('-')[0];
|
|
6281
|
-
var popperOffsets = {};
|
|
6282
|
-
|
|
6283
|
-
popperOffsets.position = this.state.position;
|
|
6284
|
-
var isParentFixed = popperOffsets.position === 'fixed';
|
|
6285
|
-
|
|
6286
|
-
//
|
|
6287
|
-
// Get reference element position
|
|
6288
|
-
//
|
|
6289
|
-
var referenceOffsets = getOffsetRectRelativeToCustomParent(
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
//
|
|
6297
|
-
//
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
//
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
if (placement === '
|
|
6311
|
-
popperOffsets.
|
|
6312
|
-
} else {
|
|
6313
|
-
popperOffsets.
|
|
6314
|
-
}
|
|
6315
|
-
}
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
// Add width and height to our offsets object
|
|
6328
|
-
popperOffsets.width = popperRect.width;
|
|
6329
|
-
popperOffsets.height = popperRect.height;
|
|
6330
|
-
|
|
6331
|
-
return {
|
|
6332
|
-
popper: popperOffsets,
|
|
6333
|
-
reference: referenceOffsets
|
|
6334
|
-
};
|
|
6335
|
-
};
|
|
6336
|
-
|
|
6250
|
+
*/
|
|
6251
|
+
Popper.prototype._getOffsets = function (popper, reference, placement) {
|
|
6252
|
+
placement = placement.split('-')[0];
|
|
6253
|
+
var popperOffsets = {};
|
|
6254
|
+
|
|
6255
|
+
popperOffsets.position = this.state.position;
|
|
6256
|
+
var isParentFixed = popperOffsets.position === 'fixed';
|
|
6257
|
+
|
|
6258
|
+
//
|
|
6259
|
+
// Get reference element position
|
|
6260
|
+
//
|
|
6261
|
+
var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, popper, isParentFixed);
|
|
6262
|
+
|
|
6263
|
+
//
|
|
6264
|
+
// Get popper sizes
|
|
6265
|
+
//
|
|
6266
|
+
var popperRect = getOuterSizes(popper);
|
|
6267
|
+
|
|
6268
|
+
//
|
|
6269
|
+
// Compute offsets of popper
|
|
6270
|
+
//
|
|
6271
|
+
|
|
6272
|
+
// depending by the popper placement we have to compute its offsets slightly differently
|
|
6273
|
+
if (['right', 'left'].indexOf(placement) !== -1) {
|
|
6274
|
+
popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
|
|
6275
|
+
if (placement === 'left') {
|
|
6276
|
+
popperOffsets.left = referenceOffsets.left - popperRect.width;
|
|
6277
|
+
} else {
|
|
6278
|
+
popperOffsets.left = referenceOffsets.right;
|
|
6279
|
+
}
|
|
6280
|
+
} else {
|
|
6281
|
+
popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
|
|
6282
|
+
if (placement === 'top') {
|
|
6283
|
+
popperOffsets.top = referenceOffsets.top - popperRect.height;
|
|
6284
|
+
} else {
|
|
6285
|
+
popperOffsets.top = referenceOffsets.bottom;
|
|
6286
|
+
}
|
|
6287
|
+
}
|
|
6288
|
+
|
|
6289
|
+
// Add width and height to our offsets object
|
|
6290
|
+
popperOffsets.width = popperRect.width;
|
|
6291
|
+
popperOffsets.height = popperRect.height;
|
|
6292
|
+
|
|
6293
|
+
return {
|
|
6294
|
+
popper: popperOffsets,
|
|
6295
|
+
reference: referenceOffsets
|
|
6296
|
+
};
|
|
6297
|
+
};
|
|
6298
|
+
|
|
6337
6299
|
/**
|
|
6338
6300
|
* Setup needed event listeners used to update the popper position
|
|
6339
6301
|
* @method
|
|
6340
6302
|
* @memberof Popper
|
|
6341
6303
|
* @access private
|
|
6342
|
-
*/
|
|
6343
|
-
Popper.prototype._setupEventListeners = function () {
|
|
6344
|
-
// NOTE: 1 DOM access here
|
|
6345
|
-
this.state.updateBound = this.update.bind(this);
|
|
6346
|
-
// 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
|
|
6347
|
-
this.state.realWindow = getRealWindow(this._popper);
|
|
6348
|
-
this.state.realWindow.addEventListener('resize', this.state.updateBound);
|
|
6349
|
-
// if the boundariesElement is window we don't need to listen for the scroll event
|
|
6350
|
-
if (this._options.boundariesElement !== 'window') {
|
|
6351
|
-
var target = getScrollParent(this._reference);
|
|
6352
|
-
target.addEventListener('scroll', this.state.updateBound);
|
|
6353
|
-
this.state.scrollTarget = target;
|
|
6354
|
-
}
|
|
6355
|
-
};
|
|
6356
|
-
|
|
6304
|
+
*/
|
|
6305
|
+
Popper.prototype._setupEventListeners = function () {
|
|
6306
|
+
// NOTE: 1 DOM access here
|
|
6307
|
+
this.state.updateBound = this.update.bind(this);
|
|
6308
|
+
// 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
|
|
6309
|
+
this.state.realWindow = getRealWindow(this._popper);
|
|
6310
|
+
this.state.realWindow.addEventListener('resize', this.state.updateBound);
|
|
6311
|
+
// if the boundariesElement is window we don't need to listen for the scroll event
|
|
6312
|
+
if (this._options.boundariesElement !== 'window') {
|
|
6313
|
+
var target = getScrollParent(this._reference);
|
|
6314
|
+
target.addEventListener('scroll', this.state.updateBound);
|
|
6315
|
+
this.state.scrollTarget = target;
|
|
6316
|
+
}
|
|
6317
|
+
};
|
|
6318
|
+
|
|
6357
6319
|
/**
|
|
6358
6320
|
* Remove event listeners used to update the popper position
|
|
6359
6321
|
* @method
|
|
6360
6322
|
* @memberof Popper
|
|
6361
6323
|
* @access private
|
|
6362
|
-
*/
|
|
6363
|
-
Popper.prototype._removeEventListeners = function () {
|
|
6364
|
-
// NOTE: 1 DOM access here
|
|
6365
|
-
(this.state.realWindow || root).removeEventListener(
|
|
6366
|
-
|
|
6367
|
-
this.state.updateBound
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
this.state.scrollTarget.removeEventListener(
|
|
6374
|
-
'scroll',
|
|
6375
|
-
this.state.updateBound
|
|
6376
|
-
);
|
|
6377
|
-
this.state.scrollTarget = null;
|
|
6378
|
-
}
|
|
6379
|
-
this.state.updateBound = null;
|
|
6380
|
-
};
|
|
6381
|
-
|
|
6324
|
+
*/
|
|
6325
|
+
Popper.prototype._removeEventListeners = function () {
|
|
6326
|
+
// NOTE: 1 DOM access here
|
|
6327
|
+
(this.state.realWindow || root).removeEventListener('resize', this.state.updateBound);
|
|
6328
|
+
if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
|
|
6329
|
+
this.state.scrollTarget.removeEventListener('scroll', this.state.updateBound);
|
|
6330
|
+
this.state.scrollTarget = null;
|
|
6331
|
+
}
|
|
6332
|
+
this.state.updateBound = null;
|
|
6333
|
+
};
|
|
6334
|
+
|
|
6382
6335
|
/**
|
|
6383
6336
|
* Computed the boundaries limits and return them
|
|
6384
6337
|
* @method
|
|
@@ -6388,75 +6341,56 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6388
6341
|
* @param {Number} padding - Boundaries padding
|
|
6389
6342
|
* @param {Element} boundariesElement - Element used to define the boundaries
|
|
6390
6343
|
* @returns {Object} Coordinates of the boundaries
|
|
6391
|
-
*/
|
|
6392
|
-
Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
|
|
6393
|
-
// NOTE: 1 DOM access here
|
|
6394
|
-
var boundaries = {};
|
|
6395
|
-
var width, height;
|
|
6396
|
-
if (boundariesElement === 'window') {
|
|
6397
|
-
var body = root.document.body,
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
height = Math.max(
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
);
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
} else {
|
|
6442
|
-
if (getOffsetParent(this._popper) === boundariesElement) {
|
|
6443
|
-
boundaries = {
|
|
6444
|
-
top: 0,
|
|
6445
|
-
left: 0,
|
|
6446
|
-
right: boundariesElement.clientWidth,
|
|
6447
|
-
bottom: boundariesElement.clientHeight
|
|
6448
|
-
};
|
|
6449
|
-
} else {
|
|
6450
|
-
boundaries = getOffsetRect(boundariesElement);
|
|
6451
|
-
}
|
|
6452
|
-
}
|
|
6453
|
-
boundaries.left += padding;
|
|
6454
|
-
boundaries.right -= padding;
|
|
6455
|
-
boundaries.top = boundaries.top + padding;
|
|
6456
|
-
boundaries.bottom = boundaries.bottom - padding;
|
|
6457
|
-
return boundaries;
|
|
6458
|
-
};
|
|
6459
|
-
|
|
6344
|
+
*/
|
|
6345
|
+
Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
|
|
6346
|
+
// NOTE: 1 DOM access here
|
|
6347
|
+
var boundaries = {};
|
|
6348
|
+
var width, height;
|
|
6349
|
+
if (boundariesElement === 'window') {
|
|
6350
|
+
var body = root.document.body,
|
|
6351
|
+
html = root.document.documentElement;
|
|
6352
|
+
|
|
6353
|
+
height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
6354
|
+
width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
|
|
6355
|
+
|
|
6356
|
+
boundaries = {
|
|
6357
|
+
top: 0,
|
|
6358
|
+
right: width,
|
|
6359
|
+
bottom: height,
|
|
6360
|
+
left: 0
|
|
6361
|
+
};
|
|
6362
|
+
} else if (boundariesElement === 'viewport') {
|
|
6363
|
+
// 将真实 window 的视口换算到 popper 所在包含块的坐标系。
|
|
6364
|
+
// 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
|
|
6365
|
+
// 统一从元素自身的 view 与真实包含块获取
|
|
6366
|
+
var realWindow = getRealWindow(this._popper);
|
|
6367
|
+
var containingBlockRect = getContainingBlockRect(this._popper, data.offsets.popper.position === 'fixed');
|
|
6368
|
+
|
|
6369
|
+
boundaries = {
|
|
6370
|
+
top: 0 - containingBlockRect.top,
|
|
6371
|
+
right: realWindow.document.documentElement.clientWidth - containingBlockRect.left,
|
|
6372
|
+
bottom: realWindow.document.documentElement.clientHeight - containingBlockRect.top,
|
|
6373
|
+
left: 0 - containingBlockRect.left
|
|
6374
|
+
};
|
|
6375
|
+
} else {
|
|
6376
|
+
if (getOffsetParent(this._popper) === boundariesElement) {
|
|
6377
|
+
boundaries = {
|
|
6378
|
+
top: 0,
|
|
6379
|
+
left: 0,
|
|
6380
|
+
right: boundariesElement.clientWidth,
|
|
6381
|
+
bottom: boundariesElement.clientHeight
|
|
6382
|
+
};
|
|
6383
|
+
} else {
|
|
6384
|
+
boundaries = getOffsetRect(boundariesElement);
|
|
6385
|
+
}
|
|
6386
|
+
}
|
|
6387
|
+
boundaries.left += padding;
|
|
6388
|
+
boundaries.right -= padding;
|
|
6389
|
+
boundaries.top = boundaries.top + padding;
|
|
6390
|
+
boundaries.bottom = boundaries.bottom - padding;
|
|
6391
|
+
return boundaries;
|
|
6392
|
+
};
|
|
6393
|
+
|
|
6460
6394
|
/**
|
|
6461
6395
|
* Loop trough the list of modifiers and run them in order, each of them will then edit the data object
|
|
6462
6396
|
* @method
|
|
@@ -6465,27 +6399,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6465
6399
|
* @param {Object} data
|
|
6466
6400
|
* @param {Array} modifiers
|
|
6467
6401
|
* @param {Function} ends
|
|
6468
|
-
*/
|
|
6469
|
-
Popper.prototype.runModifiers = function (data, modifiers, ends) {
|
|
6470
|
-
var modifiersToRun = modifiers.slice();
|
|
6471
|
-
if (ends !== undefined) {
|
|
6472
|
-
modifiersToRun = this._options.modifiers.slice(
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
);
|
|
6485
|
-
|
|
6486
|
-
return data;
|
|
6487
|
-
};
|
|
6488
|
-
|
|
6402
|
+
*/
|
|
6403
|
+
Popper.prototype.runModifiers = function (data, modifiers, ends) {
|
|
6404
|
+
var modifiersToRun = modifiers.slice();
|
|
6405
|
+
if (ends !== undefined) {
|
|
6406
|
+
modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
|
|
6407
|
+
}
|
|
6408
|
+
|
|
6409
|
+
modifiersToRun.forEach(function (modifier) {
|
|
6410
|
+
if (isFunction(modifier)) {
|
|
6411
|
+
data = modifier.call(this, data);
|
|
6412
|
+
}
|
|
6413
|
+
}.bind(this));
|
|
6414
|
+
|
|
6415
|
+
return data;
|
|
6416
|
+
};
|
|
6417
|
+
|
|
6489
6418
|
/**
|
|
6490
6419
|
* Helper used to know if the given modifier depends from another one.
|
|
6491
6420
|
* @method
|
|
@@ -6493,204 +6422,191 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6493
6422
|
* @param {String} requesting - name of requesting modifier
|
|
6494
6423
|
* @param {String} requested - name of requested modifier
|
|
6495
6424
|
* @returns {Boolean}
|
|
6496
|
-
*/
|
|
6497
|
-
Popper.prototype.isModifierRequired = function (requesting, requested) {
|
|
6498
|
-
var index = getArrayKeyIndex(this._options.modifiers, requesting);
|
|
6499
|
-
return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
|
|
6500
|
-
return modifier === requested;
|
|
6501
|
-
}).length;
|
|
6502
|
-
};
|
|
6503
|
-
|
|
6504
|
-
//
|
|
6505
|
-
// Modifiers
|
|
6506
|
-
//
|
|
6507
|
-
|
|
6425
|
+
*/
|
|
6426
|
+
Popper.prototype.isModifierRequired = function (requesting, requested) {
|
|
6427
|
+
var index = getArrayKeyIndex(this._options.modifiers, requesting);
|
|
6428
|
+
return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
|
|
6429
|
+
return modifier === requested;
|
|
6430
|
+
}).length;
|
|
6431
|
+
};
|
|
6432
|
+
|
|
6433
|
+
//
|
|
6434
|
+
// Modifiers
|
|
6435
|
+
//
|
|
6436
|
+
|
|
6508
6437
|
/**
|
|
6509
6438
|
* Modifiers list
|
|
6510
6439
|
* @namespace Popper.modifiers
|
|
6511
6440
|
* @memberof Popper
|
|
6512
6441
|
* @type {Object}
|
|
6513
|
-
*/
|
|
6514
|
-
Popper.prototype.modifiers = {};
|
|
6515
|
-
|
|
6442
|
+
*/
|
|
6443
|
+
Popper.prototype.modifiers = {};
|
|
6444
|
+
|
|
6516
6445
|
/**
|
|
6517
6446
|
* Apply the computed styles to the popper element
|
|
6518
6447
|
* @method
|
|
6519
6448
|
* @memberof Popper.modifiers
|
|
6520
6449
|
* @argument {Object} data - The data object generated by `update` method
|
|
6521
6450
|
* @returns {Object} The same data object
|
|
6522
|
-
*/
|
|
6523
|
-
Popper.prototype.modifiers.applyStyle = function (data) {
|
|
6524
|
-
// apply the final offsets to the popper
|
|
6525
|
-
// NOTE: 1 DOM access here
|
|
6526
|
-
var styles = {
|
|
6527
|
-
position: data.offsets.popper.position
|
|
6528
|
-
};
|
|
6529
|
-
|
|
6530
|
-
// round top and left to avoid blurry text
|
|
6531
|
-
var left = Math.round(data.offsets.popper.left);
|
|
6532
|
-
var top = Math.round(data.offsets.popper.top);
|
|
6533
|
-
|
|
6534
|
-
// if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
|
|
6535
|
-
// we automatically use the supported prefixed version if needed
|
|
6536
|
-
var prefixedProperty;
|
|
6537
|
-
if (
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
//
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
this.modifiers.arrow
|
|
6569
|
-
) &&
|
|
6570
|
-
data.offsets.arrow
|
|
6571
|
-
) {
|
|
6572
|
-
setStyle(data.arrowElement, data.offsets.arrow);
|
|
6573
|
-
}
|
|
6574
|
-
|
|
6575
|
-
return data;
|
|
6576
|
-
};
|
|
6577
|
-
|
|
6451
|
+
*/
|
|
6452
|
+
Popper.prototype.modifiers.applyStyle = function (data) {
|
|
6453
|
+
// apply the final offsets to the popper
|
|
6454
|
+
// NOTE: 1 DOM access here
|
|
6455
|
+
var styles = {
|
|
6456
|
+
position: data.offsets.popper.position
|
|
6457
|
+
};
|
|
6458
|
+
|
|
6459
|
+
// round top and left to avoid blurry text
|
|
6460
|
+
var left = Math.round(data.offsets.popper.left);
|
|
6461
|
+
var top = Math.round(data.offsets.popper.top);
|
|
6462
|
+
|
|
6463
|
+
// if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
|
|
6464
|
+
// we automatically use the supported prefixed version if needed
|
|
6465
|
+
var prefixedProperty;
|
|
6466
|
+
if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
|
|
6467
|
+
styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
|
|
6468
|
+
styles.top = 0;
|
|
6469
|
+
styles.left = 0;
|
|
6470
|
+
}
|
|
6471
|
+
// othwerise, we use the standard `left` and `top` properties
|
|
6472
|
+
else {
|
|
6473
|
+
styles.left = left;
|
|
6474
|
+
styles.top = top;
|
|
6475
|
+
}
|
|
6476
|
+
|
|
6477
|
+
// any property present in `data.styles` will be applied to the popper,
|
|
6478
|
+
// in this way we can make the 3rd party modifiers add custom styles to it
|
|
6479
|
+
// Be aware, modifiers could override the properties defined in the previous
|
|
6480
|
+
// lines of this modifier!
|
|
6481
|
+
Object.assign(styles, data.styles);
|
|
6482
|
+
|
|
6483
|
+
setStyle(this._popper, styles);
|
|
6484
|
+
|
|
6485
|
+
// set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
|
|
6486
|
+
// NOTE: 1 DOM access here
|
|
6487
|
+
this._popper.setAttribute('x-placement', data.placement);
|
|
6488
|
+
|
|
6489
|
+
// if the arrow modifier is required and the arrow style has been computed, apply the arrow style
|
|
6490
|
+
if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
|
|
6491
|
+
setStyle(data.arrowElement, data.offsets.arrow);
|
|
6492
|
+
}
|
|
6493
|
+
|
|
6494
|
+
return data;
|
|
6495
|
+
};
|
|
6496
|
+
|
|
6578
6497
|
/**
|
|
6579
6498
|
* Modifier used to shift the popper on the start or end of its reference element side
|
|
6580
6499
|
* @method
|
|
6581
6500
|
* @memberof Popper.modifiers
|
|
6582
6501
|
* @argument {Object} data - The data object generated by `update` method
|
|
6583
6502
|
* @returns {Object} The data object, properly modified
|
|
6584
|
-
*/
|
|
6585
|
-
Popper.prototype.modifiers.shift = function (data) {
|
|
6586
|
-
var placement = data.placement;
|
|
6587
|
-
var basePlacement = placement.split('-')[0];
|
|
6588
|
-
var shiftVariation = placement.split('-')[1];
|
|
6589
|
-
|
|
6590
|
-
// if shift shiftVariation is specified, run the modifier
|
|
6591
|
-
if (shiftVariation) {
|
|
6592
|
-
var reference = data.offsets.reference;
|
|
6593
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
6594
|
-
|
|
6595
|
-
var shiftOffsets = {
|
|
6596
|
-
y: {
|
|
6597
|
-
start: { top: reference.top },
|
|
6598
|
-
end: { top: reference.top + reference.height - popper.height }
|
|
6599
|
-
},
|
|
6600
|
-
x: {
|
|
6601
|
-
start: { left: reference.left },
|
|
6602
|
-
end: { left: reference.left + reference.width - popper.width }
|
|
6603
|
-
}
|
|
6604
|
-
};
|
|
6605
|
-
|
|
6606
|
-
var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
|
|
6607
|
-
|
|
6608
|
-
data.offsets.popper = Object.assign(
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
return data;
|
|
6615
|
-
};
|
|
6616
|
-
|
|
6503
|
+
*/
|
|
6504
|
+
Popper.prototype.modifiers.shift = function (data) {
|
|
6505
|
+
var placement = data.placement;
|
|
6506
|
+
var basePlacement = placement.split('-')[0];
|
|
6507
|
+
var shiftVariation = placement.split('-')[1];
|
|
6508
|
+
|
|
6509
|
+
// if shift shiftVariation is specified, run the modifier
|
|
6510
|
+
if (shiftVariation) {
|
|
6511
|
+
var reference = data.offsets.reference;
|
|
6512
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6513
|
+
|
|
6514
|
+
var shiftOffsets = {
|
|
6515
|
+
y: {
|
|
6516
|
+
start: { top: reference.top },
|
|
6517
|
+
end: { top: reference.top + reference.height - popper.height }
|
|
6518
|
+
},
|
|
6519
|
+
x: {
|
|
6520
|
+
start: { left: reference.left },
|
|
6521
|
+
end: { left: reference.left + reference.width - popper.width }
|
|
6522
|
+
}
|
|
6523
|
+
};
|
|
6524
|
+
|
|
6525
|
+
var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
|
|
6526
|
+
|
|
6527
|
+
data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
|
|
6528
|
+
}
|
|
6529
|
+
|
|
6530
|
+
return data;
|
|
6531
|
+
};
|
|
6532
|
+
|
|
6617
6533
|
/**
|
|
6618
6534
|
* Modifier used to make sure the popper does not overflows from it's boundaries
|
|
6619
6535
|
* @method
|
|
6620
6536
|
* @memberof Popper.modifiers
|
|
6621
6537
|
* @argument {Object} data - The data object generated by `update` method
|
|
6622
6538
|
* @returns {Object} The data object, properly modified
|
|
6623
|
-
*/
|
|
6624
|
-
Popper.prototype.modifiers.preventOverflow = function (data) {
|
|
6625
|
-
var order = this._options.preventOverflowOrder;
|
|
6626
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
6627
|
-
|
|
6628
|
-
var check = {
|
|
6629
|
-
left: function () {
|
|
6630
|
-
var left = popper.left;
|
|
6631
|
-
if (popper.left < data.boundaries.left) {
|
|
6632
|
-
left = Math.max(popper.left, data.boundaries.left);
|
|
6633
|
-
}
|
|
6634
|
-
return { left: left };
|
|
6635
|
-
},
|
|
6636
|
-
right: function () {
|
|
6637
|
-
var left = popper.left;
|
|
6638
|
-
if (popper.right > data.boundaries.right) {
|
|
6639
|
-
left = Math.min(popper.left, data.boundaries.right - popper.width);
|
|
6640
|
-
}
|
|
6641
|
-
return { left: left };
|
|
6642
|
-
},
|
|
6643
|
-
top: function () {
|
|
6644
|
-
var top = popper.top;
|
|
6645
|
-
if (popper.top < data.boundaries.top) {
|
|
6646
|
-
top = Math.max(popper.top, data.boundaries.top);
|
|
6647
|
-
}
|
|
6648
|
-
return { top: top };
|
|
6649
|
-
},
|
|
6650
|
-
bottom: function () {
|
|
6651
|
-
var top = popper.top;
|
|
6652
|
-
if (popper.bottom > data.boundaries.bottom) {
|
|
6653
|
-
top = Math.min(popper.top, data.boundaries.bottom - popper.height);
|
|
6654
|
-
}
|
|
6655
|
-
return { top: top };
|
|
6656
|
-
}
|
|
6657
|
-
};
|
|
6658
|
-
|
|
6659
|
-
order.forEach(function (direction) {
|
|
6660
|
-
data.offsets.popper = Object.assign(popper, check[direction]());
|
|
6661
|
-
});
|
|
6662
|
-
|
|
6663
|
-
return data;
|
|
6664
|
-
};
|
|
6665
|
-
|
|
6539
|
+
*/
|
|
6540
|
+
Popper.prototype.modifiers.preventOverflow = function (data) {
|
|
6541
|
+
var order = this._options.preventOverflowOrder;
|
|
6542
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6543
|
+
|
|
6544
|
+
var check = {
|
|
6545
|
+
left: function left() {
|
|
6546
|
+
var left = popper.left;
|
|
6547
|
+
if (popper.left < data.boundaries.left) {
|
|
6548
|
+
left = Math.max(popper.left, data.boundaries.left);
|
|
6549
|
+
}
|
|
6550
|
+
return { left: left };
|
|
6551
|
+
},
|
|
6552
|
+
right: function right() {
|
|
6553
|
+
var left = popper.left;
|
|
6554
|
+
if (popper.right > data.boundaries.right) {
|
|
6555
|
+
left = Math.min(popper.left, data.boundaries.right - popper.width);
|
|
6556
|
+
}
|
|
6557
|
+
return { left: left };
|
|
6558
|
+
},
|
|
6559
|
+
top: function top() {
|
|
6560
|
+
var top = popper.top;
|
|
6561
|
+
if (popper.top < data.boundaries.top) {
|
|
6562
|
+
top = Math.max(popper.top, data.boundaries.top);
|
|
6563
|
+
}
|
|
6564
|
+
return { top: top };
|
|
6565
|
+
},
|
|
6566
|
+
bottom: function bottom() {
|
|
6567
|
+
var top = popper.top;
|
|
6568
|
+
if (popper.bottom > data.boundaries.bottom) {
|
|
6569
|
+
top = Math.min(popper.top, data.boundaries.bottom - popper.height);
|
|
6570
|
+
}
|
|
6571
|
+
return { top: top };
|
|
6572
|
+
}
|
|
6573
|
+
};
|
|
6574
|
+
|
|
6575
|
+
order.forEach(function (direction) {
|
|
6576
|
+
data.offsets.popper = Object.assign(popper, check[direction]());
|
|
6577
|
+
});
|
|
6578
|
+
|
|
6579
|
+
return data;
|
|
6580
|
+
};
|
|
6581
|
+
|
|
6666
6582
|
/**
|
|
6667
6583
|
* Modifier used to make sure the popper is always near its reference
|
|
6668
6584
|
* @method
|
|
6669
6585
|
* @memberof Popper.modifiers
|
|
6670
6586
|
* @argument {Object} data - The data object generated by _update method
|
|
6671
6587
|
* @returns {Object} The data object, properly modified
|
|
6672
|
-
*/
|
|
6673
|
-
Popper.prototype.modifiers.keepTogether = function (data) {
|
|
6674
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
6675
|
-
var reference = data.offsets.reference;
|
|
6676
|
-
var f = Math.floor;
|
|
6677
|
-
|
|
6678
|
-
if (popper.right < f(reference.left)) {
|
|
6679
|
-
data.offsets.popper.left = f(reference.left) - popper.width;
|
|
6680
|
-
}
|
|
6681
|
-
if (popper.left > f(reference.right)) {
|
|
6682
|
-
data.offsets.popper.left = f(reference.right);
|
|
6683
|
-
}
|
|
6684
|
-
if (popper.bottom < f(reference.top)) {
|
|
6685
|
-
data.offsets.popper.top = f(reference.top) - popper.height;
|
|
6686
|
-
}
|
|
6687
|
-
if (popper.top > f(reference.bottom)) {
|
|
6688
|
-
data.offsets.popper.top = f(reference.bottom);
|
|
6689
|
-
}
|
|
6690
|
-
|
|
6691
|
-
return data;
|
|
6692
|
-
};
|
|
6693
|
-
|
|
6588
|
+
*/
|
|
6589
|
+
Popper.prototype.modifiers.keepTogether = function (data) {
|
|
6590
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6591
|
+
var reference = data.offsets.reference;
|
|
6592
|
+
var f = Math.floor;
|
|
6593
|
+
|
|
6594
|
+
if (popper.right < f(reference.left)) {
|
|
6595
|
+
data.offsets.popper.left = f(reference.left) - popper.width;
|
|
6596
|
+
}
|
|
6597
|
+
if (popper.left > f(reference.right)) {
|
|
6598
|
+
data.offsets.popper.left = f(reference.right);
|
|
6599
|
+
}
|
|
6600
|
+
if (popper.bottom < f(reference.top)) {
|
|
6601
|
+
data.offsets.popper.top = f(reference.top) - popper.height;
|
|
6602
|
+
}
|
|
6603
|
+
if (popper.top > f(reference.bottom)) {
|
|
6604
|
+
data.offsets.popper.top = f(reference.bottom);
|
|
6605
|
+
}
|
|
6606
|
+
|
|
6607
|
+
return data;
|
|
6608
|
+
};
|
|
6609
|
+
|
|
6694
6610
|
/**
|
|
6695
6611
|
* Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
|
|
6696
6612
|
* Requires the `preventOverflow` modifier before it in order to work.
|
|
@@ -6699,81 +6615,61 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6699
6615
|
* @memberof Popper.modifiers
|
|
6700
6616
|
* @argument {Object} data - The data object generated by _update method
|
|
6701
6617
|
* @returns {Object} The data object, properly modified
|
|
6702
|
-
*/
|
|
6703
|
-
Popper.prototype.modifiers.flip = function (data) {
|
|
6704
|
-
// check if preventOverflow is in the list of modifiers before the flip modifier.
|
|
6705
|
-
// otherwise flip would not work as expected.
|
|
6706
|
-
if (
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
) {
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
) {
|
|
6758
|
-
// we'll use this boolean to detect any flip loop
|
|
6759
|
-
data.flipped = true;
|
|
6760
|
-
data.placement = flipOrder[index + 1];
|
|
6761
|
-
if (variation) {
|
|
6762
|
-
data.placement += '-' + variation;
|
|
6763
|
-
}
|
|
6764
|
-
data.offsets.popper = this._getOffsets(
|
|
6765
|
-
this._popper,
|
|
6766
|
-
this._reference,
|
|
6767
|
-
data.placement
|
|
6768
|
-
).popper;
|
|
6769
|
-
|
|
6770
|
-
data = this.runModifiers(data, this._options.modifiers, this._flip);
|
|
6771
|
-
}
|
|
6772
|
-
}.bind(this)
|
|
6773
|
-
);
|
|
6774
|
-
return data;
|
|
6775
|
-
};
|
|
6776
|
-
|
|
6618
|
+
*/
|
|
6619
|
+
Popper.prototype.modifiers.flip = function (data) {
|
|
6620
|
+
// check if preventOverflow is in the list of modifiers before the flip modifier.
|
|
6621
|
+
// otherwise flip would not work as expected.
|
|
6622
|
+
if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
|
|
6623
|
+
console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
|
|
6624
|
+
return data;
|
|
6625
|
+
}
|
|
6626
|
+
|
|
6627
|
+
if (data.flipped && data.placement === data._originalPlacement) {
|
|
6628
|
+
// seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
|
|
6629
|
+
return data;
|
|
6630
|
+
}
|
|
6631
|
+
|
|
6632
|
+
var placement = data.placement.split('-')[0];
|
|
6633
|
+
var placementOpposite = getOppositePlacement(placement);
|
|
6634
|
+
var variation = data.placement.split('-')[1] || '';
|
|
6635
|
+
|
|
6636
|
+
var flipOrder = [];
|
|
6637
|
+
if (this._options.flipBehavior === 'flip') {
|
|
6638
|
+
flipOrder = [placement, placementOpposite];
|
|
6639
|
+
} else {
|
|
6640
|
+
flipOrder = this._options.flipBehavior;
|
|
6641
|
+
}
|
|
6642
|
+
|
|
6643
|
+
flipOrder.forEach(function (step, index) {
|
|
6644
|
+
if (placement !== step || flipOrder.length === index + 1) {
|
|
6645
|
+
return;
|
|
6646
|
+
}
|
|
6647
|
+
|
|
6648
|
+
placement = data.placement.split('-')[0];
|
|
6649
|
+
placementOpposite = getOppositePlacement(placement);
|
|
6650
|
+
|
|
6651
|
+
var popperOffsets = getPopperClientRect(data.offsets.popper);
|
|
6652
|
+
|
|
6653
|
+
// this boolean is used to distinguish right and bottom from top and left
|
|
6654
|
+
// they need different computations to get flipped
|
|
6655
|
+
var a = ['right', 'bottom'].indexOf(placement) !== -1;
|
|
6656
|
+
|
|
6657
|
+
// using Math.floor because the reference offsets may contain decimals we are not going to consider here
|
|
6658
|
+
if (a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) || !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])) {
|
|
6659
|
+
// we'll use this boolean to detect any flip loop
|
|
6660
|
+
data.flipped = true;
|
|
6661
|
+
data.placement = flipOrder[index + 1];
|
|
6662
|
+
if (variation) {
|
|
6663
|
+
data.placement += '-' + variation;
|
|
6664
|
+
}
|
|
6665
|
+
data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
|
|
6666
|
+
|
|
6667
|
+
data = this.runModifiers(data, this._options.modifiers, this._flip);
|
|
6668
|
+
}
|
|
6669
|
+
}.bind(this));
|
|
6670
|
+
return data;
|
|
6671
|
+
};
|
|
6672
|
+
|
|
6777
6673
|
/**
|
|
6778
6674
|
* Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
|
|
6779
6675
|
* The offsets will shift the popper on the side of its reference element.
|
|
@@ -6781,23 +6677,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6781
6677
|
* @memberof Popper.modifiers
|
|
6782
6678
|
* @argument {Object} data - The data object generated by _update method
|
|
6783
6679
|
* @returns {Object} The data object, properly modified
|
|
6784
|
-
*/
|
|
6785
|
-
Popper.prototype.modifiers.offset = function (data) {
|
|
6786
|
-
var offset = this._options.offset;
|
|
6787
|
-
var popper = data.offsets.popper;
|
|
6788
|
-
|
|
6789
|
-
if (data.placement.indexOf('left') !== -1) {
|
|
6790
|
-
popper.top -= offset;
|
|
6791
|
-
} else if (data.placement.indexOf('right') !== -1) {
|
|
6792
|
-
popper.top += offset;
|
|
6793
|
-
} else if (data.placement.indexOf('top') !== -1) {
|
|
6794
|
-
popper.left -= offset;
|
|
6795
|
-
} else if (data.placement.indexOf('bottom') !== -1) {
|
|
6796
|
-
popper.left += offset;
|
|
6797
|
-
}
|
|
6798
|
-
return data;
|
|
6799
|
-
};
|
|
6800
|
-
|
|
6680
|
+
*/
|
|
6681
|
+
Popper.prototype.modifiers.offset = function (data) {
|
|
6682
|
+
var offset = this._options.offset;
|
|
6683
|
+
var popper = data.offsets.popper;
|
|
6684
|
+
|
|
6685
|
+
if (data.placement.indexOf('left') !== -1) {
|
|
6686
|
+
popper.top -= offset;
|
|
6687
|
+
} else if (data.placement.indexOf('right') !== -1) {
|
|
6688
|
+
popper.top += offset;
|
|
6689
|
+
} else if (data.placement.indexOf('top') !== -1) {
|
|
6690
|
+
popper.left -= offset;
|
|
6691
|
+
} else if (data.placement.indexOf('bottom') !== -1) {
|
|
6692
|
+
popper.left += offset;
|
|
6693
|
+
}
|
|
6694
|
+
return data;
|
|
6695
|
+
};
|
|
6696
|
+
|
|
6801
6697
|
/**
|
|
6802
6698
|
* 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
|
|
6803
6699
|
* It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
|
|
@@ -6805,147 +6701,136 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6805
6701
|
* @memberof Popper.modifiers
|
|
6806
6702
|
* @argument {Object} data - The data object generated by _update method
|
|
6807
6703
|
* @returns {Object} The data object, properly modified
|
|
6808
|
-
*/
|
|
6809
|
-
Popper.prototype.modifiers.arrow = function (data) {
|
|
6810
|
-
var arrow = this._options.arrowElement;
|
|
6811
|
-
var arrowOffset = this._options.arrowOffset;
|
|
6812
|
-
|
|
6813
|
-
// if the arrowElement is a string, suppose it's a CSS selector
|
|
6814
|
-
if (typeof arrow === 'string') {
|
|
6815
|
-
arrow = this._popper.querySelector(arrow);
|
|
6816
|
-
}
|
|
6817
|
-
|
|
6818
|
-
// if arrow element is not found, don't run the modifier
|
|
6819
|
-
if (!arrow) {
|
|
6820
|
-
return data;
|
|
6821
|
-
}
|
|
6822
|
-
|
|
6823
|
-
// the arrow element must be child of its popper
|
|
6824
|
-
if (!this._popper.contains(arrow)) {
|
|
6825
|
-
console.warn(
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
)
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
var
|
|
6845
|
-
var
|
|
6846
|
-
var
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
//
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
//
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
data.offsets.arrow = arrowStyle;
|
|
6883
|
-
data.arrowElement = arrow;
|
|
6884
|
-
|
|
6885
|
-
return data;
|
|
6886
|
-
};
|
|
6887
|
-
|
|
6888
|
-
//
|
|
6889
|
-
// Helpers
|
|
6890
|
-
//
|
|
6891
|
-
|
|
6704
|
+
*/
|
|
6705
|
+
Popper.prototype.modifiers.arrow = function (data) {
|
|
6706
|
+
var arrow = this._options.arrowElement;
|
|
6707
|
+
var arrowOffset = this._options.arrowOffset;
|
|
6708
|
+
|
|
6709
|
+
// if the arrowElement is a string, suppose it's a CSS selector
|
|
6710
|
+
if (typeof arrow === 'string') {
|
|
6711
|
+
arrow = this._popper.querySelector(arrow);
|
|
6712
|
+
}
|
|
6713
|
+
|
|
6714
|
+
// if arrow element is not found, don't run the modifier
|
|
6715
|
+
if (!arrow) {
|
|
6716
|
+
return data;
|
|
6717
|
+
}
|
|
6718
|
+
|
|
6719
|
+
// the arrow element must be child of its popper
|
|
6720
|
+
if (!this._popper.contains(arrow)) {
|
|
6721
|
+
console.warn('WARNING: `arrowElement` must be child of its popper element!');
|
|
6722
|
+
return data;
|
|
6723
|
+
}
|
|
6724
|
+
|
|
6725
|
+
// arrow depends on keepTogether in order to work
|
|
6726
|
+
if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
|
|
6727
|
+
console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
|
|
6728
|
+
return data;
|
|
6729
|
+
}
|
|
6730
|
+
|
|
6731
|
+
var arrowStyle = {};
|
|
6732
|
+
var placement = data.placement.split('-')[0];
|
|
6733
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6734
|
+
var reference = data.offsets.reference;
|
|
6735
|
+
var isVertical = ['left', 'right'].indexOf(placement) !== -1;
|
|
6736
|
+
|
|
6737
|
+
var len = isVertical ? 'height' : 'width';
|
|
6738
|
+
var side = isVertical ? 'top' : 'left';
|
|
6739
|
+
var translate = isVertical ? 'translateY' : 'translateX';
|
|
6740
|
+
var altSide = isVertical ? 'left' : 'top';
|
|
6741
|
+
var opSide = isVertical ? 'bottom' : 'right';
|
|
6742
|
+
var arrowSize = getOuterSizes(arrow)[len];
|
|
6743
|
+
|
|
6744
|
+
//
|
|
6745
|
+
// extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
|
|
6746
|
+
//
|
|
6747
|
+
|
|
6748
|
+
// top/left side
|
|
6749
|
+
if (reference[opSide] - arrowSize < popper[side]) {
|
|
6750
|
+
data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
|
|
6751
|
+
}
|
|
6752
|
+
// bottom/right side
|
|
6753
|
+
if (reference[side] + arrowSize > popper[opSide]) {
|
|
6754
|
+
data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
|
|
6755
|
+
}
|
|
6756
|
+
|
|
6757
|
+
// compute center of the popper
|
|
6758
|
+
var center = reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
|
|
6759
|
+
|
|
6760
|
+
var sideValue = center - popper[side];
|
|
6761
|
+
|
|
6762
|
+
// prevent arrow from being placed not contiguously to its popper
|
|
6763
|
+
sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
|
|
6764
|
+
arrowStyle[side] = sideValue;
|
|
6765
|
+
arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
|
|
6766
|
+
|
|
6767
|
+
data.offsets.arrow = arrowStyle;
|
|
6768
|
+
data.arrowElement = arrow;
|
|
6769
|
+
|
|
6770
|
+
return data;
|
|
6771
|
+
};
|
|
6772
|
+
|
|
6773
|
+
//
|
|
6774
|
+
// Helpers
|
|
6775
|
+
//
|
|
6776
|
+
|
|
6892
6777
|
/**
|
|
6893
6778
|
* Get the outer sizes of the given element (offset size + margins)
|
|
6894
6779
|
* @function
|
|
6895
6780
|
* @ignore
|
|
6896
6781
|
* @argument {Element} element
|
|
6897
6782
|
* @returns {Object} object containing width and height properties
|
|
6898
|
-
*/
|
|
6899
|
-
function getOuterSizes(element) {
|
|
6900
|
-
// NOTE: 1 DOM access here
|
|
6901
|
-
var _display = element.style.display,
|
|
6902
|
-
|
|
6903
|
-
element.style.display = 'block';
|
|
6904
|
-
element.style.visibility = 'hidden';
|
|
6905
|
-
var calcWidthToForceRepaint = element.offsetWidth;
|
|
6906
|
-
// original method
|
|
6907
|
-
var styles = getRealWindow(element).getComputedStyle(element);
|
|
6908
|
-
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
6909
|
-
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
6910
|
-
var result = {
|
|
6911
|
-
width: element.offsetWidth + y,
|
|
6912
|
-
height: element.offsetHeight + x
|
|
6913
|
-
};
|
|
6914
|
-
|
|
6915
|
-
// reset element styles
|
|
6916
|
-
element.style.display = _display;
|
|
6917
|
-
element.style.visibility = _visibility;
|
|
6918
|
-
return result;
|
|
6919
|
-
}
|
|
6920
|
-
|
|
6783
|
+
*/
|
|
6784
|
+
function getOuterSizes(element) {
|
|
6785
|
+
// NOTE: 1 DOM access here
|
|
6786
|
+
var _display = element.style.display,
|
|
6787
|
+
_visibility = element.style.visibility;
|
|
6788
|
+
element.style.display = 'block';
|
|
6789
|
+
element.style.visibility = 'hidden';
|
|
6790
|
+
var calcWidthToForceRepaint = element.offsetWidth;
|
|
6791
|
+
// original method
|
|
6792
|
+
var styles = getRealWindow(element).getComputedStyle(element);
|
|
6793
|
+
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
6794
|
+
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
6795
|
+
var result = {
|
|
6796
|
+
width: element.offsetWidth + y,
|
|
6797
|
+
height: element.offsetHeight + x
|
|
6798
|
+
};
|
|
6799
|
+
|
|
6800
|
+
// reset element styles
|
|
6801
|
+
element.style.display = _display;
|
|
6802
|
+
element.style.visibility = _visibility;
|
|
6803
|
+
return result;
|
|
6804
|
+
}
|
|
6805
|
+
|
|
6921
6806
|
/**
|
|
6922
6807
|
* Get the opposite placement of the given one/
|
|
6923
6808
|
* @function
|
|
6924
6809
|
* @ignore
|
|
6925
6810
|
* @argument {String} placement
|
|
6926
6811
|
* @returns {String} flipped placement
|
|
6927
|
-
*/
|
|
6928
|
-
function getOppositePlacement(placement) {
|
|
6929
|
-
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
|
6930
|
-
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
6931
|
-
return hash[matched];
|
|
6932
|
-
});
|
|
6933
|
-
}
|
|
6934
|
-
|
|
6812
|
+
*/
|
|
6813
|
+
function getOppositePlacement(placement) {
|
|
6814
|
+
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
|
6815
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
6816
|
+
return hash[matched];
|
|
6817
|
+
});
|
|
6818
|
+
}
|
|
6819
|
+
|
|
6935
6820
|
/**
|
|
6936
6821
|
* Given the popper offsets, generate an output similar to getBoundingClientRect
|
|
6937
6822
|
* @function
|
|
6938
6823
|
* @ignore
|
|
6939
6824
|
* @argument {Object} popperOffsets
|
|
6940
6825
|
* @returns {Object} ClientRect like output
|
|
6941
|
-
*/
|
|
6942
|
-
function getPopperClientRect(popperOffsets) {
|
|
6943
|
-
var offsets = Object.assign({}, popperOffsets);
|
|
6944
|
-
offsets.right = offsets.left + offsets.width;
|
|
6945
|
-
offsets.bottom = offsets.top + offsets.height;
|
|
6946
|
-
return offsets;
|
|
6947
|
-
}
|
|
6948
|
-
|
|
6826
|
+
*/
|
|
6827
|
+
function getPopperClientRect(popperOffsets) {
|
|
6828
|
+
var offsets = Object.assign({}, popperOffsets);
|
|
6829
|
+
offsets.right = offsets.left + offsets.width;
|
|
6830
|
+
offsets.bottom = offsets.top + offsets.height;
|
|
6831
|
+
return offsets;
|
|
6832
|
+
}
|
|
6833
|
+
|
|
6949
6834
|
/**
|
|
6950
6835
|
* Given an array and the key to find, returns its index
|
|
6951
6836
|
* @function
|
|
@@ -6953,48 +6838,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6953
6838
|
* @argument {Array} arr
|
|
6954
6839
|
* @argument keyToFind
|
|
6955
6840
|
* @returns index or null
|
|
6956
|
-
*/
|
|
6957
|
-
function getArrayKeyIndex(arr, keyToFind) {
|
|
6958
|
-
var i = 0,
|
|
6959
|
-
|
|
6960
|
-
for (key in arr) {
|
|
6961
|
-
if (arr[key] === keyToFind) {
|
|
6962
|
-
return i;
|
|
6963
|
-
}
|
|
6964
|
-
i++;
|
|
6965
|
-
}
|
|
6966
|
-
return null;
|
|
6967
|
-
}
|
|
6968
|
-
|
|
6841
|
+
*/
|
|
6842
|
+
function getArrayKeyIndex(arr, keyToFind) {
|
|
6843
|
+
var i = 0,
|
|
6844
|
+
key;
|
|
6845
|
+
for (key in arr) {
|
|
6846
|
+
if (arr[key] === keyToFind) {
|
|
6847
|
+
return i;
|
|
6848
|
+
}
|
|
6849
|
+
i++;
|
|
6850
|
+
}
|
|
6851
|
+
return null;
|
|
6852
|
+
}
|
|
6853
|
+
|
|
6969
6854
|
/**
|
|
6970
6855
|
* Get CSS computed property of the given element
|
|
6971
6856
|
* @function
|
|
6972
6857
|
* @ignore
|
|
6973
6858
|
* @argument {Eement} element
|
|
6974
6859
|
* @argument {String} property
|
|
6975
|
-
*/
|
|
6976
|
-
function getStyleComputedProperty(element, property) {
|
|
6977
|
-
// NOTE: 1 DOM access here
|
|
6978
|
-
// 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
|
|
6979
|
-
// 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
|
|
6980
|
-
var css = getRealWindow(element).getComputedStyle(element, null);
|
|
6981
|
-
return css[property];
|
|
6982
|
-
}
|
|
6983
|
-
|
|
6860
|
+
*/
|
|
6861
|
+
function getStyleComputedProperty(element, property) {
|
|
6862
|
+
// NOTE: 1 DOM access here
|
|
6863
|
+
// 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
|
|
6864
|
+
// 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
|
|
6865
|
+
var css = getRealWindow(element).getComputedStyle(element, null);
|
|
6866
|
+
return css[property];
|
|
6867
|
+
}
|
|
6868
|
+
|
|
6984
6869
|
/**
|
|
6985
6870
|
* Returns the offset parent of the given element
|
|
6986
6871
|
* @function
|
|
6987
6872
|
* @ignore
|
|
6988
6873
|
* @argument {Element} element
|
|
6989
6874
|
* @returns {Element} offset parent
|
|
6990
|
-
*/
|
|
6991
|
-
function getOffsetParent(element) {
|
|
6992
|
-
var offsetParent = element.offsetParent;
|
|
6993
|
-
return offsetParent === root.document.body || !offsetParent
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
}
|
|
6997
|
-
|
|
6875
|
+
*/
|
|
6876
|
+
function getOffsetParent(element) {
|
|
6877
|
+
var offsetParent = element.offsetParent;
|
|
6878
|
+
return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
|
|
6879
|
+
}
|
|
6880
|
+
|
|
6998
6881
|
/**
|
|
6999
6882
|
* Returns the window the given element actually renders in.
|
|
7000
6883
|
* 无界等微前端场景下组件代码运行在沙箱 window 中,而 DOM 实际渲染在
|
|
@@ -7003,16 +6886,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
7003
6886
|
* @ignore
|
|
7004
6887
|
* @argument {Element} element
|
|
7005
6888
|
* @returns {Window} window
|
|
7006
|
-
*/
|
|
7007
|
-
function getRealWindow(element) {
|
|
7008
|
-
return
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
element.ownerDocument.defaultView) ||
|
|
7012
|
-
root
|
|
7013
|
-
);
|
|
7014
|
-
}
|
|
7015
|
-
|
|
6889
|
+
*/
|
|
6890
|
+
function getRealWindow(element) {
|
|
6891
|
+
return element && element.ownerDocument && element.ownerDocument.defaultView || root;
|
|
6892
|
+
}
|
|
6893
|
+
|
|
7016
6894
|
/**
|
|
7017
6895
|
* Returns the viewport rect of the containing block actually used to position the popper.
|
|
7018
6896
|
* 无界微前端等场景下 popper 被挂载进子应用的 shadowRoot,offsetParent 的兜底值
|
|
@@ -7026,82 +6904,72 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
7026
6904
|
* @argument {Element} element - popper element
|
|
7027
6905
|
* @argument {Boolean} fixed - whether the popper is fixed positioned
|
|
7028
6906
|
* @returns {Object} rect
|
|
7029
|
-
*/
|
|
7030
|
-
function getContainingBlockRect(element, fixed) {
|
|
7031
|
-
if (fixed) {
|
|
7032
|
-
return { top: 0, left: 0, right: 0, bottom: 0 };
|
|
7033
|
-
}
|
|
7034
|
-
|
|
7035
|
-
var node = element.parentNode;
|
|
7036
|
-
while (node) {
|
|
7037
|
-
if (node.nodeType === 1) {
|
|
7038
|
-
if (getStyleComputedProperty(node, 'position') !== 'static') {
|
|
7039
|
-
return getBoundingClientRect(node);
|
|
7040
|
-
}
|
|
7041
|
-
} else if (node.nodeType === 11) {
|
|
7042
|
-
// 遇到 shadowRoot,跨边界从宿主元素继续向上查找
|
|
7043
|
-
node = node.host;
|
|
7044
|
-
continue;
|
|
7045
|
-
} else {
|
|
7046
|
-
break;
|
|
7047
|
-
}
|
|
7048
|
-
node = node.parentNode;
|
|
7049
|
-
}
|
|
7050
|
-
|
|
7051
|
-
var win = getRealWindow(element);
|
|
7052
|
-
return {
|
|
7053
|
-
top: -(win.pageYOffset || 0),
|
|
7054
|
-
left: -(win.pageXOffset || 0),
|
|
7055
|
-
right: 0,
|
|
7056
|
-
bottom: 0
|
|
7057
|
-
};
|
|
7058
|
-
}
|
|
7059
|
-
|
|
6907
|
+
*/
|
|
6908
|
+
function getContainingBlockRect(element, fixed) {
|
|
6909
|
+
if (fixed) {
|
|
6910
|
+
return { top: 0, left: 0, right: 0, bottom: 0 };
|
|
6911
|
+
}
|
|
6912
|
+
|
|
6913
|
+
var node = element.parentNode;
|
|
6914
|
+
while (node) {
|
|
6915
|
+
if (node.nodeType === 1) {
|
|
6916
|
+
if (getStyleComputedProperty(node, 'position') !== 'static') {
|
|
6917
|
+
return getBoundingClientRect(node);
|
|
6918
|
+
}
|
|
6919
|
+
} else if (node.nodeType === 11) {
|
|
6920
|
+
// 遇到 shadowRoot,跨边界从宿主元素继续向上查找
|
|
6921
|
+
node = node.host;
|
|
6922
|
+
continue;
|
|
6923
|
+
} else {
|
|
6924
|
+
break;
|
|
6925
|
+
}
|
|
6926
|
+
node = node.parentNode;
|
|
6927
|
+
}
|
|
6928
|
+
|
|
6929
|
+
var win = getRealWindow(element);
|
|
6930
|
+
return {
|
|
6931
|
+
top: -(win.pageYOffset || 0),
|
|
6932
|
+
left: -(win.pageXOffset || 0),
|
|
6933
|
+
right: 0,
|
|
6934
|
+
bottom: 0
|
|
6935
|
+
};
|
|
6936
|
+
}
|
|
6937
|
+
|
|
7060
6938
|
/**
|
|
7061
6939
|
* Returns the scrolling parent of the given element
|
|
7062
6940
|
* @function
|
|
7063
6941
|
* @ignore
|
|
7064
6942
|
* @argument {Element} element
|
|
7065
6943
|
* @returns {Element} offset parent
|
|
7066
|
-
*/
|
|
7067
|
-
function getScrollParent(element) {
|
|
7068
|
-
var parent = element.parentNode;
|
|
7069
|
-
if (!parent) {
|
|
7070
|
-
return element;
|
|
7071
|
-
}
|
|
7072
|
-
|
|
7073
|
-
if (parent.nodeType === 11) {
|
|
7074
|
-
// 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
|
|
7075
|
-
// 否则查找到 shadowRoot 即终止,滚动事件无法被监听
|
|
7076
|
-
return getScrollParent(parent.host);
|
|
7077
|
-
}
|
|
7078
|
-
|
|
7079
|
-
if (parent.nodeType !== 1) {
|
|
7080
|
-
// 到达 document,返回元素实际渲染所在的真实 window,
|
|
7081
|
-
// 保证 window 滚动时能触发位置更新
|
|
7082
|
-
return getRealWindow(element);
|
|
7083
|
-
}
|
|
7084
|
-
|
|
7085
|
-
// Firefox want us to check `-x` and `-y` variations as well
|
|
7086
|
-
if (
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
) !== -1
|
|
7096
|
-
) {
|
|
7097
|
-
// If the detected scrollParent is body, we perform an additional check on its parentNode
|
|
7098
|
-
// in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
|
|
7099
|
-
// fixes issue #65
|
|
7100
|
-
return parent;
|
|
7101
|
-
}
|
|
7102
|
-
return getScrollParent(parent);
|
|
7103
|
-
}
|
|
7104
|
-
|
|
6944
|
+
*/
|
|
6945
|
+
function getScrollParent(element) {
|
|
6946
|
+
var parent = element.parentNode;
|
|
6947
|
+
if (!parent) {
|
|
6948
|
+
return element;
|
|
6949
|
+
}
|
|
6950
|
+
|
|
6951
|
+
if (parent.nodeType === 11) {
|
|
6952
|
+
// 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
|
|
6953
|
+
// 否则查找到 shadowRoot 即终止,滚动事件无法被监听
|
|
6954
|
+
return getScrollParent(parent.host);
|
|
6955
|
+
}
|
|
6956
|
+
|
|
6957
|
+
if (parent.nodeType !== 1) {
|
|
6958
|
+
// 到达 document,返回元素实际渲染所在的真实 window,
|
|
6959
|
+
// 保证 window 滚动时能触发位置更新
|
|
6960
|
+
return getRealWindow(element);
|
|
6961
|
+
}
|
|
6962
|
+
|
|
6963
|
+
// Firefox want us to check `-x` and `-y` variations as well
|
|
6964
|
+
if (['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1) {
|
|
6965
|
+
// If the detected scrollParent is body, we perform an additional check on its parentNode
|
|
6966
|
+
// in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
|
|
6967
|
+
// fixes issue #65
|
|
6968
|
+
return parent;
|
|
6969
|
+
}
|
|
6970
|
+
return getScrollParent(parent);
|
|
6971
|
+
}
|
|
6972
|
+
|
|
7105
6973
|
/**
|
|
7106
6974
|
* Check if the given element is fixed or is inside a fixed parent
|
|
7107
6975
|
* @function
|
|
@@ -7109,125 +6977,114 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
7109
6977
|
* @argument {Element} element
|
|
7110
6978
|
* @argument {Element} customContainer
|
|
7111
6979
|
* @returns {Boolean} answer to "isFixed?"
|
|
7112
|
-
*/
|
|
7113
|
-
function isFixed(element) {
|
|
7114
|
-
if (element === root.document.body) {
|
|
7115
|
-
return false;
|
|
7116
|
-
}
|
|
7117
|
-
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
|
7118
|
-
return true;
|
|
7119
|
-
}
|
|
7120
|
-
var parent = element.parentNode;
|
|
7121
|
-
if (parent && parent.nodeType === 11) {
|
|
7122
|
-
// 跨 shadowRoot 边界,从宿主元素继续向上判断
|
|
7123
|
-
parent = parent.host;
|
|
7124
|
-
}
|
|
7125
|
-
return parent && parent.nodeType === 1 ? isFixed(parent) : false;
|
|
7126
|
-
}
|
|
7127
|
-
|
|
6980
|
+
*/
|
|
6981
|
+
function isFixed(element) {
|
|
6982
|
+
if (element === root.document.body) {
|
|
6983
|
+
return false;
|
|
6984
|
+
}
|
|
6985
|
+
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
|
6986
|
+
return true;
|
|
6987
|
+
}
|
|
6988
|
+
var parent = element.parentNode;
|
|
6989
|
+
if (parent && parent.nodeType === 11) {
|
|
6990
|
+
// 跨 shadowRoot 边界,从宿主元素继续向上判断
|
|
6991
|
+
parent = parent.host;
|
|
6992
|
+
}
|
|
6993
|
+
return parent && parent.nodeType === 1 ? isFixed(parent) : false;
|
|
6994
|
+
}
|
|
6995
|
+
|
|
7128
6996
|
/**
|
|
7129
6997
|
* Set the style to the given popper
|
|
7130
6998
|
* @function
|
|
7131
6999
|
* @ignore
|
|
7132
7000
|
* @argument {Element} element - Element to apply the style to
|
|
7133
7001
|
* @argument {Object} styles - Object with a list of properties and values which will be applied to the element
|
|
7134
|
-
*/
|
|
7135
|
-
function setStyle(element, styles) {
|
|
7136
|
-
function is_numeric(n) {
|
|
7137
|
-
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
|
7138
|
-
}
|
|
7139
|
-
Object.keys(styles).forEach(function (prop) {
|
|
7140
|
-
var unit = '';
|
|
7141
|
-
// add unit if the value is numeric and is one of the following
|
|
7142
|
-
if (
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
/**
|
|
7154
|
-
* Check if the given variable is a function
|
|
7155
|
-
* @function
|
|
7156
|
-
* @ignore
|
|
7002
|
+
*/
|
|
7003
|
+
function setStyle(element, styles) {
|
|
7004
|
+
function is_numeric(n) {
|
|
7005
|
+
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
|
7006
|
+
}
|
|
7007
|
+
Object.keys(styles).forEach(function (prop) {
|
|
7008
|
+
var unit = '';
|
|
7009
|
+
// add unit if the value is numeric and is one of the following
|
|
7010
|
+
if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
|
|
7011
|
+
unit = 'px';
|
|
7012
|
+
}
|
|
7013
|
+
element.style[prop] = styles[prop] + unit;
|
|
7014
|
+
});
|
|
7015
|
+
}
|
|
7016
|
+
|
|
7017
|
+
/**
|
|
7018
|
+
* Check if the given variable is a function
|
|
7019
|
+
* @function
|
|
7020
|
+
* @ignore
|
|
7157
7021
|
* @argument {*} functionToCheck - variable to check
|
|
7158
7022
|
* @returns {Boolean} answer to: is a function?
|
|
7159
|
-
*/
|
|
7160
|
-
function isFunction(functionToCheck) {
|
|
7161
|
-
var getType = {};
|
|
7162
|
-
return (
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
);
|
|
7166
|
-
}
|
|
7167
|
-
|
|
7023
|
+
*/
|
|
7024
|
+
function isFunction(functionToCheck) {
|
|
7025
|
+
var getType = {};
|
|
7026
|
+
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
7027
|
+
}
|
|
7028
|
+
|
|
7168
7029
|
/**
|
|
7169
7030
|
* Get the position of the given element, relative to its offset parent
|
|
7170
7031
|
* @function
|
|
7171
7032
|
* @ignore
|
|
7172
7033
|
* @param {Element} element
|
|
7173
7034
|
* @return {Object} position - Coordinates of the element and its `scrollTop`
|
|
7174
|
-
*/
|
|
7175
|
-
function getOffsetRect(element) {
|
|
7176
|
-
var transform = getStyle(element, 'transform')
|
|
7177
|
-
|
|
7178
|
-
.
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
return elementRect;
|
|
7192
|
-
}
|
|
7193
|
-
|
|
7035
|
+
*/
|
|
7036
|
+
function getOffsetRect(element) {
|
|
7037
|
+
var transform = getStyle(element, 'transform').replace(/[^0-9\-,]/g, '').split(',');
|
|
7038
|
+
var elementRect = {
|
|
7039
|
+
width: element.offsetWidth,
|
|
7040
|
+
height: element.offsetHeight,
|
|
7041
|
+
left: element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
|
|
7042
|
+
top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
|
|
7043
|
+
};
|
|
7044
|
+
|
|
7045
|
+
elementRect.right = elementRect.left + elementRect.width;
|
|
7046
|
+
elementRect.bottom = elementRect.top + elementRect.height;
|
|
7047
|
+
|
|
7048
|
+
// position
|
|
7049
|
+
return elementRect;
|
|
7050
|
+
}
|
|
7051
|
+
|
|
7194
7052
|
/**
|
|
7195
7053
|
* Get bounding client rect of given element
|
|
7196
7054
|
* @function
|
|
7197
7055
|
* @ignore
|
|
7198
7056
|
* @param {HTMLElement} element
|
|
7199
7057
|
* @return {Object} client rect
|
|
7200
|
-
*/
|
|
7201
|
-
function getBoundingClientRect(element) {
|
|
7202
|
-
var rect = element.getBoundingClientRect();
|
|
7203
|
-
|
|
7204
|
-
// whether the IE version is lower than 11
|
|
7205
|
-
var isIE = /MSIE|Trident/.test(navigator.userAgent);
|
|
7206
|
-
|
|
7207
|
-
// fix ie document bounding top always 0 bug
|
|
7208
|
-
var rectTop =
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7058
|
+
*/
|
|
7059
|
+
function getBoundingClientRect(element) {
|
|
7060
|
+
var rect = element.getBoundingClientRect();
|
|
7061
|
+
|
|
7062
|
+
// whether the IE version is lower than 11
|
|
7063
|
+
var isIE = /MSIE|Trident/.test(navigator.userAgent);
|
|
7064
|
+
|
|
7065
|
+
// fix ie document bounding top always 0 bug
|
|
7066
|
+
var rectTop = isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
|
|
7067
|
+
|
|
7068
|
+
return {
|
|
7069
|
+
left: rect.left,
|
|
7070
|
+
top: rectTop,
|
|
7071
|
+
right: rect.right,
|
|
7072
|
+
bottom: rect.bottom,
|
|
7073
|
+
width: rect.right - rect.left,
|
|
7074
|
+
height: rect.bottom - rectTop
|
|
7075
|
+
};
|
|
7076
|
+
}
|
|
7077
|
+
|
|
7078
|
+
function getStyle(dom, attr) {
|
|
7079
|
+
if (dom.style[attr]) {
|
|
7080
|
+
return dom.style[attr];
|
|
7081
|
+
}
|
|
7082
|
+
if (window.getComputedStyle) {
|
|
7083
|
+
return getComputedStyle(dom, null)[attr];
|
|
7084
|
+
}
|
|
7085
|
+
return dom.currentStyle[attr];
|
|
7086
|
+
}
|
|
7087
|
+
|
|
7231
7088
|
/**
|
|
7232
7089
|
* Given an element and one of its parents, return the offset
|
|
7233
7090
|
* @function
|
|
@@ -7235,45 +7092,43 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
7235
7092
|
* @param {HTMLElement} element
|
|
7236
7093
|
* @param {HTMLElement} parent
|
|
7237
7094
|
* @return {Object} rect
|
|
7238
|
-
*/
|
|
7239
|
-
function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
|
|
7240
|
-
var elementRect = getBoundingClientRect(element);
|
|
7241
|
-
// parent 为 popper 元素:取其真实包含块的视口 rect,
|
|
7242
|
-
// 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
|
|
7243
|
-
var parentRect = getContainingBlockRect(parent, fixed);
|
|
7244
|
-
|
|
7245
|
-
var rect = {
|
|
7246
|
-
top: elementRect.top - parentRect.top,
|
|
7247
|
-
left: elementRect.left - parentRect.left,
|
|
7248
|
-
bottom: elementRect.top - parentRect.top + elementRect.height,
|
|
7249
|
-
right: elementRect.left - parentRect.left + elementRect.width,
|
|
7250
|
-
width: elementRect.width,
|
|
7251
|
-
height: elementRect.height
|
|
7252
|
-
};
|
|
7253
|
-
return rect;
|
|
7254
|
-
}
|
|
7255
|
-
|
|
7095
|
+
*/
|
|
7096
|
+
function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
|
|
7097
|
+
var elementRect = getBoundingClientRect(element);
|
|
7098
|
+
// parent 为 popper 元素:取其真实包含块的视口 rect,
|
|
7099
|
+
// 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
|
|
7100
|
+
var parentRect = getContainingBlockRect(parent, fixed);
|
|
7101
|
+
|
|
7102
|
+
var rect = {
|
|
7103
|
+
top: elementRect.top - parentRect.top,
|
|
7104
|
+
left: elementRect.left - parentRect.left,
|
|
7105
|
+
bottom: elementRect.top - parentRect.top + elementRect.height,
|
|
7106
|
+
right: elementRect.left - parentRect.left + elementRect.width,
|
|
7107
|
+
width: elementRect.width,
|
|
7108
|
+
height: elementRect.height
|
|
7109
|
+
};
|
|
7110
|
+
return rect;
|
|
7111
|
+
}
|
|
7112
|
+
|
|
7256
7113
|
/**
|
|
7257
7114
|
* Get the prefixed supported property name
|
|
7258
7115
|
* @function
|
|
7259
7116
|
* @ignore
|
|
7260
7117
|
* @argument {String} property (camelCase)
|
|
7261
7118
|
* @returns {String} prefixed property (camelCase)
|
|
7262
|
-
*/
|
|
7263
|
-
function getSupportedPropertyName(property) {
|
|
7264
|
-
var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
|
|
7265
|
-
|
|
7266
|
-
for (var i = 0; i < prefixes.length; i++) {
|
|
7267
|
-
var toCheck = prefixes[i]
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
}
|
|
7276
|
-
|
|
7119
|
+
*/
|
|
7120
|
+
function getSupportedPropertyName(property) {
|
|
7121
|
+
var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
|
|
7122
|
+
|
|
7123
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
7124
|
+
var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
|
|
7125
|
+
if (typeof root.document.body.style[toCheck] !== 'undefined') {
|
|
7126
|
+
return toCheck;
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
return null;
|
|
7130
|
+
}
|
|
7131
|
+
|
|
7277
7132
|
/**
|
|
7278
7133
|
* The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
|
|
7279
7134
|
* objects to a target object. It will return the target object.
|
|
@@ -7281,46 +7136,41 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
7281
7136
|
* Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
7282
7137
|
* @function
|
|
7283
7138
|
* @ignore
|
|
7284
|
-
*/
|
|
7285
|
-
if (!Object.assign) {
|
|
7286
|
-
Object.defineProperty(Object, 'assign', {
|
|
7287
|
-
enumerable: false,
|
|
7288
|
-
configurable: true,
|
|
7289
|
-
writable: true,
|
|
7290
|
-
value: function (target) {
|
|
7291
|
-
if (target === undefined || target === null) {
|
|
7292
|
-
throw new TypeError('Cannot convert first argument to object');
|
|
7293
|
-
}
|
|
7294
|
-
|
|
7295
|
-
var to = Object(target);
|
|
7296
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
7297
|
-
var nextSource = arguments[i];
|
|
7298
|
-
if (nextSource === undefined || nextSource === null) {
|
|
7299
|
-
continue;
|
|
7300
|
-
}
|
|
7301
|
-
nextSource = Object(nextSource);
|
|
7302
|
-
|
|
7303
|
-
var keysArray = Object.keys(nextSource);
|
|
7304
|
-
for (
|
|
7305
|
-
var nextIndex = 0, len = keysArray.length;
|
|
7306
|
-
nextIndex < len;
|
|
7307
|
-
nextIndex++
|
|
7308
|
-
) {
|
|
7309
|
-
var nextKey = keysArray[nextIndex];
|
|
7310
|
-
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
|
7311
|
-
if (desc !== undefined && desc.enumerable) {
|
|
7312
|
-
to[nextKey] = nextSource[nextKey];
|
|
7313
|
-
}
|
|
7314
|
-
}
|
|
7315
|
-
}
|
|
7316
|
-
return to;
|
|
7317
|
-
}
|
|
7318
|
-
});
|
|
7319
|
-
}
|
|
7320
|
-
|
|
7321
|
-
return Popper;
|
|
7322
|
-
});
|
|
7139
|
+
*/
|
|
7140
|
+
if (!Object.assign) {
|
|
7141
|
+
Object.defineProperty(Object, 'assign', {
|
|
7142
|
+
enumerable: false,
|
|
7143
|
+
configurable: true,
|
|
7144
|
+
writable: true,
|
|
7145
|
+
value: function value(target) {
|
|
7146
|
+
if (target === undefined || target === null) {
|
|
7147
|
+
throw new TypeError('Cannot convert first argument to object');
|
|
7148
|
+
}
|
|
7323
7149
|
|
|
7150
|
+
var to = Object(target);
|
|
7151
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
7152
|
+
var nextSource = arguments[i];
|
|
7153
|
+
if (nextSource === undefined || nextSource === null) {
|
|
7154
|
+
continue;
|
|
7155
|
+
}
|
|
7156
|
+
nextSource = Object(nextSource);
|
|
7157
|
+
|
|
7158
|
+
var keysArray = Object.keys(nextSource);
|
|
7159
|
+
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
|
|
7160
|
+
var nextKey = keysArray[nextIndex];
|
|
7161
|
+
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
|
7162
|
+
if (desc !== undefined && desc.enumerable) {
|
|
7163
|
+
to[nextKey] = nextSource[nextKey];
|
|
7164
|
+
}
|
|
7165
|
+
}
|
|
7166
|
+
}
|
|
7167
|
+
return to;
|
|
7168
|
+
}
|
|
7169
|
+
});
|
|
7170
|
+
}
|
|
7171
|
+
|
|
7172
|
+
return Popper;
|
|
7173
|
+
});
|
|
7324
7174
|
|
|
7325
7175
|
/***/ }),
|
|
7326
7176
|
|
|
@@ -7374,759 +7224,736 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
7374
7224
|
/* unused harmony export getSecond */
|
|
7375
7225
|
/* unused harmony export getWeekday */
|
|
7376
7226
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
* The MIT License (MIT)
|
|
7380
|
-
*
|
|
7381
|
-
* Copyright (c) 2015 Taylor Hakes
|
|
7382
|
-
*
|
|
7383
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7384
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
7385
|
-
* in the Software without restriction, including without limitation the rights
|
|
7386
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7387
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
7388
|
-
* furnished to do so, subject to the following conditions:
|
|
7389
|
-
*
|
|
7390
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
7391
|
-
* copies or substantial portions of the Software.
|
|
7392
|
-
*
|
|
7393
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
7394
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
7395
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
7396
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
7397
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
7398
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
7399
|
-
* SOFTWARE.
|
|
7400
|
-
*/
|
|
7401
|
-
|
|
7402
|
-
/*eslint-disable*/
|
|
7403
|
-
// 把 YYYY-MM-DD 改成了 yyyy-MM-dd
|
|
7404
|
-
|
|
7405
|
-
|
|
7227
|
+
|
|
7228
|
+
|
|
7406
7229
|
/**
|
|
7407
7230
|
* Parse or format dates
|
|
7408
7231
|
* @class fecha
|
|
7409
|
-
*/
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
function regexEscape(str) {
|
|
7420
|
-
return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
|
|
7421
|
-
}
|
|
7422
|
-
|
|
7423
|
-
function shorten(arr, sLen) {
|
|
7424
|
-
|
|
7425
|
-
for (
|
|
7426
|
-
newArr.push(arr[i].substr(0, sLen));
|
|
7427
|
-
}
|
|
7428
|
-
return newArr;
|
|
7429
|
-
}
|
|
7430
|
-
|
|
7431
|
-
function monthUpdate() {
|
|
7432
|
-
return function (d, v) {
|
|
7433
|
-
|
|
7434
|
-
if (~index) {
|
|
7435
|
-
d.month = index;
|
|
7436
|
-
}
|
|
7437
|
-
};
|
|
7438
|
-
}
|
|
7439
|
-
|
|
7440
|
-
function pad(val, len) {
|
|
7441
|
-
val = String(val);
|
|
7442
|
-
len = len || 2;
|
|
7443
|
-
while (val.length < len) {
|
|
7444
|
-
val = '0' + val;
|
|
7445
|
-
}
|
|
7446
|
-
return val;
|
|
7447
|
-
}
|
|
7448
|
-
|
|
7449
|
-
// 直接使用中文日期名称常量
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
return D + '日';
|
|
7457
|
-
};
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
D: function(dateObj) {
|
|
7461
|
-
return dateObj.getDay();
|
|
7462
|
-
},
|
|
7463
|
-
DD: function(dateObj) {
|
|
7464
|
-
return pad(dateObj.getDay());
|
|
7465
|
-
},
|
|
7466
|
-
Do: function(dateObj) {
|
|
7467
|
-
return DoFn(dateObj.getDate());
|
|
7468
|
-
},
|
|
7469
|
-
d: function(dateObj) {
|
|
7470
|
-
return dateObj.getDate();
|
|
7471
|
-
},
|
|
7472
|
-
dd: function(dateObj) {
|
|
7473
|
-
return pad(dateObj.getDate());
|
|
7474
|
-
},
|
|
7475
|
-
ddd: function(dateObj) {
|
|
7476
|
-
return dayNamesShort[dateObj.getDay()];
|
|
7477
|
-
},
|
|
7478
|
-
dddd: function(dateObj) {
|
|
7479
|
-
return dayNames[dateObj.getDay()];
|
|
7480
|
-
},
|
|
7481
|
-
M: function(dateObj) {
|
|
7482
|
-
return dateObj.getMonth() + 1;
|
|
7483
|
-
},
|
|
7484
|
-
MM: function(dateObj) {
|
|
7485
|
-
return pad(dateObj.getMonth() + 1);
|
|
7486
|
-
},
|
|
7487
|
-
MMM: function(dateObj) {
|
|
7488
|
-
return monthNamesShort[dateObj.getMonth()];
|
|
7489
|
-
},
|
|
7490
|
-
MMMM: function(dateObj) {
|
|
7491
|
-
return monthNames[dateObj.getMonth()];
|
|
7492
|
-
},
|
|
7493
|
-
yy: function(dateObj) {
|
|
7494
|
-
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
7495
|
-
},
|
|
7496
|
-
yyyy: function(dateObj) {
|
|
7497
|
-
return pad(dateObj.getFullYear(), 4);
|
|
7498
|
-
},
|
|
7499
|
-
h: function(dateObj) {
|
|
7500
|
-
return dateObj.getHours() % 12 || 12;
|
|
7501
|
-
},
|
|
7502
|
-
hh: function(dateObj) {
|
|
7503
|
-
return pad(dateObj.getHours() % 12 || 12);
|
|
7504
|
-
},
|
|
7505
|
-
H: function(dateObj) {
|
|
7506
|
-
return dateObj.getHours();
|
|
7507
|
-
},
|
|
7508
|
-
HH: function(dateObj) {
|
|
7509
|
-
return pad(dateObj.getHours());
|
|
7510
|
-
},
|
|
7511
|
-
m: function(dateObj) {
|
|
7512
|
-
return dateObj.getMinutes();
|
|
7513
|
-
},
|
|
7514
|
-
mm: function(dateObj) {
|
|
7515
|
-
return pad(dateObj.getMinutes());
|
|
7516
|
-
},
|
|
7517
|
-
s: function(dateObj) {
|
|
7518
|
-
return dateObj.getSeconds();
|
|
7519
|
-
},
|
|
7520
|
-
ss: function(dateObj) {
|
|
7521
|
-
return pad(dateObj.getSeconds());
|
|
7522
|
-
},
|
|
7523
|
-
S: function(dateObj) {
|
|
7524
|
-
return Math.round(dateObj.getMilliseconds() / 100);
|
|
7525
|
-
},
|
|
7526
|
-
SS: function(dateObj) {
|
|
7527
|
-
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
7528
|
-
},
|
|
7529
|
-
SSS: function(dateObj) {
|
|
7530
|
-
return pad(dateObj.getMilliseconds(), 3);
|
|
7531
|
-
},
|
|
7532
|
-
a: function(dateObj) {
|
|
7533
|
-
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
7534
|
-
},
|
|
7535
|
-
A: function(dateObj) {
|
|
7536
|
-
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
7537
|
-
},
|
|
7538
|
-
ZZ: function(dateObj) {
|
|
7539
|
-
|
|
7540
|
-
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
|
7541
|
-
}
|
|
7542
|
-
};
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
d: [twoDigits, function (d, v) {
|
|
7546
|
-
d.day = v;
|
|
7547
|
-
}],
|
|
7548
|
-
Do: [twoDigits + word, function (d, v) {
|
|
7549
|
-
d.day = parseInt(v, 10);
|
|
7550
|
-
}],
|
|
7551
|
-
M: [twoDigits, function (d, v) {
|
|
7552
|
-
d.month = v - 1;
|
|
7553
|
-
}],
|
|
7554
|
-
yy: [twoDigits, function (d, v) {
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
}
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
parseFlags.
|
|
7603
|
-
parseFlags.
|
|
7604
|
-
parseFlags.
|
|
7605
|
-
parseFlags.
|
|
7606
|
-
parseFlags.
|
|
7607
|
-
parseFlags.
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7232
|
+
*/
|
|
7233
|
+
var fecha = {};
|
|
7234
|
+
var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
|
7235
|
+
var twoDigits = '\\d\\d?';
|
|
7236
|
+
var threeDigits = '\\d{3}';
|
|
7237
|
+
var fourDigits = '\\d{4}';
|
|
7238
|
+
var word = '[^\\s]+';
|
|
7239
|
+
var literal = /\[([^]*?)\]/gm;
|
|
7240
|
+
var noop = function noop() {};
|
|
7241
|
+
|
|
7242
|
+
function regexEscape(str) {
|
|
7243
|
+
return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
|
|
7244
|
+
}
|
|
7245
|
+
|
|
7246
|
+
function shorten(arr, sLen) {
|
|
7247
|
+
var newArr = [];
|
|
7248
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
7249
|
+
newArr.push(arr[i].substr(0, sLen));
|
|
7250
|
+
}
|
|
7251
|
+
return newArr;
|
|
7252
|
+
}
|
|
7253
|
+
|
|
7254
|
+
function monthUpdate() {
|
|
7255
|
+
return function (d, v) {
|
|
7256
|
+
var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
|
|
7257
|
+
if (~index) {
|
|
7258
|
+
d.month = index;
|
|
7259
|
+
}
|
|
7260
|
+
};
|
|
7261
|
+
}
|
|
7262
|
+
|
|
7263
|
+
function pad(val, len) {
|
|
7264
|
+
val = String(val);
|
|
7265
|
+
len = len || 2;
|
|
7266
|
+
while (val.length < len) {
|
|
7267
|
+
val = '0' + val;
|
|
7268
|
+
}
|
|
7269
|
+
return val;
|
|
7270
|
+
}
|
|
7271
|
+
|
|
7272
|
+
// 直接使用中文日期名称常量
|
|
7273
|
+
var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
|
|
7274
|
+
var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
|
|
7275
|
+
var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
|
|
7276
|
+
var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
|
|
7277
|
+
var amPm = ['上午', '下午'];
|
|
7278
|
+
var DoFn = function DoFn(D) {
|
|
7279
|
+
return D + '日';
|
|
7280
|
+
};
|
|
7281
|
+
|
|
7282
|
+
var formatFlags = {
|
|
7283
|
+
D: function D(dateObj) {
|
|
7284
|
+
return dateObj.getDay();
|
|
7285
|
+
},
|
|
7286
|
+
DD: function DD(dateObj) {
|
|
7287
|
+
return pad(dateObj.getDay());
|
|
7288
|
+
},
|
|
7289
|
+
Do: function Do(dateObj) {
|
|
7290
|
+
return DoFn(dateObj.getDate());
|
|
7291
|
+
},
|
|
7292
|
+
d: function d(dateObj) {
|
|
7293
|
+
return dateObj.getDate();
|
|
7294
|
+
},
|
|
7295
|
+
dd: function dd(dateObj) {
|
|
7296
|
+
return pad(dateObj.getDate());
|
|
7297
|
+
},
|
|
7298
|
+
ddd: function ddd(dateObj) {
|
|
7299
|
+
return dayNamesShort[dateObj.getDay()];
|
|
7300
|
+
},
|
|
7301
|
+
dddd: function dddd(dateObj) {
|
|
7302
|
+
return dayNames[dateObj.getDay()];
|
|
7303
|
+
},
|
|
7304
|
+
M: function M(dateObj) {
|
|
7305
|
+
return dateObj.getMonth() + 1;
|
|
7306
|
+
},
|
|
7307
|
+
MM: function MM(dateObj) {
|
|
7308
|
+
return pad(dateObj.getMonth() + 1);
|
|
7309
|
+
},
|
|
7310
|
+
MMM: function MMM(dateObj) {
|
|
7311
|
+
return monthNamesShort[dateObj.getMonth()];
|
|
7312
|
+
},
|
|
7313
|
+
MMMM: function MMMM(dateObj) {
|
|
7314
|
+
return monthNames[dateObj.getMonth()];
|
|
7315
|
+
},
|
|
7316
|
+
yy: function yy(dateObj) {
|
|
7317
|
+
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
7318
|
+
},
|
|
7319
|
+
yyyy: function yyyy(dateObj) {
|
|
7320
|
+
return pad(dateObj.getFullYear(), 4);
|
|
7321
|
+
},
|
|
7322
|
+
h: function h(dateObj) {
|
|
7323
|
+
return dateObj.getHours() % 12 || 12;
|
|
7324
|
+
},
|
|
7325
|
+
hh: function hh(dateObj) {
|
|
7326
|
+
return pad(dateObj.getHours() % 12 || 12);
|
|
7327
|
+
},
|
|
7328
|
+
H: function H(dateObj) {
|
|
7329
|
+
return dateObj.getHours();
|
|
7330
|
+
},
|
|
7331
|
+
HH: function HH(dateObj) {
|
|
7332
|
+
return pad(dateObj.getHours());
|
|
7333
|
+
},
|
|
7334
|
+
m: function m(dateObj) {
|
|
7335
|
+
return dateObj.getMinutes();
|
|
7336
|
+
},
|
|
7337
|
+
mm: function mm(dateObj) {
|
|
7338
|
+
return pad(dateObj.getMinutes());
|
|
7339
|
+
},
|
|
7340
|
+
s: function s(dateObj) {
|
|
7341
|
+
return dateObj.getSeconds();
|
|
7342
|
+
},
|
|
7343
|
+
ss: function ss(dateObj) {
|
|
7344
|
+
return pad(dateObj.getSeconds());
|
|
7345
|
+
},
|
|
7346
|
+
S: function S(dateObj) {
|
|
7347
|
+
return Math.round(dateObj.getMilliseconds() / 100);
|
|
7348
|
+
},
|
|
7349
|
+
SS: function SS(dateObj) {
|
|
7350
|
+
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
7351
|
+
},
|
|
7352
|
+
SSS: function SSS(dateObj) {
|
|
7353
|
+
return pad(dateObj.getMilliseconds(), 3);
|
|
7354
|
+
},
|
|
7355
|
+
a: function a(dateObj) {
|
|
7356
|
+
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
7357
|
+
},
|
|
7358
|
+
A: function A(dateObj) {
|
|
7359
|
+
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
7360
|
+
},
|
|
7361
|
+
ZZ: function ZZ(dateObj) {
|
|
7362
|
+
var o = dateObj.getTimezoneOffset();
|
|
7363
|
+
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
|
7364
|
+
}
|
|
7365
|
+
};
|
|
7366
|
+
|
|
7367
|
+
var parseFlags = {
|
|
7368
|
+
d: [twoDigits, function (d, v) {
|
|
7369
|
+
d.day = v;
|
|
7370
|
+
}],
|
|
7371
|
+
Do: [twoDigits + word, function (d, v) {
|
|
7372
|
+
d.day = parseInt(v, 10);
|
|
7373
|
+
}],
|
|
7374
|
+
M: [twoDigits, function (d, v) {
|
|
7375
|
+
d.month = v - 1;
|
|
7376
|
+
}],
|
|
7377
|
+
yy: [twoDigits, function (d, v) {
|
|
7378
|
+
var da = new Date(),
|
|
7379
|
+
cent = +('' + da.getFullYear()).substr(0, 2);
|
|
7380
|
+
d.year = '' + (v > 68 ? cent - 1 : cent) + v;
|
|
7381
|
+
}],
|
|
7382
|
+
h: [twoDigits, function (d, v) {
|
|
7383
|
+
d.hour = v;
|
|
7384
|
+
}],
|
|
7385
|
+
m: [twoDigits, function (d, v) {
|
|
7386
|
+
d.minute = v;
|
|
7387
|
+
}],
|
|
7388
|
+
s: [twoDigits, function (d, v) {
|
|
7389
|
+
d.second = v;
|
|
7390
|
+
}],
|
|
7391
|
+
yyyy: [fourDigits, function (d, v) {
|
|
7392
|
+
d.year = v;
|
|
7393
|
+
}],
|
|
7394
|
+
S: ['\\d', function (d, v) {
|
|
7395
|
+
d.millisecond = v * 100;
|
|
7396
|
+
}],
|
|
7397
|
+
SS: ['\\d{2}', function (d, v) {
|
|
7398
|
+
d.millisecond = v * 10;
|
|
7399
|
+
}],
|
|
7400
|
+
SSS: [threeDigits, function (d, v) {
|
|
7401
|
+
d.millisecond = v;
|
|
7402
|
+
}],
|
|
7403
|
+
D: [twoDigits, noop],
|
|
7404
|
+
ddd: [word, noop],
|
|
7405
|
+
MMM: [word, monthUpdate('monthNamesShort')],
|
|
7406
|
+
MMMM: [word, monthUpdate('monthNames')],
|
|
7407
|
+
a: [word, function (d, v) {
|
|
7408
|
+
var val = v.toLowerCase();
|
|
7409
|
+
if (val === '上午') {
|
|
7410
|
+
d.isPm = false;
|
|
7411
|
+
} else if (val === '下午') {
|
|
7412
|
+
d.isPm = true;
|
|
7413
|
+
}
|
|
7414
|
+
}],
|
|
7415
|
+
ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
|
|
7416
|
+
var parts = (v + '').match(/([+-]|\d\d)/gi),
|
|
7417
|
+
minutes = void 0;
|
|
7418
|
+
|
|
7419
|
+
if (parts) {
|
|
7420
|
+
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
|
|
7421
|
+
d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
|
|
7422
|
+
}
|
|
7423
|
+
}]
|
|
7424
|
+
};
|
|
7425
|
+
parseFlags.dd = parseFlags.d;
|
|
7426
|
+
parseFlags.dddd = parseFlags.ddd;
|
|
7427
|
+
parseFlags.DD = parseFlags.D;
|
|
7428
|
+
parseFlags.mm = parseFlags.m;
|
|
7429
|
+
parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
|
|
7430
|
+
parseFlags.MM = parseFlags.M;
|
|
7431
|
+
parseFlags.ss = parseFlags.s;
|
|
7432
|
+
parseFlags.A = parseFlags.a;
|
|
7433
|
+
|
|
7434
|
+
// Some common format strings
|
|
7435
|
+
fecha.masks = {
|
|
7436
|
+
default: 'ddd MMM dd yyyy HH:mm:ss',
|
|
7437
|
+
shortDate: 'M/D/yy',
|
|
7438
|
+
mediumDate: 'MMM d, yyyy',
|
|
7439
|
+
longDate: 'MMMM d, yyyy',
|
|
7440
|
+
fullDate: 'dddd, MMMM d, yyyy',
|
|
7441
|
+
shortTime: 'HH:mm',
|
|
7442
|
+
mediumTime: 'HH:mm:ss',
|
|
7443
|
+
longTime: 'HH:mm:ss.SSS'
|
|
7444
|
+
};
|
|
7445
|
+
|
|
7622
7446
|
/***
|
|
7623
7447
|
* Format a date
|
|
7624
7448
|
* @method format
|
|
7625
7449
|
* @param {Date|number} dateObj
|
|
7626
7450
|
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
|
7627
|
-
*/
|
|
7628
|
-
fecha.format = function (dateObj, mask) {
|
|
7629
|
-
if (typeof dateObj === 'number') {
|
|
7630
|
-
dateObj = new Date(dateObj);
|
|
7631
|
-
}
|
|
7632
|
-
|
|
7633
|
-
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
|
7634
|
-
throw new Error('Invalid Date in fecha.format');
|
|
7635
|
-
}
|
|
7636
|
-
|
|
7637
|
-
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
// Make literals inactive by replacing them with ??
|
|
7642
|
-
mask = mask.replace(literal, function($0, $1) {
|
|
7643
|
-
literals.push($1);
|
|
7644
|
-
return '@@@';
|
|
7645
|
-
});
|
|
7646
|
-
// Apply formatting rules
|
|
7647
|
-
mask = mask.replace(token, function ($0) {
|
|
7648
|
-
return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
|
|
7649
|
-
});
|
|
7650
|
-
// Inline literal values back into the formatted value
|
|
7651
|
-
return mask.replace(/@@@/g, function() {
|
|
7652
|
-
return literals.shift();
|
|
7653
|
-
});
|
|
7654
|
-
};
|
|
7655
|
-
|
|
7451
|
+
*/
|
|
7452
|
+
fecha.format = function (dateObj, mask) {
|
|
7453
|
+
if (typeof dateObj === 'number') {
|
|
7454
|
+
dateObj = new Date(dateObj);
|
|
7455
|
+
}
|
|
7456
|
+
|
|
7457
|
+
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
|
7458
|
+
throw new Error('Invalid Date in fecha.format');
|
|
7459
|
+
}
|
|
7460
|
+
|
|
7461
|
+
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
7462
|
+
|
|
7463
|
+
var literals = [];
|
|
7464
|
+
|
|
7465
|
+
// Make literals inactive by replacing them with ??
|
|
7466
|
+
mask = mask.replace(literal, function ($0, $1) {
|
|
7467
|
+
literals.push($1);
|
|
7468
|
+
return '@@@';
|
|
7469
|
+
});
|
|
7470
|
+
// Apply formatting rules
|
|
7471
|
+
mask = mask.replace(token, function ($0) {
|
|
7472
|
+
return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
|
|
7473
|
+
});
|
|
7474
|
+
// Inline literal values back into the formatted value
|
|
7475
|
+
return mask.replace(/@@@/g, function () {
|
|
7476
|
+
return literals.shift();
|
|
7477
|
+
});
|
|
7478
|
+
};
|
|
7479
|
+
|
|
7656
7480
|
/**
|
|
7657
7481
|
* Parse a date string into an object, changes - into /
|
|
7658
7482
|
* @method parse
|
|
7659
7483
|
* @param {string} dateStr Date string
|
|
7660
7484
|
* @param {string} format Date parse format
|
|
7661
7485
|
* @returns {Date|boolean}
|
|
7662
|
-
*/
|
|
7663
|
-
fecha.parse = function (dateStr, format) {
|
|
7664
|
-
if (typeof format !== 'string') {
|
|
7665
|
-
throw new Error('Invalid format in fecha.parse');
|
|
7666
|
-
}
|
|
7667
|
-
|
|
7668
|
-
format = fecha.masks[format] || format;
|
|
7669
|
-
|
|
7670
|
-
// Avoid regular expression denial of service, fail early for really long strings
|
|
7671
|
-
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
|
7672
|
-
if (dateStr.length > 1000) {
|
|
7673
|
-
return null;
|
|
7674
|
-
}
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
format = format.replace(literal, function($0, $1) {
|
|
7680
|
-
literals.push($1);
|
|
7681
|
-
return '@@@';
|
|
7682
|
-
});
|
|
7683
|
-
|
|
7684
|
-
if (parseFlags[$0]) {
|
|
7685
|
-
|
|
7686
|
-
parseInfo.push(info[1]);
|
|
7687
|
-
return '(' + info[0] + ')';
|
|
7688
|
-
}
|
|
7689
|
-
|
|
7690
|
-
return $0;
|
|
7691
|
-
});
|
|
7692
|
-
newFormat = newFormat.replace(/@@@/g, function() {
|
|
7693
|
-
return literals.shift();
|
|
7694
|
-
});
|
|
7695
|
-
|
|
7696
|
-
if (!matches) {
|
|
7697
|
-
return null;
|
|
7698
|
-
}
|
|
7699
|
-
|
|
7700
|
-
for (
|
|
7701
|
-
parseInfo[i - 1](dateInfo, matches[i]);
|
|
7702
|
-
}
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
|
7706
|
-
dateInfo.hour = +dateInfo.hour + 12;
|
|
7707
|
-
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
|
7708
|
-
dateInfo.hour = 0;
|
|
7709
|
-
}
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
if (dateInfo.timezoneOffset != null) {
|
|
7713
|
-
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
7714
|
-
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
if (date
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
// 处理多种输入类型
|
|
7762
|
-
if (!date) return '';
|
|
7763
|
-
|
|
7764
|
-
// 如果是时间戳,转成日期对象
|
|
7765
|
-
if (typeof date === 'number') {
|
|
7766
|
-
date = new Date(date);
|
|
7767
|
-
}
|
|
7768
|
-
// 如果是字符串,转成日期对象
|
|
7769
|
-
if (typeof date === 'string') {
|
|
7770
|
-
date = new Date(date);
|
|
7771
|
-
}
|
|
7772
|
-
|
|
7773
|
-
// 调用toDate进一步验证和转换
|
|
7774
|
-
date = toDate(date);
|
|
7775
|
-
if (!date) return '';
|
|
7776
|
-
|
|
7777
|
-
// 兼容大写和小写的格式标记
|
|
7778
|
-
// 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
return
|
|
7800
|
-
}
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
//
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
|
|
7824
|
-
};
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
return prevDate(result,
|
|
7838
|
-
}
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
//
|
|
7858
|
-
|
|
7859
|
-
//
|
|
7860
|
-
|
|
7861
|
-
//
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
for (
|
|
7881
|
-
hours[i] =
|
|
7882
|
-
}
|
|
7883
|
-
}
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
}
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
};
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
}
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
return
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
};
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
return
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
};
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
return
|
|
8045
|
-
};
|
|
8046
|
-
|
|
7486
|
+
*/
|
|
7487
|
+
fecha.parse = function (dateStr, format) {
|
|
7488
|
+
if (typeof format !== 'string') {
|
|
7489
|
+
throw new Error('Invalid format in fecha.parse');
|
|
7490
|
+
}
|
|
7491
|
+
|
|
7492
|
+
format = fecha.masks[format] || format;
|
|
7493
|
+
|
|
7494
|
+
// Avoid regular expression denial of service, fail early for really long strings
|
|
7495
|
+
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
|
7496
|
+
if (dateStr.length > 1000) {
|
|
7497
|
+
return null;
|
|
7498
|
+
}
|
|
7499
|
+
|
|
7500
|
+
var dateInfo = {};
|
|
7501
|
+
var parseInfo = [];
|
|
7502
|
+
var literals = [];
|
|
7503
|
+
format = format.replace(literal, function ($0, $1) {
|
|
7504
|
+
literals.push($1);
|
|
7505
|
+
return '@@@';
|
|
7506
|
+
});
|
|
7507
|
+
var newFormat = regexEscape(format).replace(token, function ($0) {
|
|
7508
|
+
if (parseFlags[$0]) {
|
|
7509
|
+
var info = parseFlags[$0];
|
|
7510
|
+
parseInfo.push(info[1]);
|
|
7511
|
+
return '(' + info[0] + ')';
|
|
7512
|
+
}
|
|
7513
|
+
|
|
7514
|
+
return $0;
|
|
7515
|
+
});
|
|
7516
|
+
newFormat = newFormat.replace(/@@@/g, function () {
|
|
7517
|
+
return literals.shift();
|
|
7518
|
+
});
|
|
7519
|
+
var matches = dateStr.match(new RegExp(newFormat, 'i'));
|
|
7520
|
+
if (!matches) {
|
|
7521
|
+
return null;
|
|
7522
|
+
}
|
|
7523
|
+
|
|
7524
|
+
for (var i = 1; i < matches.length; i++) {
|
|
7525
|
+
parseInfo[i - 1](dateInfo, matches[i]);
|
|
7526
|
+
}
|
|
7527
|
+
|
|
7528
|
+
var today = new Date();
|
|
7529
|
+
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
|
7530
|
+
dateInfo.hour = +dateInfo.hour + 12;
|
|
7531
|
+
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
|
7532
|
+
dateInfo.hour = 0;
|
|
7533
|
+
}
|
|
7534
|
+
|
|
7535
|
+
var date = void 0;
|
|
7536
|
+
if (dateInfo.timezoneOffset != null) {
|
|
7537
|
+
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
7538
|
+
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
|
|
7539
|
+
} else {
|
|
7540
|
+
date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
|
|
7541
|
+
}
|
|
7542
|
+
return date;
|
|
7543
|
+
};
|
|
7544
|
+
|
|
7545
|
+
// 导出fecha对象
|
|
7546
|
+
|
|
7547
|
+
|
|
7548
|
+
// 以下是从date-util.js合并的函数
|
|
7549
|
+
var newArray = function newArray(start, end) {
|
|
7550
|
+
var result = [];
|
|
7551
|
+
for (var i = start; i <= end; i++) {
|
|
7552
|
+
result.push(i);
|
|
7553
|
+
}
|
|
7554
|
+
return result;
|
|
7555
|
+
};
|
|
7556
|
+
|
|
7557
|
+
var getSettings = function getSettings() {
|
|
7558
|
+
return {
|
|
7559
|
+
dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
|
|
7560
|
+
dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
|
7561
|
+
monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
|
7562
|
+
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
|
7563
|
+
amPm: ['上午', '下午']
|
|
7564
|
+
};
|
|
7565
|
+
};
|
|
7566
|
+
|
|
7567
|
+
var toDate = function toDate(date) {
|
|
7568
|
+
return isDate(date) ? new Date(date) : null;
|
|
7569
|
+
};
|
|
7570
|
+
|
|
7571
|
+
var isDate = function isDate(date) {
|
|
7572
|
+
if (date === null || date === undefined) return false;
|
|
7573
|
+
if (isNaN(new Date(date).getTime())) return false;
|
|
7574
|
+
if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
|
|
7575
|
+
return true;
|
|
7576
|
+
};
|
|
7577
|
+
|
|
7578
|
+
var isDateObject = function isDateObject(val) {
|
|
7579
|
+
return val instanceof Date;
|
|
7580
|
+
};
|
|
7581
|
+
|
|
7582
|
+
var formatDate = function formatDate(date) {
|
|
7583
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
|
|
7584
|
+
|
|
7585
|
+
// 处理多种输入类型
|
|
7586
|
+
if (!date) return '';
|
|
7587
|
+
|
|
7588
|
+
// 如果是时间戳,转成日期对象
|
|
7589
|
+
if (typeof date === 'number') {
|
|
7590
|
+
date = new Date(date);
|
|
7591
|
+
}
|
|
7592
|
+
// 如果是字符串,转成日期对象
|
|
7593
|
+
if (typeof date === 'string') {
|
|
7594
|
+
date = new Date(date);
|
|
7595
|
+
}
|
|
7596
|
+
|
|
7597
|
+
// 调用toDate进一步验证和转换
|
|
7598
|
+
date = toDate(date);
|
|
7599
|
+
if (!date) return '';
|
|
7600
|
+
|
|
7601
|
+
// 兼容大写和小写的格式标记
|
|
7602
|
+
// 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
|
|
7603
|
+
var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
|
|
7604
|
+
|
|
7605
|
+
// 使用fecha库进行格式化,支持中文配置
|
|
7606
|
+
var str = fecha.format(date, lowercaseFormat, getSettings());
|
|
7607
|
+
return str;
|
|
7608
|
+
};
|
|
7609
|
+
|
|
7610
|
+
var parseDate = function parseDate(string, format) {
|
|
7611
|
+
return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
|
|
7612
|
+
};
|
|
7613
|
+
|
|
7614
|
+
var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
|
|
7615
|
+
if (month === 3 || month === 5 || month === 8 || month === 10) {
|
|
7616
|
+
return 30;
|
|
7617
|
+
}
|
|
7618
|
+
|
|
7619
|
+
if (month === 1) {
|
|
7620
|
+
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
|
|
7621
|
+
return 29;
|
|
7622
|
+
} else {
|
|
7623
|
+
return 28;
|
|
7624
|
+
}
|
|
7625
|
+
}
|
|
7626
|
+
|
|
7627
|
+
return 31;
|
|
7628
|
+
};
|
|
7629
|
+
|
|
7630
|
+
var getDayCountOfYear = function getDayCountOfYear(year) {
|
|
7631
|
+
var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
|
|
7632
|
+
return isLeapYear ? 366 : 365;
|
|
7633
|
+
};
|
|
7634
|
+
|
|
7635
|
+
var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
|
|
7636
|
+
var temp = new Date(date.getTime());
|
|
7637
|
+
temp.setDate(1);
|
|
7638
|
+
return temp.getDay();
|
|
7639
|
+
};
|
|
7640
|
+
|
|
7641
|
+
// see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
|
|
7642
|
+
// {prev, next} Date should work for Daylight Saving Time
|
|
7643
|
+
// Adding 24 * 60 * 60 * 1000 does not work in the above scenario
|
|
7644
|
+
var prevDate = function prevDate(date) {
|
|
7645
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7646
|
+
|
|
7647
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
|
|
7648
|
+
};
|
|
7649
|
+
|
|
7650
|
+
var nextDate = function nextDate(date) {
|
|
7651
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7652
|
+
|
|
7653
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
|
|
7654
|
+
};
|
|
7655
|
+
|
|
7656
|
+
var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
|
|
7657
|
+
var result = new Date(year, month, 1);
|
|
7658
|
+
var day = result.getDay();
|
|
7659
|
+
|
|
7660
|
+
if (day === 0) {
|
|
7661
|
+
return prevDate(result, 7);
|
|
7662
|
+
} else {
|
|
7663
|
+
return prevDate(result, day);
|
|
7664
|
+
}
|
|
7665
|
+
};
|
|
7666
|
+
|
|
7667
|
+
var getWeekNumber = function getWeekNumber(date) {
|
|
7668
|
+
// 支持多种输入类型
|
|
7669
|
+
if (!date || !isDate(date)) {
|
|
7670
|
+
date = new Date();
|
|
7671
|
+
}
|
|
7672
|
+
if (typeof date === 'string') {
|
|
7673
|
+
date = new Date(date);
|
|
7674
|
+
}
|
|
7675
|
+
|
|
7676
|
+
// 验证日期有效性
|
|
7677
|
+
if (!isDate(date)) return null;
|
|
7678
|
+
|
|
7679
|
+
var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
7680
|
+
// 设置为最近的星期四:当前日期 + 4 - 当前星期数
|
|
7681
|
+
// 将星期日的星期数设为7
|
|
7682
|
+
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
|
|
7683
|
+
// 获取当年的第一天
|
|
7684
|
+
var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
7685
|
+
// 计算到最近的星期四的完整周数
|
|
7686
|
+
var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
|
|
7687
|
+
// 返回周数
|
|
7688
|
+
return weekNo;
|
|
7689
|
+
};
|
|
7690
|
+
|
|
7691
|
+
var getRangeHours = function getRangeHours(ranges) {
|
|
7692
|
+
var hours = [];
|
|
7693
|
+
var disabledHours = [];
|
|
7694
|
+
|
|
7695
|
+
(ranges || []).forEach(function (range) {
|
|
7696
|
+
var value = range.map(function (date) {
|
|
7697
|
+
return date.getHours();
|
|
7698
|
+
});
|
|
7699
|
+
|
|
7700
|
+
disabledHours = disabledHours.concat(newArray(value[0], value[1]));
|
|
7701
|
+
});
|
|
7702
|
+
|
|
7703
|
+
if (disabledHours.length) {
|
|
7704
|
+
for (var i = 0; i < 24; i++) {
|
|
7705
|
+
hours[i] = disabledHours.indexOf(i) === -1;
|
|
7706
|
+
}
|
|
7707
|
+
} else {
|
|
7708
|
+
for (var _i = 0; _i < 24; _i++) {
|
|
7709
|
+
hours[_i] = false;
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7712
|
+
|
|
7713
|
+
return hours;
|
|
7714
|
+
};
|
|
7715
|
+
|
|
7716
|
+
var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
|
|
7717
|
+
if (amount <= 0) return [];
|
|
7718
|
+
var temp = new Date(date.getTime());
|
|
7719
|
+
temp.setDate(0);
|
|
7720
|
+
var lastDay = temp.getDate();
|
|
7721
|
+
return range(amount).map(function (_, index) {
|
|
7722
|
+
return lastDay - (amount - index - 1);
|
|
7723
|
+
});
|
|
7724
|
+
};
|
|
7725
|
+
|
|
7726
|
+
var getMonthDays = function getMonthDays(date) {
|
|
7727
|
+
var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
7728
|
+
var days = temp.getDate();
|
|
7729
|
+
return range(days).map(function (_, index) {
|
|
7730
|
+
return index + 1;
|
|
7731
|
+
});
|
|
7732
|
+
};
|
|
7733
|
+
|
|
7734
|
+
function setRangeData(arr, start, end, value) {
|
|
7735
|
+
for (var i = start; i < end; i++) {
|
|
7736
|
+
arr[i] = value;
|
|
7737
|
+
}
|
|
7738
|
+
}
|
|
7739
|
+
|
|
7740
|
+
var getRangeMinutes = function getRangeMinutes(ranges, hour) {
|
|
7741
|
+
var minutes = new Array(60);
|
|
7742
|
+
|
|
7743
|
+
if (ranges.length > 0) {
|
|
7744
|
+
ranges.forEach(function (range) {
|
|
7745
|
+
var start = range[0];
|
|
7746
|
+
var end = range[1];
|
|
7747
|
+
var startHour = start.getHours();
|
|
7748
|
+
var startMinute = start.getMinutes();
|
|
7749
|
+
var endHour = end.getHours();
|
|
7750
|
+
var endMinute = end.getMinutes();
|
|
7751
|
+
if (startHour === hour && endHour !== hour) {
|
|
7752
|
+
setRangeData(minutes, startMinute, 60, true);
|
|
7753
|
+
} else if (startHour === hour && endHour === hour) {
|
|
7754
|
+
setRangeData(minutes, startMinute, endMinute + 1, true);
|
|
7755
|
+
} else if (startHour !== hour && endHour === hour) {
|
|
7756
|
+
setRangeData(minutes, 0, endMinute + 1, true);
|
|
7757
|
+
} else if (startHour < hour && endHour > hour) {
|
|
7758
|
+
setRangeData(minutes, 0, 60, true);
|
|
7759
|
+
}
|
|
7760
|
+
});
|
|
7761
|
+
} else {
|
|
7762
|
+
setRangeData(minutes, 0, 60, true);
|
|
7763
|
+
}
|
|
7764
|
+
return minutes;
|
|
7765
|
+
};
|
|
7766
|
+
|
|
7767
|
+
var range = function range(n) {
|
|
7768
|
+
// see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
|
|
7769
|
+
return Array.apply(null, { length: n }).map(function (_, n) {
|
|
7770
|
+
return n;
|
|
7771
|
+
});
|
|
7772
|
+
};
|
|
7773
|
+
|
|
7774
|
+
var modifyDate = function modifyDate(date, y, m, d) {
|
|
7775
|
+
return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
7776
|
+
};
|
|
7777
|
+
|
|
7778
|
+
var modifyTime = function modifyTime(date, h, m, s) {
|
|
7779
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
|
|
7780
|
+
};
|
|
7781
|
+
|
|
7782
|
+
var modifyWithTimeString = function modifyWithTimeString(date, time) {
|
|
7783
|
+
if (date == null || !time) {
|
|
7784
|
+
return date;
|
|
7785
|
+
}
|
|
7786
|
+
time = parseDate(time, 'HH:mm:ss');
|
|
7787
|
+
return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
|
|
7788
|
+
};
|
|
7789
|
+
|
|
7790
|
+
var clearTime = function clearTime(date) {
|
|
7791
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
7792
|
+
};
|
|
7793
|
+
|
|
7794
|
+
var clearMilliseconds = function clearMilliseconds(date) {
|
|
7795
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
|
|
7796
|
+
};
|
|
7797
|
+
|
|
7798
|
+
var limitTimeRange = function limitTimeRange(date, ranges) {
|
|
7799
|
+
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
|
|
7800
|
+
|
|
7801
|
+
// TODO: refactory a more elegant solution
|
|
7802
|
+
if (ranges.length === 0) return date;
|
|
7803
|
+
var normalizeDate = function normalizeDate(date) {
|
|
7804
|
+
return fecha.parse(fecha.format(date, format), format);
|
|
7805
|
+
};
|
|
7806
|
+
var ndate = normalizeDate(date);
|
|
7807
|
+
var nranges = ranges.map(function (range) {
|
|
7808
|
+
return range.map(normalizeDate);
|
|
7809
|
+
});
|
|
7810
|
+
if (nranges.some(function (nrange) {
|
|
7811
|
+
return ndate >= nrange[0] && ndate <= nrange[1];
|
|
7812
|
+
})) return date;
|
|
7813
|
+
|
|
7814
|
+
var minDate = nranges[0][0];
|
|
7815
|
+
var maxDate = nranges[0][0];
|
|
7816
|
+
|
|
7817
|
+
nranges.forEach(function (nrange) {
|
|
7818
|
+
minDate = new Date(Math.min(nrange[0], minDate));
|
|
7819
|
+
maxDate = new Date(Math.max(nrange[1], minDate));
|
|
7820
|
+
});
|
|
7821
|
+
|
|
7822
|
+
var ret = ndate < minDate ? minDate : maxDate;
|
|
7823
|
+
// preserve Year/Month/Date
|
|
7824
|
+
return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
|
|
7825
|
+
};
|
|
7826
|
+
|
|
7827
|
+
var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
|
|
7828
|
+
var limitedDate = limitTimeRange(date, selectableRange, format);
|
|
7829
|
+
return limitedDate.getTime() === date.getTime();
|
|
7830
|
+
};
|
|
7831
|
+
|
|
7832
|
+
var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
|
|
7833
|
+
// clamp date to the number of days in `year`, `month`
|
|
7834
|
+
// eg: (2010-1-31, 2010, 2) => 2010-2-28
|
|
7835
|
+
var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
|
|
7836
|
+
return modifyDate(date, year, month, monthDate);
|
|
7837
|
+
};
|
|
7838
|
+
|
|
7839
|
+
var prevMonth = function prevMonth(date) {
|
|
7840
|
+
var year = date.getFullYear();
|
|
7841
|
+
var month = date.getMonth();
|
|
7842
|
+
return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
|
|
7843
|
+
};
|
|
7844
|
+
|
|
7845
|
+
var nextMonth = function nextMonth(date) {
|
|
7846
|
+
var year = date.getFullYear();
|
|
7847
|
+
var month = date.getMonth();
|
|
7848
|
+
return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
|
|
7849
|
+
};
|
|
7850
|
+
|
|
7851
|
+
var prevYear = function prevYear(date) {
|
|
7852
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7853
|
+
|
|
7854
|
+
var year = date.getFullYear();
|
|
7855
|
+
var month = date.getMonth();
|
|
7856
|
+
return changeYearMonthAndClampDate(date, year - amount, month);
|
|
7857
|
+
};
|
|
7858
|
+
|
|
7859
|
+
var nextYear = function nextYear(date) {
|
|
7860
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7861
|
+
|
|
7862
|
+
var year = date.getFullYear();
|
|
7863
|
+
var month = date.getMonth();
|
|
7864
|
+
return changeYearMonthAndClampDate(date, year + amount, month);
|
|
7865
|
+
};
|
|
7866
|
+
|
|
7867
|
+
var extractDateFormat = function extractDateFormat(format) {
|
|
7868
|
+
return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
|
|
7869
|
+
};
|
|
7870
|
+
|
|
7871
|
+
var extractTimeFormat = function extractTimeFormat(format) {
|
|
7872
|
+
return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
|
|
7873
|
+
};
|
|
7874
|
+
|
|
7875
|
+
var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
|
|
7876
|
+
return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
|
|
7877
|
+
};
|
|
7878
|
+
|
|
8047
7879
|
/**
|
|
8048
7880
|
* 计算两个日期之间的工作日数量(不包括周末和节假日)
|
|
8049
7881
|
* @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
|
|
8050
7882
|
* @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
|
|
8051
7883
|
* @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
|
|
8052
7884
|
* @returns {number} 工作日数量
|
|
8053
|
-
*/
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
);
|
|
8059
|
-
}
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
8065
|
-
throw new Error(
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
}
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
7885
|
+
*/
|
|
7886
|
+
var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
|
|
7887
|
+
var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
7888
|
+
|
|
7889
|
+
if (typeof start_date !== 'string' || typeof end_date !== 'string') {
|
|
7890
|
+
throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
|
|
7891
|
+
}
|
|
7892
|
+
|
|
7893
|
+
var startDateObj = new Date(start_date);
|
|
7894
|
+
var endDateObj = new Date(end_date);
|
|
7895
|
+
|
|
7896
|
+
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
7897
|
+
throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
|
|
7898
|
+
}
|
|
7899
|
+
|
|
7900
|
+
if (startDateObj > endDateObj) {
|
|
7901
|
+
throw new Error('Start date should be earlier than or equal to end date.');
|
|
7902
|
+
}
|
|
7903
|
+
|
|
7904
|
+
var workdays = 0;
|
|
7905
|
+
|
|
7906
|
+
// Iterate through each day in the date range
|
|
7907
|
+
|
|
7908
|
+
var _loop = function _loop(currentDate) {
|
|
7909
|
+
// Check if the current day is a weekend (Saturday or Sunday)
|
|
7910
|
+
var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
|
|
7911
|
+
|
|
7912
|
+
// Check if the current day is a holiday
|
|
7913
|
+
var isHoliday = holidays.some(function (holiday) {
|
|
7914
|
+
var holidayDate = new Date(holiday);
|
|
7915
|
+
return currentDate.toDateString() === holidayDate.toDateString();
|
|
7916
|
+
});
|
|
7917
|
+
|
|
7918
|
+
// If it's a workday (not a weekend or holiday), increment the workdays count
|
|
7919
|
+
if (!isWeekend && !isHoliday) {
|
|
7920
|
+
workdays++;
|
|
7921
|
+
}
|
|
7922
|
+
};
|
|
7923
|
+
|
|
7924
|
+
for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
|
|
7925
|
+
_loop(currentDate);
|
|
7926
|
+
}
|
|
7927
|
+
|
|
7928
|
+
return workdays;
|
|
7929
|
+
};
|
|
7930
|
+
|
|
8100
7931
|
/**
|
|
8101
7932
|
* 日期加减天数
|
|
8102
7933
|
* @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
|
|
8103
7934
|
* @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
|
|
8104
7935
|
* @returns {string} 结果日期,格式为 "YYYY-MM-DD"
|
|
8105
|
-
*/
|
|
8106
|
-
|
|
8107
|
-
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
8108
|
-
throw new Error(
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
return `${resultYear}-${resultMonth}-${resultDay}`;
|
|
8128
|
-
};
|
|
8129
|
-
|
|
7936
|
+
*/
|
|
7937
|
+
var dateAddDays = function dateAddDays(start_date, days) {
|
|
7938
|
+
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
7939
|
+
throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days.");
|
|
7940
|
+
}
|
|
7941
|
+
|
|
7942
|
+
var startDateObj = new Date(start_date);
|
|
7943
|
+
if (isNaN(startDateObj.getTime())) {
|
|
7944
|
+
throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
|
|
7945
|
+
}
|
|
7946
|
+
|
|
7947
|
+
var resultDateObj = new Date(startDateObj);
|
|
7948
|
+
resultDateObj.setDate(resultDateObj.getDate() + days);
|
|
7949
|
+
|
|
7950
|
+
var resultYear = resultDateObj.getFullYear();
|
|
7951
|
+
var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
|
|
7952
|
+
var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
|
|
7953
|
+
|
|
7954
|
+
return resultYear + '-' + resultMonth + '-' + resultDay;
|
|
7955
|
+
};
|
|
7956
|
+
|
|
8130
7957
|
/**
|
|
8131
7958
|
* 计算两个日期之间的差值
|
|
8132
7959
|
* @date 2023年12月14日
|
|
@@ -8134,182 +7961,180 @@ const dateAddDays = function (start_date, days) {
|
|
|
8134
7961
|
* @param {String} end_date - 结束日期字符串
|
|
8135
7962
|
* @param {String} unit - 单位:year/month/day
|
|
8136
7963
|
* @returns {Number} 差值
|
|
8137
|
-
*/
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
return (
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
7964
|
+
*/
|
|
7965
|
+
var dateDiff = function dateDiff(start_date, end_date) {
|
|
7966
|
+
var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
|
|
7967
|
+
|
|
7968
|
+
// Assuming date strings are in "YYYY-MM-DD" format
|
|
7969
|
+
var startDate = new Date(start_date);
|
|
7970
|
+
var endDate = new Date(end_date);
|
|
7971
|
+
|
|
7972
|
+
// If the date is invalid, return 0
|
|
7973
|
+
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
|
7974
|
+
return 0;
|
|
7975
|
+
}
|
|
7976
|
+
|
|
7977
|
+
if (unit === 'year') {
|
|
7978
|
+
return endDate.getFullYear() - startDate.getFullYear();
|
|
7979
|
+
} else if (unit === 'month') {
|
|
7980
|
+
return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
|
|
7981
|
+
} else {
|
|
7982
|
+
// Default to day
|
|
7983
|
+
var timeDifference = endDate - startDate;
|
|
7984
|
+
// Calculate days (86400000 milliseconds per day)
|
|
7985
|
+
return Math.floor(timeDifference / 86400000);
|
|
7986
|
+
}
|
|
7987
|
+
};
|
|
7988
|
+
|
|
8163
7989
|
/**
|
|
8164
7990
|
* 获取月份中的日期
|
|
8165
7991
|
* @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
|
|
8166
7992
|
* @returns {number} 月份中的日期(1-31)
|
|
8167
|
-
*/
|
|
8168
|
-
|
|
8169
|
-
if (typeof date !== 'string') {
|
|
8170
|
-
throw new Error(
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
return dateObj.getDate();
|
|
8183
|
-
};
|
|
8184
|
-
|
|
7993
|
+
*/
|
|
7994
|
+
var dayOfMonth = function dayOfMonth(date) {
|
|
7995
|
+
if (typeof date !== 'string') {
|
|
7996
|
+
throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
|
|
7997
|
+
}
|
|
7998
|
+
|
|
7999
|
+
var dateObj = new Date(date);
|
|
8000
|
+
if (isNaN(dateObj.getTime())) {
|
|
8001
|
+
throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
|
|
8002
|
+
}
|
|
8003
|
+
|
|
8004
|
+
return dateObj.getDate();
|
|
8005
|
+
};
|
|
8006
|
+
|
|
8185
8007
|
/**
|
|
8186
8008
|
* 获取当前日期
|
|
8187
8009
|
* @date 2022年5月7日
|
|
8188
8010
|
* @param {string} format - 日期格式,默认为'YYYY-MM-DD'
|
|
8189
8011
|
* @returns {string} 当前日期的格式化字符串
|
|
8190
|
-
*/
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8012
|
+
*/
|
|
8013
|
+
var getCurrentDate = function getCurrentDate() {
|
|
8014
|
+
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
|
|
8015
|
+
|
|
8016
|
+
return formatDate(new Date(), format);
|
|
8017
|
+
};
|
|
8018
|
+
|
|
8195
8019
|
/**
|
|
8196
8020
|
* 获取当前日期时间
|
|
8197
8021
|
* @date 2022年5月7日
|
|
8198
8022
|
* @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
|
|
8199
8023
|
* @returns {string} 当前日期时间的格式化字符串
|
|
8200
|
-
*/
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8024
|
+
*/
|
|
8025
|
+
var getCurrentDateTime = function getCurrentDateTime() {
|
|
8026
|
+
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
|
|
8027
|
+
|
|
8028
|
+
return formatDate(new Date(), format);
|
|
8029
|
+
};
|
|
8030
|
+
|
|
8205
8031
|
/**
|
|
8206
8032
|
* 获取小时
|
|
8207
8033
|
* @date 2022年5月7日
|
|
8208
8034
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
8209
8035
|
* @returns {number} 小时数(0-23)
|
|
8210
|
-
*/
|
|
8211
|
-
|
|
8212
|
-
if (!date) {
|
|
8213
|
-
return new Date().getHours();
|
|
8214
|
-
}
|
|
8215
|
-
if (typeof date === 'string') {
|
|
8216
|
-
date = new Date(date);
|
|
8217
|
-
}
|
|
8218
|
-
return date.getHours();
|
|
8219
|
-
};
|
|
8220
|
-
|
|
8036
|
+
*/
|
|
8037
|
+
var getHour = function getHour(date) {
|
|
8038
|
+
if (!date) {
|
|
8039
|
+
return new Date().getHours();
|
|
8040
|
+
}
|
|
8041
|
+
if (typeof date === 'string') {
|
|
8042
|
+
date = new Date(date);
|
|
8043
|
+
}
|
|
8044
|
+
return date.getHours();
|
|
8045
|
+
};
|
|
8046
|
+
|
|
8221
8047
|
/**
|
|
8222
8048
|
* 获取分钟
|
|
8223
8049
|
* @date 2022年5月7日
|
|
8224
8050
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
8225
8051
|
* @returns {number} 分钟数(0-59)
|
|
8226
|
-
*/
|
|
8227
|
-
|
|
8228
|
-
if (!date) {
|
|
8229
|
-
return new Date().getMinutes();
|
|
8230
|
-
}
|
|
8231
|
-
if (typeof date === 'string') {
|
|
8232
|
-
date = new Date(date);
|
|
8233
|
-
}
|
|
8234
|
-
return date.getMinutes();
|
|
8235
|
-
};
|
|
8236
|
-
|
|
8052
|
+
*/
|
|
8053
|
+
var getMinute = function getMinute(date) {
|
|
8054
|
+
if (!date) {
|
|
8055
|
+
return new Date().getMinutes();
|
|
8056
|
+
}
|
|
8057
|
+
if (typeof date === 'string') {
|
|
8058
|
+
date = new Date(date);
|
|
8059
|
+
}
|
|
8060
|
+
return date.getMinutes();
|
|
8061
|
+
};
|
|
8062
|
+
|
|
8237
8063
|
/**
|
|
8238
8064
|
* 获取月份
|
|
8239
8065
|
* @date 2022年5月7日
|
|
8240
8066
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
8241
8067
|
* @returns {number} 月份数(1-12)
|
|
8242
|
-
*/
|
|
8243
|
-
|
|
8244
|
-
if (!date) {
|
|
8245
|
-
return new Date().getMonth() + 1;
|
|
8246
|
-
}
|
|
8247
|
-
if (typeof date === 'string') {
|
|
8248
|
-
date = new Date(date);
|
|
8249
|
-
}
|
|
8250
|
-
return date.getMonth() + 1;
|
|
8251
|
-
};
|
|
8252
|
-
|
|
8068
|
+
*/
|
|
8069
|
+
var getMonth = function getMonth(date) {
|
|
8070
|
+
if (!date) {
|
|
8071
|
+
return new Date().getMonth() + 1;
|
|
8072
|
+
}
|
|
8073
|
+
if (typeof date === 'string') {
|
|
8074
|
+
date = new Date(date);
|
|
8075
|
+
}
|
|
8076
|
+
return date.getMonth() + 1;
|
|
8077
|
+
};
|
|
8078
|
+
|
|
8253
8079
|
/**
|
|
8254
8080
|
* 获取秒
|
|
8255
8081
|
* @date 2022年5月7日
|
|
8256
8082
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
8257
8083
|
* @returns {number} 秒数(0-59)
|
|
8258
|
-
*/
|
|
8259
|
-
|
|
8260
|
-
if (!date) {
|
|
8261
|
-
return new Date().getSeconds();
|
|
8262
|
-
}
|
|
8263
|
-
if (typeof date === 'string') {
|
|
8264
|
-
date = new Date(date);
|
|
8265
|
-
}
|
|
8266
|
-
return date.getSeconds();
|
|
8267
|
-
};
|
|
8268
|
-
|
|
8084
|
+
*/
|
|
8085
|
+
var getSecond = function getSecond(date) {
|
|
8086
|
+
if (!date) {
|
|
8087
|
+
return new Date().getSeconds();
|
|
8088
|
+
}
|
|
8089
|
+
if (typeof date === 'string') {
|
|
8090
|
+
date = new Date(date);
|
|
8091
|
+
}
|
|
8092
|
+
return date.getSeconds();
|
|
8093
|
+
};
|
|
8094
|
+
|
|
8269
8095
|
/**
|
|
8270
8096
|
* 获取星期几
|
|
8271
8097
|
* @date 2022年5月7日
|
|
8272
8098
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
8273
8099
|
* @returns {number} 星期几(0-6,0表示星期日)
|
|
8274
|
-
*/
|
|
8275
|
-
|
|
8276
|
-
if (!date) {
|
|
8277
|
-
return new Date().getDay();
|
|
8278
|
-
}
|
|
8279
|
-
if (typeof date === 'string') {
|
|
8280
|
-
date = new Date(date);
|
|
8281
|
-
}
|
|
8282
|
-
return date.getDay();
|
|
8283
|
-
};
|
|
8284
|
-
|
|
8285
|
-
|
|
8100
|
+
*/
|
|
8101
|
+
var getWeekday = function getWeekday(date) {
|
|
8102
|
+
if (!date) {
|
|
8103
|
+
return new Date().getDay();
|
|
8104
|
+
}
|
|
8105
|
+
if (typeof date === 'string') {
|
|
8106
|
+
date = new Date(date);
|
|
8107
|
+
}
|
|
8108
|
+
return date.getDay();
|
|
8109
|
+
};
|
|
8110
|
+
|
|
8286
8111
|
/**
|
|
8287
8112
|
* @desc 获取上午/下午/晚上
|
|
8288
8113
|
* @author huangbo
|
|
8289
8114
|
* @date 2022年5月7日
|
|
8290
8115
|
* @param {String} [time] - 时间
|
|
8291
|
-
**/
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
if (!time) {
|
|
8295
|
-
hour = new Date().getHours();
|
|
8296
|
-
} else if (typeof time === 'string') {
|
|
8297
|
-
// 从时间字符串中提取小时
|
|
8298
|
-
|
|
8299
|
-
if (match) {
|
|
8300
|
-
hour = parseInt(match[1], 10);
|
|
8301
|
-
}
|
|
8302
|
-
} else if (typeof time === 'number') {
|
|
8303
|
-
hour = time;
|
|
8304
|
-
}
|
|
8305
|
-
// 判断时间段
|
|
8306
|
-
if (hour >= 5 && hour < 12) {
|
|
8307
|
-
return '上午';
|
|
8308
|
-
} else if (hour >= 12 && hour < 18) {
|
|
8309
|
-
return '下午';
|
|
8310
|
-
} else {
|
|
8311
|
-
return '晚上';
|
|
8312
|
-
}
|
|
8116
|
+
**/
|
|
8117
|
+
var timeCycle = function timeCycle(time) {
|
|
8118
|
+
var hour = 0;
|
|
8119
|
+
if (!time) {
|
|
8120
|
+
hour = new Date().getHours();
|
|
8121
|
+
} else if (typeof time === 'string') {
|
|
8122
|
+
// 从时间字符串中提取小时
|
|
8123
|
+
var match = time.match(/^(\d{1,2})/);
|
|
8124
|
+
if (match) {
|
|
8125
|
+
hour = parseInt(match[1], 10);
|
|
8126
|
+
}
|
|
8127
|
+
} else if (typeof time === 'number') {
|
|
8128
|
+
hour = time;
|
|
8129
|
+
}
|
|
8130
|
+
// 判断时间段
|
|
8131
|
+
if (hour >= 5 && hour < 12) {
|
|
8132
|
+
return '上午';
|
|
8133
|
+
} else if (hour >= 12 && hour < 18) {
|
|
8134
|
+
return '下午';
|
|
8135
|
+
} else {
|
|
8136
|
+
return '晚上';
|
|
8137
|
+
}
|
|
8313
8138
|
};
|
|
8314
8139
|
|
|
8315
8140
|
/***/ }),
|
|
@@ -8321,7 +8146,7 @@ module.exports = require("eoss/lib/message-box");
|
|
|
8321
8146
|
|
|
8322
8147
|
/***/ }),
|
|
8323
8148
|
|
|
8324
|
-
/***/
|
|
8149
|
+
/***/ 86:
|
|
8325
8150
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
8326
8151
|
|
|
8327
8152
|
"use strict";
|