@zkwq/business 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -0
- package/dist/index.js +21861 -0
- package/dist/index.umd.cjs +46 -0
- package/package.json +27 -0
- package/src/components/base/ui/alert/Alert.vue +94 -0
- package/src/components/base/ui/autocomplete/autocomplete-suggestions.vue +77 -0
- package/src/components/base/ui/autocomplete/autocomplete.vue +305 -0
- package/src/components/base/ui/backtop/main.vue +112 -0
- package/src/components/base/ui/button/Button.vue +84 -0
- package/src/components/base/ui/button/ButtonGroup.vue +10 -0
- package/src/components/base/ui/carousel/Carousel.vue +304 -0
- package/src/components/base/ui/carousel/CarouselItem.vue +137 -0
- package/src/components/base/ui/cascader/cascader.vue +650 -0
- package/src/components/base/ui/cascader-panel/cascader-menu.vue +138 -0
- package/src/components/base/ui/cascader-panel/cascader-node.vue +246 -0
- package/src/components/base/ui/cascader-panel/cascader-panel.vue +382 -0
- package/src/components/base/ui/cascader-panel/node.js +166 -0
- package/src/components/base/ui/cascader-panel/store.js +62 -0
- package/src/components/base/ui/checkbox/checkbox-button.vue +199 -0
- package/src/components/base/ui/checkbox/checkbox-group.vue +48 -0
- package/src/components/base/ui/checkbox/checkbox.vue +222 -0
- package/src/components/base/ui/col/col.js +71 -0
- package/src/components/base/ui/collapse/collapse-item.vue +180 -0
- package/src/components/base/ui/collapse/collapse.vue +73 -0
- package/src/components/base/ui/color-picker/color.js +317 -0
- package/src/components/base/ui/color-picker/components/alpha-slider.vue +132 -0
- package/src/components/base/ui/color-picker/components/hue-slider.vue +123 -0
- package/src/components/base/ui/color-picker/components/picker-dropdown.vue +119 -0
- package/src/components/base/ui/color-picker/components/predefine.vue +61 -0
- package/src/components/base/ui/color-picker/components/sv-panel.vue +100 -0
- package/src/components/base/ui/color-picker/draggable.js +36 -0
- package/src/components/base/ui/color-picker/index.js +2 -0
- package/src/components/base/ui/color-picker/main.vue +188 -0
- package/src/components/base/ui/date-picker/basic/date-table.vue +441 -0
- package/src/components/base/ui/date-picker/basic/month-table.vue +254 -0
- package/src/components/base/ui/date-picker/basic/time-spinner.vue +304 -0
- package/src/components/base/ui/date-picker/basic/year-table.vue +101 -0
- package/src/components/base/ui/date-picker/panel/date-range.vue +680 -0
- package/src/components/base/ui/date-picker/panel/date.vue +597 -0
- package/src/components/base/ui/date-picker/panel/month-range.vue +289 -0
- package/src/components/base/ui/date-picker/panel/time-range.vue +248 -0
- package/src/components/base/ui/date-picker/panel/time-select.vue +178 -0
- package/src/components/base/ui/date-picker/panel/time.vue +186 -0
- package/src/components/base/ui/date-picker/picker/date-picker.js +43 -0
- package/src/components/base/ui/date-picker/picker/time-picker.js +39 -0
- package/src/components/base/ui/date-picker/picker/time-select.js +21 -0
- package/src/components/base/ui/date-picker/picker.vue +942 -0
- package/src/components/base/ui/dialog/Index.vue +212 -0
- package/src/components/base/ui/directive/repeat-click.js +24 -0
- package/src/components/base/ui/directive/ripple.js +303 -0
- package/src/components/base/ui/divider/Divider.vue +37 -0
- package/src/components/base/ui/drawer/Drawer.vue +202 -0
- package/src/components/base/ui/dropdown/dropdown-item.vue +39 -0
- package/src/components/base/ui/dropdown/dropdown-menu.vue +63 -0
- package/src/components/base/ui/dropdown/dropdown.vue +308 -0
- package/src/components/base/ui/form/Form.vue +167 -0
- package/src/components/base/ui/form/FormItem.vue +334 -0
- package/src/components/base/ui/form/LabelWrap.vue +69 -0
- package/src/components/base/ui/icon/icon.vue +13 -0
- package/src/components/base/ui/image/image-viewer.vue +302 -0
- package/src/components/base/ui/image/main.vue +248 -0
- package/src/components/base/ui/index.js +189 -0
- package/src/components/base/ui/input/Input.vue +438 -0
- package/src/components/base/ui/input/calcTextareaHeight.js +104 -0
- package/src/components/base/ui/input-number/input-number.vue +285 -0
- package/src/components/base/ui/locale/format.js +32 -0
- package/src/components/base/ui/locale/index.js +48 -0
- package/src/components/base/ui/locale/lang/zh-CN.js +120 -0
- package/src/components/base/ui/menu/menu-item-group.vue +45 -0
- package/src/components/base/ui/menu/menu-item.vue +112 -0
- package/src/components/base/ui/menu/menu-mixin.js +44 -0
- package/src/components/base/ui/menu/menu.vue +312 -0
- package/src/components/base/ui/menu/submenu.vue +408 -0
- package/src/components/base/ui/message/index.js +2 -0
- package/src/components/base/ui/message/main.js +87 -0
- package/src/components/base/ui/message/main.vue +110 -0
- package/src/components/base/ui/message-box/main.js +216 -0
- package/src/components/base/ui/message-box/main.vue +323 -0
- package/src/components/base/ui/mixin/emitter.js +31 -0
- package/src/components/base/ui/mixin/focus.js +9 -0
- package/src/components/base/ui/mixin/locale.js +9 -0
- package/src/components/base/ui/mixin/migrating.js +33 -0
- package/src/components/base/ui/pagination/pager.vue +163 -0
- package/src/components/base/ui/pagination/pagination.jsx +391 -0
- package/src/components/base/ui/popover/directive.js +20 -0
- package/src/components/base/ui/popover/index.js +14 -0
- package/src/components/base/ui/popover/main.vue +236 -0
- package/src/components/base/ui/progress/Progress.vue +227 -0
- package/src/components/base/ui/radio/radio-button.vue +114 -0
- package/src/components/base/ui/radio/radio-group.vue +111 -0
- package/src/components/base/ui/radio/radio.vue +134 -0
- package/src/components/base/ui/row/row.js +47 -0
- package/src/components/base/ui/scrollbar/bar.jsx +91 -0
- package/src/components/base/ui/scrollbar/index.jsx +203 -0
- package/src/components/base/ui/scrollbar/util.js +32 -0
- package/src/components/base/ui/select/Option.vue +168 -0
- package/src/components/base/ui/select/OptionGroup.vue +60 -0
- package/src/components/base/ui/select/Select.vue +920 -0
- package/src/components/base/ui/select/SelectDropdown.vue +74 -0
- package/src/components/base/ui/select/navigation-mixin.js +54 -0
- package/src/components/base/ui/skeleton/index.js +8 -0
- package/src/components/base/ui/skeleton/src/img-placeholder.vue +16 -0
- package/src/components/base/ui/skeleton/src/index.vue +80 -0
- package/src/components/base/ui/skeleton/src/item.vue +22 -0
- package/src/components/base/ui/skeleton-item/index.js +8 -0
- package/src/components/base/ui/slider/button.vue +238 -0
- package/src/components/base/ui/slider/main.vue +427 -0
- package/src/components/base/ui/slider/marker.js +18 -0
- package/src/components/base/ui/style/alert.scss +147 -0
- package/src/components/base/ui/style/animations.scss +65 -0
- package/src/components/base/ui/style/autocomplete.scss +81 -0
- package/src/components/base/ui/style/backtop.scss +20 -0
- package/src/components/base/ui/style/button-group.scss +0 -0
- package/src/components/base/ui/style/button.scss +380 -0
- package/src/components/base/ui/style/carousel-item.scss +50 -0
- package/src/components/base/ui/style/carousel.scss +161 -0
- package/src/components/base/ui/style/cascader-panel.scss +120 -0
- package/src/components/base/ui/style/cascader.scss +185 -0
- package/src/components/base/ui/style/checkbox-button.scss +0 -0
- package/src/components/base/ui/style/checkbox-group.scss +0 -0
- package/src/components/base/ui/style/checkbox.scss +360 -0
- package/src/components/base/ui/style/col.scss +156 -0
- package/src/components/base/ui/style/collapse-item.scss +0 -0
- package/src/components/base/ui/style/collapse.scss +114 -0
- package/src/components/base/ui/style/color-picker.scss +387 -0
- package/src/components/base/ui/style/config.scss +4 -0
- package/src/components/base/ui/style/date-picker/date-picker.scss +97 -0
- package/src/components/base/ui/style/date-picker/date-range-picker.scss +101 -0
- package/src/components/base/ui/style/date-picker/date-table.scss +151 -0
- package/src/components/base/ui/style/date-picker/month-table.scss +82 -0
- package/src/components/base/ui/style/date-picker/picker-panel.scss +117 -0
- package/src/components/base/ui/style/date-picker/picker.scss +197 -0
- package/src/components/base/ui/style/date-picker/time-picker.scss +85 -0
- package/src/components/base/ui/style/date-picker/time-range-picker.scss +31 -0
- package/src/components/base/ui/style/date-picker/time-spinner.scss +110 -0
- package/src/components/base/ui/style/date-picker/year-table.scss +51 -0
- package/src/components/base/ui/style/date-picker.scss +12 -0
- package/src/components/base/ui/style/dialog.scss +123 -0
- package/src/components/base/ui/style/divider.scss +47 -0
- package/src/components/base/ui/style/drawer.scss +218 -0
- package/src/components/base/ui/style/dropdown-item.scss +0 -0
- package/src/components/base/ui/style/dropdown-menu.scss +0 -0
- package/src/components/base/ui/style/dropdown.scss +185 -0
- package/src/components/base/ui/style/form-item.scss +0 -0
- package/src/components/base/ui/style/form.scss +203 -0
- package/src/components/base/ui/style/function.scss +43 -0
- package/src/components/base/ui/style/icon.scss +1167 -0
- package/src/components/base/ui/style/image.scss +184 -0
- package/src/components/base/ui/style/index.scss +57 -0
- package/src/components/base/ui/style/input-number.scss +187 -0
- package/src/components/base/ui/style/input.scss +477 -0
- package/src/components/base/ui/style/menu-item-group.scss +0 -0
- package/src/components/base/ui/style/menu-item.scss +0 -0
- package/src/components/base/ui/style/menu.scss +294 -0
- package/src/components/base/ui/style/message-box.scss +231 -0
- package/src/components/base/ui/style/message.scss +120 -0
- package/src/components/base/ui/style/mixins.scss +196 -0
- package/src/components/base/ui/style/option-group.scss +42 -0
- package/src/components/base/ui/style/option.scss +36 -0
- package/src/components/base/ui/style/pagination.scss +295 -0
- package/src/components/base/ui/style/popover.scss +40 -0
- package/src/components/base/ui/style/popper.scss +102 -0
- package/src/components/base/ui/style/popup.scss +42 -0
- package/src/components/base/ui/style/progress.scss +141 -0
- package/src/components/base/ui/style/radio-button.scss +113 -0
- package/src/components/base/ui/style/radio-group.scss +9 -0
- package/src/components/base/ui/style/radio.scss +203 -0
- package/src/components/base/ui/style/ripple.scss +35 -0
- package/src/components/base/ui/style/row.scss +39 -0
- package/src/components/base/ui/style/scrollbar.scss +75 -0
- package/src/components/base/ui/style/select-dropdown.scss +59 -0
- package/src/components/base/ui/style/select.scss +154 -0
- package/src/components/base/ui/style/skeleton-item.scss +84 -0
- package/src/components/base/ui/style/skeleton.scss +40 -0
- package/src/components/base/ui/style/slider.scss +250 -0
- package/src/components/base/ui/style/switch.scss +116 -0
- package/src/components/base/ui/style/tabs.scss +602 -0
- package/src/components/base/ui/style/tag.scss +174 -0
- package/src/components/base/ui/style/tooltip.scss +146 -0
- package/src/components/base/ui/style/transition.scss +138 -0
- package/src/components/base/ui/style/upload.scss +603 -0
- package/src/components/base/ui/style/utils.scss +39 -0
- package/src/components/base/ui/style/var.scss +1007 -0
- package/src/components/base/ui/switch/index.vue +174 -0
- package/src/components/base/ui/tabs/tab-bar.vue +57 -0
- package/src/components/base/ui/tabs/tab-nav.vue +294 -0
- package/src/components/base/ui/tabs/tab-pane.vue +56 -0
- package/src/components/base/ui/tabs/tabs.vue +191 -0
- package/src/components/base/ui/tag/Tag.vue +60 -0
- package/src/components/base/ui/tooltip/tooltip.jsx +234 -0
- package/src/components/base/ui/upload/Index.vue +340 -0
- package/src/components/base/ui/upload/Upload.vue +216 -0
- package/src/components/base/ui/upload/UploadDragger.vue +70 -0
- package/src/components/base/ui/upload/UploadList.vue +100 -0
- package/src/components/base/ui/upload/ajax.js +85 -0
- package/src/components/base/ui/util/aria-dialog.js +90 -0
- package/src/components/base/ui/util/aria-utils.js +122 -0
- package/src/components/base/ui/util/clickoutside.js +76 -0
- package/src/components/base/ui/util/date-util.js +292 -0
- package/src/components/base/ui/util/date.js +370 -0
- package/src/components/base/ui/util/debounce.js +21 -0
- package/src/components/base/ui/util/deepmerge.js +100 -0
- package/src/components/base/ui/util/dom.js +215 -0
- package/src/components/base/ui/util/index.js +262 -0
- package/src/components/base/ui/util/menu/aria-menubar.js +14 -0
- package/src/components/base/ui/util/menu/aria-menuitem.js +49 -0
- package/src/components/base/ui/util/menu/aria-submenu.js +59 -0
- package/src/components/base/ui/util/merge.js +14 -0
- package/src/components/base/ui/util/popper.js +1235 -0
- package/src/components/base/ui/util/popup/index.js +218 -0
- package/src/components/base/ui/util/popup/popup-manager.js +194 -0
- package/src/components/base/ui/util/resize-events.js +32 -0
- package/src/components/base/ui/util/scroll-into-view.js +27 -0
- package/src/components/base/ui/util/scrollbar-width.js +29 -0
- package/src/components/base/ui/util/shared.js +7 -0
- package/src/components/base/ui/util/throttle.js +91 -0
- package/src/components/base/ui/util/types.js +24 -0
- package/src/components/base/ui/util/vdom.js +5 -0
- package/src/components/base/ui/util/vue-popper.js +188 -0
- package/src/components/normal/AggsItemH.vue +139 -0
- package/src/index.js +10 -0
- package/src/static/base-icons.ttf +0 -0
- package/src/static/base-icons.woff +0 -0
- package/src/static/label_bg.png +0 -0
- package/src/static/term-label-bg.png +0 -0
- package/src/style/app-article.scss +698 -0
- package/src/style/app-comment.scss +259 -0
- package/src/style/app-recommend.scss +48 -0
- package/src/style/app-richtext.scss +176 -0
- package/src/style/index.scss +523 -0
- package/vite.config.js +38 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/* Modified from https://github.com/taylorhakes/fecha
|
|
2
|
+
*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 Taylor Hakes
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/*eslint-disable*/
|
|
27
|
+
// 把 YYYY-MM-DD 改成了 yyyy-MM-dd
|
|
28
|
+
let fecha1;
|
|
29
|
+
(function (main) {
|
|
30
|
+
'use strict';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Parse or format dates
|
|
34
|
+
* @class fecha
|
|
35
|
+
*/
|
|
36
|
+
var fecha = {};
|
|
37
|
+
var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
|
38
|
+
var twoDigits = '\\d\\d?';
|
|
39
|
+
var threeDigits = '\\d{3}';
|
|
40
|
+
var fourDigits = '\\d{4}';
|
|
41
|
+
var word = '[^\\s]+';
|
|
42
|
+
var literal = /\[([^]*?)\]/gm;
|
|
43
|
+
var noop = function () {
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function regexEscape(str) {
|
|
47
|
+
return str.replace( /[|\\{()[^$+*?.-]/g, '\\$&');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function shorten(arr, sLen) {
|
|
51
|
+
var newArr = [];
|
|
52
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
53
|
+
newArr.push(arr[i].substr(0, sLen));
|
|
54
|
+
}
|
|
55
|
+
return newArr;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function monthUpdate(arrName) {
|
|
59
|
+
return function (d, v, i18n) {
|
|
60
|
+
var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
|
|
61
|
+
if (~index) {
|
|
62
|
+
d.month = index;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function pad(val, len) {
|
|
68
|
+
val = String(val);
|
|
69
|
+
len = len || 2;
|
|
70
|
+
while (val.length < len) {
|
|
71
|
+
val = '0' + val;
|
|
72
|
+
}
|
|
73
|
+
return val;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
77
|
+
var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
78
|
+
var monthNamesShort = shorten(monthNames, 3);
|
|
79
|
+
var dayNamesShort = shorten(dayNames, 3);
|
|
80
|
+
fecha.i18n = {
|
|
81
|
+
dayNamesShort: dayNamesShort,
|
|
82
|
+
dayNames: dayNames,
|
|
83
|
+
monthNamesShort: monthNamesShort,
|
|
84
|
+
monthNames: monthNames,
|
|
85
|
+
amPm: ['am', 'pm'],
|
|
86
|
+
DoFn: function DoFn(D) {
|
|
87
|
+
return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var formatFlags = {
|
|
92
|
+
D: function(dateObj) {
|
|
93
|
+
return dateObj.getDay();
|
|
94
|
+
},
|
|
95
|
+
DD: function(dateObj) {
|
|
96
|
+
return pad(dateObj.getDay());
|
|
97
|
+
},
|
|
98
|
+
Do: function(dateObj, i18n) {
|
|
99
|
+
return i18n.DoFn(dateObj.getDate());
|
|
100
|
+
},
|
|
101
|
+
d: function(dateObj) {
|
|
102
|
+
return dateObj.getDate();
|
|
103
|
+
},
|
|
104
|
+
dd: function(dateObj) {
|
|
105
|
+
return pad(dateObj.getDate());
|
|
106
|
+
},
|
|
107
|
+
ddd: function(dateObj, i18n) {
|
|
108
|
+
return i18n.dayNamesShort[dateObj.getDay()];
|
|
109
|
+
},
|
|
110
|
+
dddd: function(dateObj, i18n) {
|
|
111
|
+
return i18n.dayNames[dateObj.getDay()];
|
|
112
|
+
},
|
|
113
|
+
M: function(dateObj) {
|
|
114
|
+
return dateObj.getMonth() + 1;
|
|
115
|
+
},
|
|
116
|
+
MM: function(dateObj) {
|
|
117
|
+
return pad(dateObj.getMonth() + 1);
|
|
118
|
+
},
|
|
119
|
+
MMM: function(dateObj, i18n) {
|
|
120
|
+
return i18n.monthNamesShort[dateObj.getMonth()];
|
|
121
|
+
},
|
|
122
|
+
MMMM: function(dateObj, i18n) {
|
|
123
|
+
return i18n.monthNames[dateObj.getMonth()];
|
|
124
|
+
},
|
|
125
|
+
yy: function(dateObj) {
|
|
126
|
+
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
127
|
+
},
|
|
128
|
+
yyyy: function(dateObj) {
|
|
129
|
+
return pad(dateObj.getFullYear(), 4);
|
|
130
|
+
},
|
|
131
|
+
h: function(dateObj) {
|
|
132
|
+
return dateObj.getHours() % 12 || 12;
|
|
133
|
+
},
|
|
134
|
+
hh: function(dateObj) {
|
|
135
|
+
return pad(dateObj.getHours() % 12 || 12);
|
|
136
|
+
},
|
|
137
|
+
H: function(dateObj) {
|
|
138
|
+
return dateObj.getHours();
|
|
139
|
+
},
|
|
140
|
+
HH: function(dateObj) {
|
|
141
|
+
return pad(dateObj.getHours());
|
|
142
|
+
},
|
|
143
|
+
m: function(dateObj) {
|
|
144
|
+
return dateObj.getMinutes();
|
|
145
|
+
},
|
|
146
|
+
mm: function(dateObj) {
|
|
147
|
+
return pad(dateObj.getMinutes());
|
|
148
|
+
},
|
|
149
|
+
s: function(dateObj) {
|
|
150
|
+
return dateObj.getSeconds();
|
|
151
|
+
},
|
|
152
|
+
ss: function(dateObj) {
|
|
153
|
+
return pad(dateObj.getSeconds());
|
|
154
|
+
},
|
|
155
|
+
S: function(dateObj) {
|
|
156
|
+
return Math.round(dateObj.getMilliseconds() / 100);
|
|
157
|
+
},
|
|
158
|
+
SS: function(dateObj) {
|
|
159
|
+
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
160
|
+
},
|
|
161
|
+
SSS: function(dateObj) {
|
|
162
|
+
return pad(dateObj.getMilliseconds(), 3);
|
|
163
|
+
},
|
|
164
|
+
a: function(dateObj, i18n) {
|
|
165
|
+
return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
|
|
166
|
+
},
|
|
167
|
+
A: function(dateObj, i18n) {
|
|
168
|
+
return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
|
|
169
|
+
},
|
|
170
|
+
ZZ: function(dateObj) {
|
|
171
|
+
var o = dateObj.getTimezoneOffset();
|
|
172
|
+
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
var parseFlags = {
|
|
177
|
+
d: [twoDigits, function (d, v) {
|
|
178
|
+
d.day = v;
|
|
179
|
+
}],
|
|
180
|
+
Do: [twoDigits + word, function (d, v) {
|
|
181
|
+
d.day = parseInt(v, 10);
|
|
182
|
+
}],
|
|
183
|
+
M: [twoDigits, function (d, v) {
|
|
184
|
+
d.month = v - 1;
|
|
185
|
+
}],
|
|
186
|
+
yy: [twoDigits, function (d, v) {
|
|
187
|
+
var da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
|
|
188
|
+
d.year = '' + (v > 68 ? cent - 1 : cent) + v;
|
|
189
|
+
}],
|
|
190
|
+
h: [twoDigits, function (d, v) {
|
|
191
|
+
d.hour = v;
|
|
192
|
+
}],
|
|
193
|
+
m: [twoDigits, function (d, v) {
|
|
194
|
+
d.minute = v;
|
|
195
|
+
}],
|
|
196
|
+
s: [twoDigits, function (d, v) {
|
|
197
|
+
d.second = v;
|
|
198
|
+
}],
|
|
199
|
+
yyyy: [fourDigits, function (d, v) {
|
|
200
|
+
d.year = v;
|
|
201
|
+
}],
|
|
202
|
+
S: ['\\d', function (d, v) {
|
|
203
|
+
d.millisecond = v * 100;
|
|
204
|
+
}],
|
|
205
|
+
SS: ['\\d{2}', function (d, v) {
|
|
206
|
+
d.millisecond = v * 10;
|
|
207
|
+
}],
|
|
208
|
+
SSS: [threeDigits, function (d, v) {
|
|
209
|
+
d.millisecond = v;
|
|
210
|
+
}],
|
|
211
|
+
D: [twoDigits, noop],
|
|
212
|
+
ddd: [word, noop],
|
|
213
|
+
MMM: [word, monthUpdate('monthNamesShort')],
|
|
214
|
+
MMMM: [word, monthUpdate('monthNames')],
|
|
215
|
+
a: [word, function (d, v, i18n) {
|
|
216
|
+
var val = v.toLowerCase();
|
|
217
|
+
if (val === i18n.amPm[0]) {
|
|
218
|
+
d.isPm = false;
|
|
219
|
+
} else if (val === i18n.amPm[1]) {
|
|
220
|
+
d.isPm = true;
|
|
221
|
+
}
|
|
222
|
+
}],
|
|
223
|
+
ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
|
|
224
|
+
var parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
|
|
225
|
+
|
|
226
|
+
if (parts) {
|
|
227
|
+
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
|
|
228
|
+
d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
|
|
229
|
+
}
|
|
230
|
+
}]
|
|
231
|
+
};
|
|
232
|
+
parseFlags.dd = parseFlags.d;
|
|
233
|
+
parseFlags.dddd = parseFlags.ddd;
|
|
234
|
+
parseFlags.DD = parseFlags.D;
|
|
235
|
+
parseFlags.mm = parseFlags.m;
|
|
236
|
+
parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
|
|
237
|
+
parseFlags.MM = parseFlags.M;
|
|
238
|
+
parseFlags.ss = parseFlags.s;
|
|
239
|
+
parseFlags.A = parseFlags.a;
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
// Some common format strings
|
|
243
|
+
fecha.masks = {
|
|
244
|
+
default: 'ddd MMM dd yyyy HH:mm:ss',
|
|
245
|
+
shortDate: 'M/D/yy',
|
|
246
|
+
mediumDate: 'MMM d, yyyy',
|
|
247
|
+
longDate: 'MMMM d, yyyy',
|
|
248
|
+
fullDate: 'dddd, MMMM d, yyyy',
|
|
249
|
+
shortTime: 'HH:mm',
|
|
250
|
+
mediumTime: 'HH:mm:ss',
|
|
251
|
+
longTime: 'HH:mm:ss.SSS'
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/***
|
|
255
|
+
* Format a date
|
|
256
|
+
* @method format
|
|
257
|
+
* @param {Date|number} dateObj
|
|
258
|
+
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
|
259
|
+
*/
|
|
260
|
+
fecha.format = function (dateObj, mask, i18nSettings) {
|
|
261
|
+
var i18n = i18nSettings || fecha.i18n;
|
|
262
|
+
|
|
263
|
+
if (typeof dateObj === 'number') {
|
|
264
|
+
dateObj = new Date(dateObj);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
|
268
|
+
throw new Error('Invalid Date in fecha.format');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
272
|
+
|
|
273
|
+
var literals = [];
|
|
274
|
+
|
|
275
|
+
// Make literals inactive by replacing them with ??
|
|
276
|
+
mask = mask.replace(literal, function($0, $1) {
|
|
277
|
+
literals.push($1);
|
|
278
|
+
return '@@@';
|
|
279
|
+
});
|
|
280
|
+
// Apply formatting rules
|
|
281
|
+
mask = mask.replace(token, function ($0) {
|
|
282
|
+
return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
|
|
283
|
+
});
|
|
284
|
+
// Inline literal values back into the formatted value
|
|
285
|
+
return mask.replace(/@@@/g, function() {
|
|
286
|
+
return literals.shift();
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Parse a date string into an object, changes - into /
|
|
292
|
+
* @method parse
|
|
293
|
+
* @param {string} dateStr Date string
|
|
294
|
+
* @param {string} format Date parse format
|
|
295
|
+
* @returns {Date|boolean}
|
|
296
|
+
*/
|
|
297
|
+
fecha.parse = function (dateStr, format, i18nSettings) {
|
|
298
|
+
var i18n = i18nSettings || fecha.i18n;
|
|
299
|
+
|
|
300
|
+
if (typeof format !== 'string') {
|
|
301
|
+
throw new Error('Invalid format in fecha.parse');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
format = fecha.masks[format] || format;
|
|
305
|
+
|
|
306
|
+
// Avoid regular expression denial of service, fail early for really long strings
|
|
307
|
+
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
|
308
|
+
if (dateStr.length > 1000) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
var dateInfo = {};
|
|
313
|
+
var parseInfo = [];
|
|
314
|
+
var literals = [];
|
|
315
|
+
format = format.replace(literal, function($0, $1) {
|
|
316
|
+
literals.push($1);
|
|
317
|
+
return '@@@';
|
|
318
|
+
});
|
|
319
|
+
var newFormat = regexEscape(format).replace(token, function ($0) {
|
|
320
|
+
if (parseFlags[$0]) {
|
|
321
|
+
var info = parseFlags[$0];
|
|
322
|
+
parseInfo.push(info[1]);
|
|
323
|
+
return '(' + info[0] + ')';
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return $0;
|
|
327
|
+
});
|
|
328
|
+
newFormat = newFormat.replace(/@@@/g, function() {
|
|
329
|
+
return literals.shift();
|
|
330
|
+
});
|
|
331
|
+
var matches = dateStr.match(new RegExp(newFormat, 'i'));
|
|
332
|
+
if (!matches) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
for (var i = 1; i < matches.length; i++) {
|
|
337
|
+
parseInfo[i - 1](dateInfo, matches[i], i18n);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
var today = new Date();
|
|
341
|
+
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
|
342
|
+
dateInfo.hour = +dateInfo.hour + 12;
|
|
343
|
+
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
|
344
|
+
dateInfo.hour = 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
var date;
|
|
348
|
+
if (dateInfo.timezoneOffset != null) {
|
|
349
|
+
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
350
|
+
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
|
351
|
+
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
|
|
352
|
+
} else {
|
|
353
|
+
date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
|
354
|
+
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
|
|
355
|
+
}
|
|
356
|
+
return date;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
/* istanbul ignore next */
|
|
360
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
361
|
+
module.exports = fecha;
|
|
362
|
+
} else if (typeof define === 'function' && define.amd) {
|
|
363
|
+
define(function () {
|
|
364
|
+
return fecha;
|
|
365
|
+
});
|
|
366
|
+
} else {
|
|
367
|
+
fecha1 = fecha;
|
|
368
|
+
}
|
|
369
|
+
})(this);
|
|
370
|
+
export default fecha1;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable no-undefined */
|
|
2
|
+
|
|
3
|
+
var throttle = import('./throttle');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Debounce execution of a function. Debouncing, unlike throttling,
|
|
7
|
+
* guarantees that a function is only executed a single time, either at the
|
|
8
|
+
* very beginning of a series of calls, or at the very end.
|
|
9
|
+
*
|
|
10
|
+
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
11
|
+
* @param {Boolean} [atBegin] Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
|
|
12
|
+
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
|
|
13
|
+
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
|
|
14
|
+
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
|
15
|
+
* to `callback` when the debounced-function is executed.
|
|
16
|
+
*
|
|
17
|
+
* @return {Function} A new, debounced function.
|
|
18
|
+
*/
|
|
19
|
+
export default function ( delay, atBegin, callback ) {
|
|
20
|
+
return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false);
|
|
21
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var deepmerge = function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var isMergeableObject = function isMergeableObject(value) {
|
|
5
|
+
return isNonNullObject(value)
|
|
6
|
+
&& !isSpecial(value)
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function isNonNullObject(value) {
|
|
10
|
+
return !!value && typeof value === 'object'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isSpecial(value) {
|
|
14
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
15
|
+
|
|
16
|
+
return stringValue === '[object RegExp]'
|
|
17
|
+
|| stringValue === '[object Date]'
|
|
18
|
+
|| isReactElement(value)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
22
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
23
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
24
|
+
|
|
25
|
+
function isReactElement(value) {
|
|
26
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function emptyTarget(val) {
|
|
30
|
+
return Array.isArray(val) ? [] : {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function cloneIfNecessary(value, optionsArgument) {
|
|
34
|
+
var clone = optionsArgument && optionsArgument.clone === true;
|
|
35
|
+
return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function defaultArrayMerge(target, source, optionsArgument) {
|
|
39
|
+
var destination = target.slice();
|
|
40
|
+
source.forEach(function(e, i) {
|
|
41
|
+
if (typeof destination[i] === 'undefined') {
|
|
42
|
+
destination[i] = cloneIfNecessary(e, optionsArgument);
|
|
43
|
+
} else if (isMergeableObject(e)) {
|
|
44
|
+
destination[i] = deepmerge(target[i], e, optionsArgument);
|
|
45
|
+
} else if (target.indexOf(e) === -1) {
|
|
46
|
+
destination.push(cloneIfNecessary(e, optionsArgument));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return destination
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function mergeObject(target, source, optionsArgument) {
|
|
53
|
+
var destination = {};
|
|
54
|
+
if (isMergeableObject(target)) {
|
|
55
|
+
Object.keys(target).forEach(function(key) {
|
|
56
|
+
destination[key] = cloneIfNecessary(target[key], optionsArgument);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
Object.keys(source).forEach(function(key) {
|
|
60
|
+
if (!isMergeableObject(source[key]) || !target[key]) {
|
|
61
|
+
destination[key] = cloneIfNecessary(source[key], optionsArgument);
|
|
62
|
+
} else {
|
|
63
|
+
destination[key] = deepmerge(target[key], source[key], optionsArgument);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return destination
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function deepmerge(target, source, optionsArgument) {
|
|
70
|
+
var sourceIsArray = Array.isArray(source);
|
|
71
|
+
var targetIsArray = Array.isArray(target);
|
|
72
|
+
var options = optionsArgument || { arrayMerge: defaultArrayMerge };
|
|
73
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
74
|
+
|
|
75
|
+
if (!sourceAndTargetTypesMatch) {
|
|
76
|
+
return cloneIfNecessary(source, optionsArgument)
|
|
77
|
+
} else if (sourceIsArray) {
|
|
78
|
+
var arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
79
|
+
return arrayMerge(target, source, optionsArgument)
|
|
80
|
+
} else {
|
|
81
|
+
return mergeObject(target, source, optionsArgument)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
deepmerge.all = function deepmergeAll(array, optionsArgument) {
|
|
86
|
+
if (!Array.isArray(array) || array.length < 2) {
|
|
87
|
+
throw new Error('first argument should be an array with at least two elements')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// we are sure there are at least 2 values, so it is safe to have no initial value
|
|
91
|
+
return array.reduce(function(prev, next) {
|
|
92
|
+
return deepmerge(prev, next, optionsArgument)
|
|
93
|
+
})
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var deepmerge_1 = deepmerge
|
|
97
|
+
|
|
98
|
+
return deepmerge_1
|
|
99
|
+
}
|
|
100
|
+
export default deepmerge ()
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
const isServer = Vue.prototype.$isServer
|
|
4
|
+
const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g
|
|
5
|
+
const MOZ_HACK_REGEXP = /^moz([A-Z])/
|
|
6
|
+
const ieVersion = isServer ? 0 : Number(document.documentMode)
|
|
7
|
+
|
|
8
|
+
const trim = function(string) {
|
|
9
|
+
return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '')
|
|
10
|
+
}
|
|
11
|
+
const camelCase = function(name) {
|
|
12
|
+
return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
|
|
13
|
+
return offset ? letter.toUpperCase() : letter
|
|
14
|
+
}).replace(MOZ_HACK_REGEXP, 'Moz$1')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const on = (function() {
|
|
18
|
+
if (!isServer && document.addEventListener) {
|
|
19
|
+
return function(element, event, handler) {
|
|
20
|
+
if (element && event && handler) {
|
|
21
|
+
element.addEventListener(event, handler, false)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
return function(element, event, handler) {
|
|
26
|
+
if (element && event && handler) {
|
|
27
|
+
element.attachEvent('on' + event, handler)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
})()
|
|
32
|
+
|
|
33
|
+
export const off = (function() {
|
|
34
|
+
if (!isServer && document.removeEventListener) {
|
|
35
|
+
return function(element, event, handler) {
|
|
36
|
+
if (element && event) {
|
|
37
|
+
element.removeEventListener(event, handler, false)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
return function(element, event, handler) {
|
|
42
|
+
if (element && event) {
|
|
43
|
+
element.detachEvent('on' + event, handler)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})()
|
|
48
|
+
|
|
49
|
+
export const once = function(el, event, fn) {
|
|
50
|
+
var listener = function() {
|
|
51
|
+
if (fn) {
|
|
52
|
+
fn.apply(this, arguments)
|
|
53
|
+
}
|
|
54
|
+
off(el, event, listener)
|
|
55
|
+
}
|
|
56
|
+
on(el, event, listener)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function hasClass(el, cls) {
|
|
60
|
+
if (!el || !cls) return false
|
|
61
|
+
if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.')
|
|
62
|
+
if (el.classList) {
|
|
63
|
+
return el.classList.contains(cls)
|
|
64
|
+
} else {
|
|
65
|
+
return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function addClass(el, cls) {
|
|
70
|
+
if (!el) return
|
|
71
|
+
var curClass = el.className
|
|
72
|
+
var classes = (cls || '').split(' ')
|
|
73
|
+
|
|
74
|
+
for (var i = 0, j = classes.length; i < j; i++) {
|
|
75
|
+
var clsName = classes[i]
|
|
76
|
+
if (!clsName) continue
|
|
77
|
+
|
|
78
|
+
if (el.classList) {
|
|
79
|
+
el.classList.add(clsName)
|
|
80
|
+
} else if (!hasClass(el, clsName)) {
|
|
81
|
+
curClass += ' ' + clsName
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!el.classList) {
|
|
85
|
+
el.className = curClass
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function removeClass(el, cls) {
|
|
90
|
+
if (!el || !cls) return
|
|
91
|
+
var classes = cls.split(' ')
|
|
92
|
+
var curClass = ' ' + el.className + ' '
|
|
93
|
+
|
|
94
|
+
for (var i = 0, j = classes.length; i < j; i++) {
|
|
95
|
+
var clsName = classes[i]
|
|
96
|
+
if (!clsName) continue
|
|
97
|
+
|
|
98
|
+
if (el.classList) {
|
|
99
|
+
el.classList.remove(clsName)
|
|
100
|
+
} else if (hasClass(el, clsName)) {
|
|
101
|
+
curClass = curClass.replace(' ' + clsName + ' ', ' ')
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!el.classList) {
|
|
105
|
+
el.className = trim(curClass)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const getStyle = ieVersion < 9 ? function(element, styleName) {
|
|
110
|
+
if (isServer) return
|
|
111
|
+
if (!element || !styleName) return null
|
|
112
|
+
styleName = camelCase(styleName)
|
|
113
|
+
if (styleName === 'float') {
|
|
114
|
+
styleName = 'styleFloat'
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
switch (styleName) {
|
|
118
|
+
case 'opacity':
|
|
119
|
+
try {
|
|
120
|
+
return element.filters.item('alpha').opacity / 100
|
|
121
|
+
} catch (e) {
|
|
122
|
+
return 1.0
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null)
|
|
126
|
+
}
|
|
127
|
+
} catch (e) {
|
|
128
|
+
return element.style[styleName]
|
|
129
|
+
}
|
|
130
|
+
} : function(element, styleName) {
|
|
131
|
+
if (isServer) return
|
|
132
|
+
if (!element || !styleName) return null
|
|
133
|
+
styleName = camelCase(styleName)
|
|
134
|
+
if (styleName === 'float') {
|
|
135
|
+
styleName = 'cssFloat'
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
var computed = document.defaultView.getComputedStyle(element, '')
|
|
139
|
+
return element.style[styleName] || computed ? computed[styleName] : null
|
|
140
|
+
} catch (e) {
|
|
141
|
+
return element.style[styleName]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function setStyle(element, styleName, value) {
|
|
146
|
+
if (!element || !styleName) return
|
|
147
|
+
|
|
148
|
+
if (typeof styleName === 'object') {
|
|
149
|
+
for (var prop in styleName) {
|
|
150
|
+
if (styleName.hasOwnProperty(prop)) {
|
|
151
|
+
setStyle(element, prop, styleName[prop])
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
styleName = camelCase(styleName)
|
|
156
|
+
if (styleName === 'opacity' && ieVersion < 9) {
|
|
157
|
+
element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')'
|
|
158
|
+
} else {
|
|
159
|
+
element.style[styleName] = value
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const isScroll = (el, vertical) => {
|
|
165
|
+
if (isServer) return
|
|
166
|
+
|
|
167
|
+
const determinedDirection = vertical !== null || vertical !== undefined
|
|
168
|
+
const overflow = determinedDirection
|
|
169
|
+
? vertical
|
|
170
|
+
? getStyle(el, 'overflow-y')
|
|
171
|
+
: getStyle(el, 'overflow-x')
|
|
172
|
+
: getStyle(el, 'overflow')
|
|
173
|
+
|
|
174
|
+
return overflow.match(/(scroll|auto)/)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export const getScrollContainer = (el, vertical) => {
|
|
178
|
+
if (isServer) return
|
|
179
|
+
|
|
180
|
+
let parent = el
|
|
181
|
+
while (parent) {
|
|
182
|
+
if ([window, document, document.documentElement].includes(parent)) {
|
|
183
|
+
return window
|
|
184
|
+
}
|
|
185
|
+
if (isScroll(parent, vertical)) {
|
|
186
|
+
return parent
|
|
187
|
+
}
|
|
188
|
+
parent = parent.parentNode
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return parent
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const isInContainer = (el, container) => {
|
|
195
|
+
if (isServer || !el || !container) return false
|
|
196
|
+
|
|
197
|
+
const elRect = el.getBoundingClientRect()
|
|
198
|
+
let containerRect
|
|
199
|
+
|
|
200
|
+
if ([window, document, document.documentElement, null, undefined].includes(container)) {
|
|
201
|
+
containerRect = {
|
|
202
|
+
top: 0,
|
|
203
|
+
right: window.innerWidth,
|
|
204
|
+
bottom: window.innerHeight,
|
|
205
|
+
left: 0
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
containerRect = container.getBoundingClientRect()
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return elRect.top < containerRect.bottom &&
|
|
212
|
+
elRect.bottom > containerRect.top &&
|
|
213
|
+
elRect.right > containerRect.left &&
|
|
214
|
+
elRect.left < containerRect.right
|
|
215
|
+
}
|