bri-components 1.1.3 → 1.1.4
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.bri-components.min.js +1 -1
- package/lib/1.bri-components.min.js +1 -1
- package/lib/2.bri-components.min.js +1 -1
- package/lib/3.bri-components.min.js +1 -1
- package/lib/4.bri-components.min.js +1 -1
- package/lib/5.bri-components.min.js +1 -1
- package/lib/6.bri-components.min.js +1 -1
- package/lib/7.bri-components.min.js +1 -1
- package/lib/bri-components.min.js +6 -6
- package/lib/styles/bri-components.css +1 -1
- package/package.json +1 -1
- package/src/abolish/DshCascaders.less +11 -0
- package/src/{components/controls/base/DshCascaderMultiple.vue → abolish/DshCascaders.vue} +4 -23
- package/src/{components/list → abolish}/DshFlatTable.vue +1 -1
- package/src/abolish/DshTexts.less +13 -0
- package/src/{components/controls/base/textMultiple/DshTextMultiple.vue → abolish/DshTexts.vue} +4 -20
- package/src/components/controls/base/{textMultiple/MultipleInput.vue → BriInputs.vue} +13 -12
- package/src/components/controls/base/{ZUpload/YUploadImage.vue → BriUpload/BriUploadImage.vue} +56 -15
- package/src/components/controls/base/{ZUpload → BriUpload}/index.vue +11 -12
- package/src/components/controls/base/{ZUpload → BriUpload}/uploadMixin.js +2 -2
- package/src/components/controls/base/{DshCascader.vue → DshCascader/DshCascader.vue} +20 -16
- package/src/components/controls/base/DshCheckbox.vue +1 -1
- package/src/components/controls/base/DshCoordinates.vue +117 -109
- package/src/components/controls/base/DshEditor.vue +1 -1
- package/src/components/controls/base/DshInput.vue +9 -4
- package/src/components/controls/base/DshNumber/DshNumber.vue +2 -0
- package/src/components/controls/base/DshSelect.vue +1 -1
- package/src/components/controls/controlMap.js +6 -7
- package/src/components/controls/controlMixin.js +6 -5
- package/src/components/list/DshBox/DshBox.vue +7 -24
- package/src/components/list/DshBox/DshCard.vue +13 -72
- package/src/components/list/DshBox/DshList.vue +8 -136
- package/src/components/list/DshBox/DshPanel.vue +0 -110
- package/src/components/list/DshBox/DshTable.vue +1 -4
- package/src/components/list/ZTree.vue +0 -58
- package/src/components/other/ZIframe.vue +5 -0
- package/src/components/small/DshControlDefine.vue +5 -1
- package/src/components/small/DshPage.vue +1 -0
- package/src/index.js +11 -23
- package/src/styles/common/control.less +16 -17
- package/src/styles/components/controls/{MultipleInput.less → BriInputs.less} +1 -1
- package/src/styles/components/controls/{ZUpload.less → BriUpload.less} +4 -4
- package/src/styles/components/controls/DshCoordinates.less +53 -43
- package/src/styles/components/controls/DshNumber.less +18 -0
- package/src/styles/components/index.less +22 -16
- package/src/styles/components/list/DshBox/DshBox.less +20 -0
- package/src/styles/components/list/DshBox/DshCard.less +59 -0
- package/src/styles/components/list/DshBox/DshList.less +142 -0
- package/src/styles/components/list/DshBox/DshPanel.less +107 -0
- package/src/styles/components/list/DshBox/DshTable.less +4 -0
- package/src/styles/components/list/ZTree.less +52 -0
- package/src/styles/components/small/DshModal.less +1 -1
- package/src/styles/variables.less +1 -0
- package/src/utils/table.js +3 -2
- package/src/components/controls/base/YSerialNumber.vue +0 -43
- package/src/components/list/easyTable/index.js +0 -23
- package/src/components/list/easyTable/src/directives/clickoutside.js +0 -32
- package/src/components/list/easyTable/src/mixins/layerAdjustment.js +0 -62
- package/src/components/list/easyTable/src/settings/settings.js +0 -11
- package/src/components/list/easyTable/src/utils/deepClone.js +0 -256
- package/src/components/list/easyTable/src/utils/dom.js +0 -41
- package/src/components/list/easyTable/src/utils/utils.js +0 -190
- package/src/components/list/easyTable/v-checkbox/index.js +0 -7
- package/src/components/list/easyTable/v-checkbox/src/checkbox.vue +0 -127
- package/src/components/list/easyTable/v-checkbox-group/index.js +0 -7
- package/src/components/list/easyTable/v-checkbox-group/src/checkbox-group.vue +0 -68
- package/src/components/list/easyTable/v-dropdown/index.js +0 -7
- package/src/components/list/easyTable/v-dropdown/src/dropdown.vue +0 -337
- package/src/components/list/easyTable/v-table/index.js +0 -7
- package/src/components/list/easyTable/v-table/src/body-cell-merge-mixin.js +0 -141
- package/src/components/list/easyTable/v-table/src/cell-edit-mixin.js +0 -102
- package/src/components/list/easyTable/v-table/src/checkbox-selection-mixin.js +0 -189
- package/src/components/list/easyTable/v-table/src/classes-mixin.js +0 -56
- package/src/components/list/easyTable/v-table/src/drag-width-mixin.js +0 -202
- package/src/components/list/easyTable/v-table/src/export-csv.js +0 -74
- package/src/components/list/easyTable/v-table/src/frozen-columns-mixin.js +0 -134
- package/src/components/list/easyTable/v-table/src/loading.vue +0 -49
- package/src/components/list/easyTable/v-table/src/scroll-bar-control-mixin.js +0 -21
- package/src/components/list/easyTable/v-table/src/scroll-control-mixin.js +0 -92
- package/src/components/list/easyTable/v-table/src/sort-control-mixin.js +0 -108
- package/src/components/list/easyTable/v-table/src/table-empty-mixin.js +0 -73
- package/src/components/list/easyTable/v-table/src/table-empty.vue +0 -66
- package/src/components/list/easyTable/v-table/src/table-filters-mixin.js +0 -126
- package/src/components/list/easyTable/v-table/src/table-footer-mixin.js +0 -122
- package/src/components/list/easyTable/v-table/src/table-resize-mixin.js +0 -279
- package/src/components/list/easyTable/v-table/src/table-row-mouse-events-mixin.js +0 -123
- package/src/components/list/easyTable/v-table/src/table.vue +0 -1565
- package/src/components/list/easyTable/v-table/src/title-cell-merge-mixin.js +0 -115
- package/src/components/list/evTable/EvTable.vue +0 -321
- package/src/components/list/evTable/EvTableMixin.js +0 -26
- package/src/styles/components/list/evTable.less +0 -79
- package/src/styles/components/list/evtable/animation.less +0 -141
- package/src/styles/components/list/evtable/font/fontello.eot +0 -0
- package/src/styles/components/list/evtable/font/fontello.svg +0 -32
- package/src/styles/components/list/evtable/font/fontello.ttf +0 -0
- package/src/styles/components/list/evtable/font/fontello.woff +0 -0
- package/src/styles/components/list/evtable/font/fontello.woff2 +0 -0
- package/src/styles/components/list/evtable/fontello.less +0 -68
- package/src/styles/components/list/evtable/index.less +0 -5
- package/src/styles/components/list/evtable/v-checkbox.less +0 -167
- package/src/styles/components/list/evtable/v-dropdown.less +0 -235
- package/src/styles/components/list/evtable/v-table.less +0 -334
- package/src/styles/components/list/ivu_reset.less +0 -49
- /package/src/{styles/components/list → abolish}/DshFlatTable.less +0 -0
- /package/src/components/{pages/Error → Error}/Error403.vue +0 -0
- /package/src/components/{pages/Error → Error}/Error404.vue +0 -0
- /package/src/components/{pages/Error → Error}/Error500.vue +0 -0
- /package/src/components/{pages/Error → Error}/error.less +0 -0
- /package/src/components/{pages/Error → Error}/errorBack.vue +0 -0
- /package/src/components/controls/base/{ZUpload → BriUpload}/upload-list.vue +0 -0
- /package/src/components/controls/base/{ZUpload → BriUpload}/upload-listItem.vue +0 -0
- /package/src/components/{other → controls/base/DshCascader}/InfoCascader.vue +0 -0
- /package/src/styles/components/{other → controls}/InfoCascader.less +0 -0
- /package/src/styles/components/list/{DshCrossTable.less → DshBox/DshCrossTable.less} +0 -0
- /package/src/styles/components/list/{DshSingleData.less → DshBox/DshSingleData.less} +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
.DshPanel {
|
|
2
|
+
min-width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: row;
|
|
6
|
+
|
|
7
|
+
&-group {
|
|
8
|
+
width: 300px;
|
|
9
|
+
min-width: 300px;
|
|
10
|
+
max-width: 300px;
|
|
11
|
+
height: 100%;
|
|
12
|
+
padding: 10px;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
|
|
17
|
+
&-title {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 50px;
|
|
20
|
+
padding: 15px 10px;
|
|
21
|
+
display: flex;
|
|
22
|
+
border-radius: 10px 10px 0px 0px;
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
|
|
25
|
+
&-name {
|
|
26
|
+
max-width: 120px;
|
|
27
|
+
}
|
|
28
|
+
&-number {
|
|
29
|
+
font-weight: bold;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-list {
|
|
34
|
+
width: 100%;
|
|
35
|
+
flex: 1;
|
|
36
|
+
min-height: 0px;
|
|
37
|
+
border: 1px dashed #cccccc;
|
|
38
|
+
border-top: none;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
|
|
42
|
+
.list-drag {
|
|
43
|
+
width: 100%;
|
|
44
|
+
flex: 1;
|
|
45
|
+
min-height: 0px;
|
|
46
|
+
|
|
47
|
+
&-transition {
|
|
48
|
+
display: block;
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
padding: 10px;
|
|
52
|
+
overflow: auto;
|
|
53
|
+
|
|
54
|
+
.item {
|
|
55
|
+
height: 60px;
|
|
56
|
+
padding: 10px 17px;
|
|
57
|
+
margin-bottom: 10px;
|
|
58
|
+
border: 1px solid rgba(102, 110, 126, 0.1);
|
|
59
|
+
border-radius: 4px;
|
|
60
|
+
background: #FFFFFF;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
position: relative;
|
|
63
|
+
|
|
64
|
+
&-dropdown {
|
|
65
|
+
position: absolute;
|
|
66
|
+
top: 5px;
|
|
67
|
+
right: 5px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&-title {
|
|
71
|
+
width: calc(100% - 22px);
|
|
72
|
+
margin-bottom: 2px;
|
|
73
|
+
font-family: Source Han Sans CN;
|
|
74
|
+
font-size: 14px;
|
|
75
|
+
font-weight: 500;
|
|
76
|
+
color: #515A6E;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&-cols {}
|
|
80
|
+
|
|
81
|
+
.unit {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: row;
|
|
84
|
+
color: #515A6E;
|
|
85
|
+
&-label {
|
|
86
|
+
max-width: 60px;
|
|
87
|
+
}
|
|
88
|
+
&-colon {
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
&-value {
|
|
92
|
+
flex: 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.list-btns {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 40px;
|
|
102
|
+
padding: 0px 10px;
|
|
103
|
+
text-align: center;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.ZTree {
|
|
2
|
+
max-width: 1200px;
|
|
3
|
+
min-width: 720px;
|
|
4
|
+
height: 100%;
|
|
5
|
+
margin: 0px auto;
|
|
6
|
+
background: #fff;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
|
|
10
|
+
&-action {
|
|
11
|
+
padding: 10px;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: flex-end;
|
|
14
|
+
|
|
15
|
+
&-create {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
align-items: center;
|
|
19
|
+
|
|
20
|
+
.ivu-icon {
|
|
21
|
+
font-size: 20px;
|
|
22
|
+
font-weight: bold;
|
|
23
|
+
margin-right: -10px;
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
transform: translate(0, -1px);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&-tree {
|
|
31
|
+
width: 100%;
|
|
32
|
+
flex: 1;
|
|
33
|
+
min-height: 0px;
|
|
34
|
+
overflow: auto;
|
|
35
|
+
|
|
36
|
+
.ivu-tree-title {
|
|
37
|
+
width: calc(100% - 18px);
|
|
38
|
+
}
|
|
39
|
+
.ivu-tree-arrow {
|
|
40
|
+
margin-top: 5px;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
&-dropdown-menu.DshColorPanel-list {
|
|
44
|
+
width: 242px!important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&-create-content {
|
|
48
|
+
.textRight {
|
|
49
|
+
text-align: right;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/utils/table.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* -------------------- 表格 -------------- */
|
|
2
2
|
// 转化表单字段属性 to 表格参数, 是否需要过滤tag
|
|
3
3
|
const transformToColumns = function (form) {
|
|
4
|
+
let headerFilter = this.listPropsObj && this.listPropsObj.headerFilter;
|
|
4
5
|
return form
|
|
5
6
|
.filter(col => col._type !== "tag")
|
|
6
7
|
.map(col => {
|
|
@@ -12,7 +13,7 @@ const transformToColumns = function (form) {
|
|
|
12
13
|
key: col._key,
|
|
13
14
|
align: col._align || typeData.align,
|
|
14
15
|
width: col._width || typeData.width,
|
|
15
|
-
sortBy: col._sortBy || typeData.sortBy,
|
|
16
|
+
sortBy: headerFilter ? col._sortBy || typeData.sortBy : undefined,
|
|
16
17
|
|
|
17
18
|
...(
|
|
18
19
|
col._type
|
|
@@ -49,7 +50,7 @@ const transformToColumns = function (form) {
|
|
|
49
50
|
...(
|
|
50
51
|
["select", "checkbox"].includes(col._type)
|
|
51
52
|
? {
|
|
52
|
-
filter:
|
|
53
|
+
filter: headerFilter ? {
|
|
53
54
|
isMultiple: true,
|
|
54
55
|
maxHeight: 300,
|
|
55
56
|
filterList: col._data.map(item => ({
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="YSerialNumber">
|
|
3
|
-
<dsh-input
|
|
4
|
-
:value="value"
|
|
5
|
-
:propsObj="selfPropsObj"
|
|
6
|
-
:canEdit="canEdit"
|
|
7
|
-
></dsh-input>
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script>
|
|
12
|
-
import controlMixin from "../controlMixin.js";
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
name: "YSerialNumber",
|
|
16
|
-
mixins: [controlMixin],
|
|
17
|
-
props: {},
|
|
18
|
-
data () {
|
|
19
|
-
return {};
|
|
20
|
-
},
|
|
21
|
-
computed: {
|
|
22
|
-
selfPropsObj () {
|
|
23
|
-
return {
|
|
24
|
-
...this.propsObj,
|
|
25
|
-
canEdit: false
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
created () {},
|
|
30
|
-
methods: {}
|
|
31
|
-
};
|
|
32
|
-
</script>
|
|
33
|
-
|
|
34
|
-
<style lang="less" scoped>
|
|
35
|
-
.YSerialNumber {
|
|
36
|
-
width: 100%;
|
|
37
|
-
}
|
|
38
|
-
</style>
|
|
39
|
-
<style lang="less">
|
|
40
|
-
.YSerialNumber {
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
</style>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import VTable from "./v-table/index";
|
|
2
|
-
import VCheckbox from "./v-checkbox/index";
|
|
3
|
-
import VCheckboxGroup from "./v-checkbox-group/index";
|
|
4
|
-
import VDropdown from "./v-dropdown/index";
|
|
5
|
-
|
|
6
|
-
const install = function (Vue, opts = {}) {
|
|
7
|
-
Vue.component(VTable.name, VTable);
|
|
8
|
-
Vue.component(VCheckbox.name, VCheckbox);
|
|
9
|
-
Vue.component(VCheckboxGroup.name, VCheckboxGroup);
|
|
10
|
-
Vue.component(VDropdown.name, VDropdown);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// auto install
|
|
14
|
-
if (typeof window !== "undefined" && window.Vue) {
|
|
15
|
-
install(window.Vue);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
VTable,
|
|
20
|
-
VCheckbox,
|
|
21
|
-
VCheckboxGroup,
|
|
22
|
-
VDropdown
|
|
23
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
bind: function (el, binding, vNode) {
|
|
3
|
-
if (typeof binding.value !== "function") {
|
|
4
|
-
|
|
5
|
-
let msg = `in [clickoutside] directives, provided expression '${binding.expression}' is not a function `;
|
|
6
|
-
|
|
7
|
-
const compName = vNode.context.name;
|
|
8
|
-
|
|
9
|
-
if (compName) {
|
|
10
|
-
msg += `in ${compName}`;
|
|
11
|
-
}
|
|
12
|
-
console.error(msg);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let handler = (e) => {
|
|
16
|
-
if (!el.contains(e.target) && el !== e.target) {
|
|
17
|
-
binding.value(e);
|
|
18
|
-
} else {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
el.__clickOutSide__ = handler;
|
|
23
|
-
|
|
24
|
-
document.addEventListener("click", handler, true);
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
unbind: function (el) {
|
|
28
|
-
document.removeEventListener("click", el.__clickOutSide__, true);
|
|
29
|
-
el.__clickOutSide__ = null;
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import utils from "../utils/utils";
|
|
2
|
-
|
|
3
|
-
let __autoAdjustmentEvents__ = [];
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
methods: {
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* 自动调整浮层(不绑定事件)
|
|
10
|
-
*
|
|
11
|
-
* @method layerAdjustmentBind
|
|
12
|
-
* @param {Dom} layerElement 浮层元素
|
|
13
|
-
* @param {Dom} targetElement 控制元素
|
|
14
|
-
* @param {Number} distance 浮层元素和控制元素的上下间距
|
|
15
|
-
*/
|
|
16
|
-
layerAdjustmentOnce (layerElement, targetElement, distance) {
|
|
17
|
-
|
|
18
|
-
let viewportOffset = utils.getViewportOffset(targetElement);
|
|
19
|
-
let layerElemHeight = typeof layerElement.getBoundingClientRect !== "undefined" ? layerElement.getBoundingClientRect().height : layerElement.clientHeight;
|
|
20
|
-
|
|
21
|
-
if (viewportOffset.bottom < layerElemHeight) {
|
|
22
|
-
|
|
23
|
-
layerElement.style.top = (viewportOffset.top - layerElemHeight - distance) + "px";
|
|
24
|
-
} else {
|
|
25
|
-
|
|
26
|
-
layerElement.style.top = (viewportOffset.top + targetElement.clientHeight + distance) + "px";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
layerElement.style.left = viewportOffset.left + "px";
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
* 滚动时自动调整浮层
|
|
34
|
-
*
|
|
35
|
-
* @method layerAdjustmentBind
|
|
36
|
-
* @param {Dom} layerElement 浮层元素
|
|
37
|
-
* @param {Dom} targetElement 控制元素
|
|
38
|
-
* @param {Number} distance 浮层元素和控制元素的上下间距
|
|
39
|
-
*/
|
|
40
|
-
layerAdjustmentBind (layerElement, targetElement, distance) {
|
|
41
|
-
|
|
42
|
-
let handler = (e) => {
|
|
43
|
-
|
|
44
|
-
setTimeout(x => {
|
|
45
|
-
|
|
46
|
-
this.layerAdjustmentOnce(layerElement, targetElement, distance);
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
__autoAdjustmentEvents__.push(handler);
|
|
51
|
-
utils.bind(window, "scroll", handler);
|
|
52
|
-
utils.bind(window, "resize", handler);
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
beforeDestroy () {
|
|
57
|
-
|
|
58
|
-
utils.unbind(window, "scroll", __autoAdjustmentEvents__);
|
|
59
|
-
utils.unbind(window, "resize", __autoAdjustmentEvents__);
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
};
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
* source:https://github.com/pvorb/clone/blob/master/clone.js
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* */
|
|
7
|
-
|
|
8
|
-
let clone = (function () {
|
|
9
|
-
"use strict";
|
|
10
|
-
|
|
11
|
-
function _instanceof (obj, type) {
|
|
12
|
-
return type != null && obj instanceof type;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let NativeMap;
|
|
16
|
-
try {
|
|
17
|
-
NativeMap = Map;
|
|
18
|
-
} catch (_) {
|
|
19
|
-
// maybe a reference error because no `Map`. Give it a dummy value that no
|
|
20
|
-
// value will ever be an instanceof.
|
|
21
|
-
NativeMap = function () {};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let NativeSet;
|
|
25
|
-
try {
|
|
26
|
-
NativeSet = Set;
|
|
27
|
-
} catch (_) {
|
|
28
|
-
NativeSet = function () {};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let NativePromise;
|
|
32
|
-
try {
|
|
33
|
-
NativePromise = Promise;
|
|
34
|
-
} catch (_) {
|
|
35
|
-
NativePromise = function () {};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Clones (copies) an Object using deep copying.
|
|
40
|
-
*
|
|
41
|
-
* This function supports circular references by default, but if you are certain
|
|
42
|
-
* there are no circular references in your object, you can save some CPU time
|
|
43
|
-
* by calling clone(obj, false).
|
|
44
|
-
*
|
|
45
|
-
* Caution: if `circular` is false and `parent` contains circular references,
|
|
46
|
-
* your program may enter an infinite loop and crash.
|
|
47
|
-
*
|
|
48
|
-
* @param `parent` - the object to be cloned
|
|
49
|
-
* @param `circular` - set to true if the object to be cloned may contain
|
|
50
|
-
* circular references. (optional - true by default)
|
|
51
|
-
* @param `depth` - set to a number if the object is only to be cloned to
|
|
52
|
-
* a particular depth. (optional - defaults to Infinity)
|
|
53
|
-
* @param `prototype` - sets the prototype to be used when cloning an object.
|
|
54
|
-
* (optional - defaults to parent prototype).
|
|
55
|
-
* @param `includeNonEnumerable` - set to true if the non-enumerable properties
|
|
56
|
-
* should be cloned as well. Non-enumerable properties on the prototype
|
|
57
|
-
* chain will be ignored. (optional - false by default)
|
|
58
|
-
*/
|
|
59
|
-
function clone (parent, circular, depth, prototype, includeNonEnumerable) {
|
|
60
|
-
if (typeof circular === "object") {
|
|
61
|
-
depth = circular.depth;
|
|
62
|
-
prototype = circular.prototype;
|
|
63
|
-
includeNonEnumerable = circular.includeNonEnumerable;
|
|
64
|
-
circular = circular.circular;
|
|
65
|
-
}
|
|
66
|
-
// maintain two arrays for circular references, where corresponding parents
|
|
67
|
-
// and children have the same index
|
|
68
|
-
let allParents = [];
|
|
69
|
-
let allChildren = [];
|
|
70
|
-
|
|
71
|
-
let useBuffer = typeof Buffer != "undefined";
|
|
72
|
-
|
|
73
|
-
if (typeof circular == "undefined")
|
|
74
|
-
{ circular = true; }
|
|
75
|
-
|
|
76
|
-
if (typeof depth == "undefined")
|
|
77
|
-
{ depth = Infinity; }
|
|
78
|
-
|
|
79
|
-
// recurse this function so we don't reset allParents and allChildren
|
|
80
|
-
function _clone (parent, depth) {
|
|
81
|
-
// cloning null always returns null
|
|
82
|
-
if (parent === null)
|
|
83
|
-
{ return null; }
|
|
84
|
-
|
|
85
|
-
if (depth === 0)
|
|
86
|
-
{ return parent; }
|
|
87
|
-
|
|
88
|
-
let child;
|
|
89
|
-
let proto;
|
|
90
|
-
if (typeof parent != "object") {
|
|
91
|
-
return parent;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (_instanceof(parent, NativeMap)) {
|
|
95
|
-
child = new NativeMap();
|
|
96
|
-
} else if (_instanceof(parent, NativeSet)) {
|
|
97
|
-
child = new NativeSet();
|
|
98
|
-
} else if (_instanceof(parent, NativePromise)) {
|
|
99
|
-
child = new NativePromise(function (resolve, reject) {
|
|
100
|
-
parent.then(function (value) {
|
|
101
|
-
resolve(_clone(value, depth - 1));
|
|
102
|
-
}, function (err) {
|
|
103
|
-
reject(_clone(err, depth - 1));
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
} else if (clone.__isArray(parent)) {
|
|
107
|
-
child = [];
|
|
108
|
-
} else if (clone.__isRegExp(parent)) {
|
|
109
|
-
child = new RegExp(parent.source, __getRegExpFlags(parent));
|
|
110
|
-
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
|
111
|
-
} else if (clone.__isDate(parent)) {
|
|
112
|
-
child = new Date(parent.getTime());
|
|
113
|
-
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
114
|
-
child = Buffer.alloc(parent.length);
|
|
115
|
-
parent.copy(child);
|
|
116
|
-
return child;
|
|
117
|
-
} else if (_instanceof(parent, Error)) {
|
|
118
|
-
child = Object.create(parent);
|
|
119
|
-
} else {
|
|
120
|
-
if (typeof prototype == "undefined") {
|
|
121
|
-
proto = Object.getPrototypeOf(parent);
|
|
122
|
-
child = Object.create(proto);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
child = Object.create(prototype);
|
|
126
|
-
proto = prototype;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (circular) {
|
|
131
|
-
let index = allParents.indexOf(parent);
|
|
132
|
-
|
|
133
|
-
if (index != -1) {
|
|
134
|
-
return allChildren[index];
|
|
135
|
-
}
|
|
136
|
-
allParents.push(parent);
|
|
137
|
-
allChildren.push(child);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (_instanceof(parent, NativeMap)) {
|
|
141
|
-
parent.forEach(function (value, key) {
|
|
142
|
-
let keyChild = _clone(key, depth - 1);
|
|
143
|
-
let valueChild = _clone(value, depth - 1);
|
|
144
|
-
child.set(keyChild, valueChild);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (_instanceof(parent, NativeSet)) {
|
|
148
|
-
parent.forEach(function (value) {
|
|
149
|
-
let entryChild = _clone(value, depth - 1);
|
|
150
|
-
child.add(entryChild);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
for (let i in parent) {
|
|
155
|
-
let attrs;
|
|
156
|
-
if (proto) {
|
|
157
|
-
attrs = Object.getOwnPropertyDescriptor(proto, i);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (attrs && attrs.set == null) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
child[i] = _clone(parent[i], depth - 1);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (Object.getOwnPropertySymbols) {
|
|
167
|
-
let symbols = Object.getOwnPropertySymbols(parent);
|
|
168
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
169
|
-
// Don't need to worry about cloning a symbol because it is a primitive,
|
|
170
|
-
// like a number or string.
|
|
171
|
-
let symbol = symbols[i];
|
|
172
|
-
let descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
|
|
173
|
-
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
child[symbol] = _clone(parent[symbol], depth - 1);
|
|
177
|
-
if (!descriptor.enumerable) {
|
|
178
|
-
Object.defineProperty(child, symbol, {
|
|
179
|
-
enumerable: false
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (includeNonEnumerable) {
|
|
186
|
-
let allPropertyNames = Object.getOwnPropertyNames(parent);
|
|
187
|
-
for (let i = 0; i < allPropertyNames.length; i++) {
|
|
188
|
-
let propertyName = allPropertyNames[i];
|
|
189
|
-
let descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
|
|
190
|
-
if (descriptor && descriptor.enumerable) {
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
child[propertyName] = _clone(parent[propertyName], depth - 1);
|
|
194
|
-
Object.defineProperty(child, propertyName, {
|
|
195
|
-
enumerable: false
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return child;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return _clone(parent, depth);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Simple flat clone using prototype, accepts only objects, usefull for property
|
|
208
|
-
* override on FLAT configuration object (no nested props).
|
|
209
|
-
*
|
|
210
|
-
* USE WITH CAUTION! This may not behave as you wish if you do not know how this
|
|
211
|
-
* works.
|
|
212
|
-
*/
|
|
213
|
-
clone.clonePrototype = function clonePrototype (parent) {
|
|
214
|
-
if (parent === null)
|
|
215
|
-
{ return null; }
|
|
216
|
-
|
|
217
|
-
let C = function () {};
|
|
218
|
-
C.prototype = parent;
|
|
219
|
-
return new C();
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
// private utility functions
|
|
223
|
-
|
|
224
|
-
function __objToStr (o) {
|
|
225
|
-
return Object.prototype.toString.call(o);
|
|
226
|
-
}
|
|
227
|
-
clone.__objToStr = __objToStr;
|
|
228
|
-
|
|
229
|
-
function __isDate (o) {
|
|
230
|
-
return typeof o === "object" && __objToStr(o) === "[object Date]";
|
|
231
|
-
}
|
|
232
|
-
clone.__isDate = __isDate;
|
|
233
|
-
|
|
234
|
-
function __isArray (o) {
|
|
235
|
-
return typeof o === "object" && __objToStr(o) === "[object Array]";
|
|
236
|
-
}
|
|
237
|
-
clone.__isArray = __isArray;
|
|
238
|
-
|
|
239
|
-
function __isRegExp (o) {
|
|
240
|
-
return typeof o === "object" && __objToStr(o) === "[object RegExp]";
|
|
241
|
-
}
|
|
242
|
-
clone.__isRegExp = __isRegExp;
|
|
243
|
-
|
|
244
|
-
function __getRegExpFlags (re) {
|
|
245
|
-
let flags = "";
|
|
246
|
-
if (re.global) flags += "g";
|
|
247
|
-
if (re.ignoreCase) flags += "i";
|
|
248
|
-
if (re.multiline) flags += "m";
|
|
249
|
-
return flags;
|
|
250
|
-
}
|
|
251
|
-
clone.__getRegExpFlags = __getRegExpFlags;
|
|
252
|
-
|
|
253
|
-
return clone;
|
|
254
|
-
})();
|
|
255
|
-
|
|
256
|
-
export default clone;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// has class
|
|
3
|
-
export function hasClass (el, cls) {
|
|
4
|
-
if (!el || !cls) return false;
|
|
5
|
-
if (cls.indexOf(" ") !== -1) throw new Error("className should not contain space.");
|
|
6
|
-
if (el.classList) {
|
|
7
|
-
return el.classList.contains(cls);
|
|
8
|
-
} else {
|
|
9
|
-
return (" " + el.className + " ").indexOf(" " + cls + " ") > -1;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// add class
|
|
14
|
-
export function addClass (el, cls) {
|
|
15
|
-
if (!el || !cls) return;
|
|
16
|
-
|
|
17
|
-
if (el.classList) {
|
|
18
|
-
el.classList.add(cls);
|
|
19
|
-
|
|
20
|
-
} else {
|
|
21
|
-
|
|
22
|
-
let clsArr = el.className.split(" ");
|
|
23
|
-
|
|
24
|
-
if (clsArr.indexOf(cls) === -1) {
|
|
25
|
-
el.className += " " + cls;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// remove class
|
|
31
|
-
export function removeClass (el, cls) {
|
|
32
|
-
if (!el || !cls) return;
|
|
33
|
-
|
|
34
|
-
if (el.classList) {
|
|
35
|
-
el.classList.remove(cls);
|
|
36
|
-
} else {
|
|
37
|
-
|
|
38
|
-
let reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
|
39
|
-
el.className = el.className.replace(reg, " "); // For IE9 and earlier
|
|
40
|
-
}
|
|
41
|
-
};
|