@opentiny/vue-renderless 3.1.0-alpha.0 → 3.5.0
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/action-menu/index.js +10 -0
- package/action-menu/vue.js +26 -0
- package/amount/index.js +334 -0
- package/amount/vue.js +206 -0
- package/area/index.js +162 -0
- package/area/vue.js +68 -0
- package/autonavi-map/index.js +28 -0
- package/avatar/index.js +5 -1
- package/avatar/vue.js +2 -1
- package/baidu-map/index.js +28 -0
- package/breadcrumb/index.js +9 -0
- package/breadcrumb/vue.js +25 -3
- package/breadcrumb-item/index.js +26 -0
- package/breadcrumb-item/vue.js +20 -11
- package/bulletin-board/index.js +4 -1
- package/button-group/vue.js +1 -1
- package/calendar/index.js +14 -14
- package/card-template/index.js +1 -1
- package/cascader/index.js +21 -7
- package/cascader/vue.js +1 -2
- package/cascader-node/index.js +3 -1
- package/cascader-panel/index.js +12 -4
- package/cascader-panel/vue.js +1 -2
- package/chart-bar/index.js +533 -0
- package/chart-boxplot/index.js +270 -0
- package/chart-candle/index.js +428 -0
- package/chart-core/deps/constants.js +65 -0
- package/chart-core/deps/numerify.js +286 -0
- package/chart-core/deps/utils.js +205 -0
- package/chart-core/index.js +541 -0
- package/chart-core/modules/animation.js +10 -0
- package/chart-core/modules/extend.js +36 -0
- package/chart-core/modules/mark.js +7 -0
- package/chart-core/vue.js +128 -0
- package/chart-funnel/index.js +155 -0
- package/chart-gauge/index.js +153 -0
- package/chart-graph/index.js +38 -0
- package/chart-heatmap/index.js +407 -0
- package/chart-line/index.js +358 -0
- package/chart-liquidfill/index.js +119 -0
- package/chart-map/index.js +261 -0
- package/chart-pie/index.js +327 -0
- package/chart-radar/index.js +181 -0
- package/chart-sankey/index.js +166 -0
- package/chart-scatter/index.js +360 -0
- package/chart-sunburst/index.js +36 -0
- package/chart-tree/index.js +107 -0
- package/chart-waterfall/index.js +231 -0
- package/chart-wordcloud/index.js +109 -0
- package/checkbox/index.js +4 -4
- package/checkbox-button/index.js +3 -1
- package/common/bigInt.js +5 -2
- package/common/date.js +17 -17
- package/common/deps/date-util.js +15 -5
- package/common/deps/date.js +6 -6
- package/common/deps/dom.js +18 -6
- package/common/deps/eSpaceCtrl.js +286 -0
- package/common/deps/fullscreen/apis.js +22 -22
- package/common/deps/memorize.js +3 -3
- package/common/deps/modal-queue.js +2 -0
- package/common/deps/popper.js +12 -10
- package/common/deps/popup-manager.js +16 -5
- package/common/deps/resize-event.js +6 -2
- package/common/deps/scrollbar-width.js +6 -2
- package/common/deps/tree-model/node.js +30 -10
- package/common/deps/tree-model/tree-store.js +33 -21
- package/common/deps/tree-model/util.js +6 -2
- package/common/deps/upload-ajax.js +7 -1
- package/common/deps/vue-popper.js +2 -2
- package/common/string.js +1 -1
- package/company/index.js +56 -0
- package/company/vue.js +35 -0
- package/country/index.js +54 -0
- package/country/vue.js +35 -0
- package/credit-card-form/index.js +1 -0
- package/currency/index.js +78 -0
- package/currency/vue.js +39 -0
- package/date-panel/index.js +16 -6
- package/date-picker/index.js +9 -5
- package/date-range/index.js +28 -9
- package/date-table/index.js +3 -1
- package/dept/index.js +318 -0
- package/dept/vue.js +163 -0
- package/detail-page/index.js +4 -1
- package/dialog-box/index.js +14 -4
- package/dialog-box/vue.js +7 -3
- package/drop-roles/index.js +73 -0
- package/drop-roles/vue.js +38 -0
- package/dropdown/index.js +5 -4
- package/dropdown/vue.js +5 -3
- package/dropdown-item/index.js +15 -0
- package/dropdown-item/vue.js +27 -13
- package/espace/index.js +129 -0
- package/espace/vue.js +52 -0
- package/exception/index.js +1 -1
- package/file-upload/index.js +336 -291
- package/form/index.js +3 -1
- package/form/vue.js +15 -0
- package/form-item/index.js +15 -5
- package/fullscreen/index.js +4 -4
- package/fullscreen/vue.js +3 -3
- package/grid/core/interceptor.js +4 -7
- package/grid/plugins/export.js +2 -2
- package/grid/plugins/exportExcel.js +28 -10
- package/grid/static/array/findTree.js +1 -1
- package/grid/static/base/helperCreateGetObjects.js +1 -1
- package/grid/static/base/helperEqualCompare.js +2 -2
- package/grid/static/base/helperGetHGSKeys.js +1 -1
- package/grid/static/base/uniqueId.js +1 -1
- package/grid/static/object/assign.js +3 -3
- package/grid/static/string/toString.js +3 -3
- package/hrapprover/index.js +118 -0
- package/hrapprover/vue.js +102 -0
- package/locales/index.js +116 -0
- package/locales/vue.js +46 -0
- package/logon-user/index.js +23 -0
- package/logon-user/vue.js +22 -0
- package/logout/index.js +118 -0
- package/logout/vue.js +22 -0
- package/milestone/index.js +2 -1
- package/mini-picker/index.js +1 -1
- package/mini-picker/vue.js +1 -1
- package/modal/index.js +4 -2
- package/month-table/index.js +2 -2
- package/nav-menu/index.js +2 -2
- package/numeric/index.js +5 -2
- package/package.json +33 -136
- package/pager-item/vue.js +6 -2
- package/picker/index.js +43 -17
- package/picker/timezone.js +2 -2
- package/picker-column/index.js +7 -3
- package/pop-upload/index.js +5 -3
- package/popeditor/index.js +15 -7
- package/popover/index.js +87 -54
- package/popover/vue.js +13 -9
- package/rate/index.js +2 -2
- package/rich-text/clipboard.js +77 -0
- package/rich-text/index.js +176 -0
- package/rich-text/module/file-upload.js +118 -0
- package/rich-text/module/image-drop.js +54 -0
- package/rich-text/module/image-upload.js +84 -0
- package/rich-text/options.js +187 -0
- package/rich-text/table-module.js +557 -0
- package/rich-text/vue.js +149 -0
- package/roles/index.js +87 -0
- package/roles/vue.js +39 -0
- package/search/index.js +32 -27
- package/search/vue.js +7 -2
- package/select/index.js +328 -304
- package/select/vue.js +19 -9
- package/select-dropdown/index.js +1 -1
- package/slider/index.js +9 -11
- package/slider/vue.js +3 -3
- package/split/vue.js +1 -1
- package/tab-nav/index.js +0 -6
- package/tab-nav/vue.js +0 -14
- package/table/index.js +1 -1
- package/text-popup/index.js +6 -4
- package/time/index.js +3 -1
- package/time-range/index.js +6 -2
- package/time-spinner/index.js +15 -5
- package/toggle-menu/index.js +11 -0
- package/toggle-menu/vue.js +2 -1
- package/tooltip/index.js +46 -35
- package/tooltip/vue.js +5 -1
- package/tree/index.js +57 -21
- package/tree-menu/index.js +3 -1
- package/tree-node/index.js +7 -3
- package/upload/index.js +14 -5
- package/user/index.js +634 -0
- package/user/vue.js +113 -0
- package/user-account/index.js +23 -0
- package/user-account/vue.js +25 -0
- package/user-contact/index.js +1 -4
- package/user-head/index.js +33 -11
- package/user-head/vue.js +10 -7
- package/user-link/index.js +43 -0
- package/user-link/vue.js +60 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var sf = function sf() {
|
|
2
|
+
return {
|
|
3
|
+
show: false
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
var DEFAULT_THEME = {
|
|
7
|
+
categoryAxis: {
|
|
8
|
+
axisLine: sf(),
|
|
9
|
+
axisTick: sf(),
|
|
10
|
+
splitLine: sf()
|
|
11
|
+
},
|
|
12
|
+
valueAxis: {
|
|
13
|
+
axisLine: sf()
|
|
14
|
+
},
|
|
15
|
+
line: {
|
|
16
|
+
smooth: true
|
|
17
|
+
},
|
|
18
|
+
grid: {
|
|
19
|
+
containLabel: true,
|
|
20
|
+
left: 10,
|
|
21
|
+
right: 10
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var DEFAULT_COLORS = ['#19d4ae', '#5ab1ef', '#fa6e86', '#ffb980', '#0067a6', '#c4b4e4'];
|
|
25
|
+
DEFAULT_COLORS = DEFAULT_COLORS.concat(['#d87a80', '#9cbbff', '#d9d0c7', '#87a997', '#d49ea2', '#5b4947', '#7ba3a8']);
|
|
26
|
+
var HEAT_MAP_COLOR = ['#5990FD', '#2DA769', '#EEBA18', '#F43146'];
|
|
27
|
+
var HEAT_BMAP_COLOR = ['blue', 'blue', 'green', 'yellow', 'red'];
|
|
28
|
+
var SAAS_DEFAULT_COLORS_10 = ['#6d8ff0', '#00a874', '#bd72f0', '#54bcce', '#fdc000', '#9185f0', '#82dbb1', '#f46087', '#2070f3', '#ee8ddb'];
|
|
29
|
+
var SAAS_DEFAULT_COLORS_18 = ['#2070f3', '#50c291', '#bd72f0', '#54bcce', '#fdc000', '#6d8ff0', '#71c14c', '#87d5e5', '#9185f0', '#82dbb1', '#ada6ed', '#97da7e', '#f46087', '#ee8ddb', '#f09596', '#f36900', '#daa61b', '#efb9e3'];
|
|
30
|
+
var DEFAULT_CONFIG = {
|
|
31
|
+
tooltip: {
|
|
32
|
+
backgroundColor: '#fff',
|
|
33
|
+
borderColor: '#fff',
|
|
34
|
+
padding: [8, 16],
|
|
35
|
+
textStyle: {
|
|
36
|
+
color: '#191919',
|
|
37
|
+
fontSize: '14'
|
|
38
|
+
},
|
|
39
|
+
extraCssText: 'box-shadow:0 8px 20px rgba(0, 0, 0, 0.16);'
|
|
40
|
+
},
|
|
41
|
+
legend: {
|
|
42
|
+
icon: 'circle',
|
|
43
|
+
bottom: 0,
|
|
44
|
+
itemGap: 24,
|
|
45
|
+
itemWidth: 10,
|
|
46
|
+
itemHeight: 10,
|
|
47
|
+
itemStyle: {
|
|
48
|
+
borderColor: 'transparent'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var itemPoint = function itemPoint(color) {
|
|
53
|
+
return ['<span style="', "background-color:".concat(color, ";"), 'display: inline-block;', 'width: 6px;', 'height: 6px;', 'border-radius: 50%;', 'margin-right:8px;', 'vertical-align:middle;', '"></span>'].join('');
|
|
54
|
+
};
|
|
55
|
+
var itemLabel = function itemLabel(seriesName, onlyLabel) {
|
|
56
|
+
return ['<span style="', 'display:inline-block;', 'font-size:12px;', 'color:#4E4E4E;', "".concat(onlyLabel ? '' : 'margin-right:25px;'), "\">".concat(seriesName, "</span>")].join('');
|
|
57
|
+
};
|
|
58
|
+
var itemContent = function itemContent(content) {
|
|
59
|
+
return ['<span style="', 'float:right;', 'font-size:14px;', 'color:#191919;', "\">".concat(content, "</span>")].join('');
|
|
60
|
+
};
|
|
61
|
+
var STATIC_PROPS = ['initOptions', 'loading', 'dataEmpty', 'judgeWidth', 'widthChangeDelay'];
|
|
62
|
+
var ECHARTS_SETTINGS = ['grid', 'dataZoom', 'visualMap', 'toolbox', 'title', 'legend', 'xAxis'];
|
|
63
|
+
ECHARTS_SETTINGS = ECHARTS_SETTINGS.concat(['yAxis', 'radar', 'tooltip', 'axisPointer', 'brush', 'geo']);
|
|
64
|
+
ECHARTS_SETTINGS = ECHARTS_SETTINGS.concat(['timeline', 'graphic', 'series', 'backgroundColor', 'textStyle']);
|
|
65
|
+
export { DEFAULT_THEME, DEFAULT_COLORS, HEAT_MAP_COLOR, HEAT_BMAP_COLOR, itemPoint, itemLabel, itemContent, STATIC_PROPS, ECHARTS_SETTINGS, DEFAULT_CONFIG, SAAS_DEFAULT_COLORS_10, SAAS_DEFAULT_COLORS_18 };
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
var ABBR = {
|
|
2
|
+
th: 3,
|
|
3
|
+
mi: 6,
|
|
4
|
+
bi: 9,
|
|
5
|
+
tr: 12
|
|
6
|
+
};
|
|
7
|
+
var abbrLabel = {
|
|
8
|
+
th: 'k',
|
|
9
|
+
mi: 'm',
|
|
10
|
+
bi: 'b',
|
|
11
|
+
tr: 't'
|
|
12
|
+
};
|
|
13
|
+
var DEFAULT_OPTIONS = {
|
|
14
|
+
zeroFormat: null,
|
|
15
|
+
nullFormat: null,
|
|
16
|
+
defaultFormat: '0,0',
|
|
17
|
+
scalePercentBy100: true,
|
|
18
|
+
abbrLabel: abbrLabel
|
|
19
|
+
};
|
|
20
|
+
var TRILLION = 1e12,
|
|
21
|
+
BILLION = 1e9,
|
|
22
|
+
MILLION = 1e6,
|
|
23
|
+
THOUSAND = 1e3;
|
|
24
|
+
var numIsNaN = function numIsNaN(value) {
|
|
25
|
+
return typeof value === 'number' && isNaN(value);
|
|
26
|
+
};
|
|
27
|
+
var options = {};
|
|
28
|
+
var formats = {};
|
|
29
|
+
function getBoundedPrecision(value, maxDecimals, optionals) {
|
|
30
|
+
var splitValue = value.toString().split('e-');
|
|
31
|
+
var exponent = splitValue.length === 2 ? Number(splitValue[1]) : 0;
|
|
32
|
+
splitValue = splitValue[0].split('.');
|
|
33
|
+
exponent = splitValue.length === 2 ? splitValue[1].length + exponent : exponent;
|
|
34
|
+
var minDecimals = maxDecimals - (optionals || 0);
|
|
35
|
+
return Math.min(Math.max(exponent, minDecimals), maxDecimals);
|
|
36
|
+
}
|
|
37
|
+
function toFixed(value, maxDecimals, roundingFunction, optionals) {
|
|
38
|
+
var boundedPrecision = getBoundedPrecision(value, maxDecimals, optionals);
|
|
39
|
+
var power = Math.pow(10, boundedPrecision);
|
|
40
|
+
var output = (roundingFunction(value * "1e+".concat(boundedPrecision)) / power).toFixed(boundedPrecision);
|
|
41
|
+
if (optionals > maxDecimals - boundedPrecision) {
|
|
42
|
+
var optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$');
|
|
43
|
+
output = output.replace(optionalsRegExp, '');
|
|
44
|
+
}
|
|
45
|
+
return output;
|
|
46
|
+
}
|
|
47
|
+
function judgForFunc(num, abs, abbrForce) {
|
|
48
|
+
var flag;
|
|
49
|
+
if (num === 0) {
|
|
50
|
+
flag = abs >= TRILLION && !abbrForce || abbrForce === 't';
|
|
51
|
+
} else if (num === 1) {
|
|
52
|
+
flag = abs < TRILLION && abs >= BILLION && !abbrForce || abbrForce === 'b';
|
|
53
|
+
} else if (num === 2) {
|
|
54
|
+
flag = abs < BILLION && abs >= MILLION && !abbrForce || abbrForce === 'm';
|
|
55
|
+
} else if (num === 3) {
|
|
56
|
+
flag = abs < MILLION && abs >= THOUSAND && !abbrForce || abbrForce === 'k';
|
|
57
|
+
}
|
|
58
|
+
return flag;
|
|
59
|
+
}
|
|
60
|
+
var negativeSigned = function negativeSigned(_ref) {
|
|
61
|
+
var format = _ref.format,
|
|
62
|
+
value = _ref.value;
|
|
63
|
+
return ~format.indexOf('+') ? format.indexOf('+') : value < 0 ? format.indexOf('-') : -1;
|
|
64
|
+
};
|
|
65
|
+
var updateAbbrV = function updateAbbrV(params) {
|
|
66
|
+
var abbr = params.abbr,
|
|
67
|
+
abbrForce = params.abbrForce,
|
|
68
|
+
format = params.format,
|
|
69
|
+
value = params.value,
|
|
70
|
+
abs = params.abs;
|
|
71
|
+
abbrForce = format.match(/a(k|m|b|t)?/);
|
|
72
|
+
abbrForce = abbrForce ? abbrForce[1] : false;
|
|
73
|
+
if (~format.indexOf(' a')) {
|
|
74
|
+
abbr = ' ';
|
|
75
|
+
}
|
|
76
|
+
format = format.replace(new RegExp(abbr + 'a[kmbt]?'), '');
|
|
77
|
+
if (judgForFunc(0, abs, abbrForce)) {
|
|
78
|
+
abbr += options.abbrLabel.tr;
|
|
79
|
+
value = value / TRILLION;
|
|
80
|
+
} else if (judgForFunc(1, abs, abbrForce)) {
|
|
81
|
+
abbr += options.abbrLabel.bi;
|
|
82
|
+
value = value / BILLION;
|
|
83
|
+
} else if (judgForFunc(2, abs, abbrForce)) {
|
|
84
|
+
abbr += options.abbrLabel.mi;
|
|
85
|
+
value = value / MILLION;
|
|
86
|
+
} else if (judgForFunc(3, abs, abbrForce)) {
|
|
87
|
+
abbr += options.abbrLabel.th;
|
|
88
|
+
value = value / THOUSAND;
|
|
89
|
+
}
|
|
90
|
+
Object.assign(params, {
|
|
91
|
+
abbr: abbr,
|
|
92
|
+
abbrForce: abbrForce,
|
|
93
|
+
format: format,
|
|
94
|
+
value: value,
|
|
95
|
+
abs: abs
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
var handlePrecision = function handlePrecision(params) {
|
|
99
|
+
var roundingFunction = params.roundingFunction,
|
|
100
|
+
value = params.value,
|
|
101
|
+
format = params.format;
|
|
102
|
+
var number = value.toString().split('.')[0];
|
|
103
|
+
var precision = format.split('.')[1];
|
|
104
|
+
if (precision) {
|
|
105
|
+
if (~precision.indexOf('[')) {
|
|
106
|
+
precision = precision.replace(']', '');
|
|
107
|
+
precision = precision.split('[');
|
|
108
|
+
params.decimal = toFixed(value, precision[0].length + precision[1].length, roundingFunction, precision[1].length);
|
|
109
|
+
} else {
|
|
110
|
+
params.decimal = toFixed(value, precision.length, roundingFunction);
|
|
111
|
+
}
|
|
112
|
+
number = params.decimal.split('.')[0];
|
|
113
|
+
params.decimal = ~params.decimal.indexOf('.') ? '.' + params.decimal.split('.')[1] : '';
|
|
114
|
+
if (params.optDec && Number(params.decimal.slice(1)) === 0) {
|
|
115
|
+
params.decimal = '';
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
number = toFixed(value, 0, roundingFunction);
|
|
119
|
+
}
|
|
120
|
+
return number;
|
|
121
|
+
};
|
|
122
|
+
function formatNumber(params) {
|
|
123
|
+
var number = handlePrecision(params);
|
|
124
|
+
var thousands = params.format.indexOf(',');
|
|
125
|
+
var leadingCount = (params.format.split('.')[0].split(',')[0].match(/0/g) || []).length;
|
|
126
|
+
if (params.abbr && !params.abbrForce && Number(number) >= 1000 && params.abbr !== ABBR.trillion) {
|
|
127
|
+
number = String(Number(number) / 1000);
|
|
128
|
+
params.abbr = ABBR.million;
|
|
129
|
+
}
|
|
130
|
+
if (~number.indexOf('-')) {
|
|
131
|
+
number = number.slice(1);
|
|
132
|
+
params.neg = true;
|
|
133
|
+
}
|
|
134
|
+
if (number.length < leadingCount) {
|
|
135
|
+
for (var i = leadingCount - number.length; i > 0; i--) {
|
|
136
|
+
number = '0' + number;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (thousands > -1) {
|
|
140
|
+
number = number.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
|
|
141
|
+
}
|
|
142
|
+
if (!params.format.indexOf('.')) {
|
|
143
|
+
number = '';
|
|
144
|
+
}
|
|
145
|
+
return number;
|
|
146
|
+
}
|
|
147
|
+
function getOutStr(_ref2, number) {
|
|
148
|
+
var decimal = _ref2.decimal,
|
|
149
|
+
negFlag = _ref2.negFlag,
|
|
150
|
+
neg = _ref2.neg,
|
|
151
|
+
signed = _ref2.signed,
|
|
152
|
+
abbr = _ref2.abbr;
|
|
153
|
+
var outStr = number + decimal + (abbr || '');
|
|
154
|
+
if (negFlag) {
|
|
155
|
+
outStr = negFlag && neg ? "(".concat(outStr, ")") : outStr;
|
|
156
|
+
} else {
|
|
157
|
+
if (signed >= 0) {
|
|
158
|
+
var symbol = neg ? '-' : '+';
|
|
159
|
+
outStr = signed === 0 ? symbol + outStr : outStr + symbol;
|
|
160
|
+
} else if (neg) {
|
|
161
|
+
outStr = '-' + outStr;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return outStr;
|
|
165
|
+
}
|
|
166
|
+
function numberToFormat(options, value, format, roundingFunction) {
|
|
167
|
+
var params = {
|
|
168
|
+
abs: Math.abs(value),
|
|
169
|
+
negFlag: false,
|
|
170
|
+
optDec: false,
|
|
171
|
+
abbr: '',
|
|
172
|
+
decimal: '',
|
|
173
|
+
neg: false,
|
|
174
|
+
abbrForce: void 0,
|
|
175
|
+
signed: void 0,
|
|
176
|
+
format: format || '',
|
|
177
|
+
value: value || 0,
|
|
178
|
+
roundingFunction: roundingFunction
|
|
179
|
+
};
|
|
180
|
+
if (~format.indexOf('(')) {
|
|
181
|
+
params.negFlag = true;
|
|
182
|
+
params.format = format.replace(/[(|)]/g, '');
|
|
183
|
+
} else if (~params.format.indexOf('+') || ~params.format.indexOf('-')) {
|
|
184
|
+
params.signed = negativeSigned(params);
|
|
185
|
+
params.format = format.replace(/[+|-]/g, '');
|
|
186
|
+
}
|
|
187
|
+
if (~params.format.indexOf('a')) {
|
|
188
|
+
updateAbbrV(params);
|
|
189
|
+
}
|
|
190
|
+
if (~params.format.indexOf('[.]')) {
|
|
191
|
+
params.optDec = true;
|
|
192
|
+
params.format = format.replace('[.]', '.');
|
|
193
|
+
}
|
|
194
|
+
var number = formatNumber(params);
|
|
195
|
+
return getOutStr(params, number);
|
|
196
|
+
}
|
|
197
|
+
function extend(target, sub) {
|
|
198
|
+
Object.keys(sub).forEach(function (key) {
|
|
199
|
+
target[key] = sub[key];
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
var numerifyPercent = {
|
|
203
|
+
regexp: /%/,
|
|
204
|
+
format: function format(value, formatType, roundingFunction, numerify) {
|
|
205
|
+
var space = ~formatType.indexOf(' %') ? ' ' : '';
|
|
206
|
+
var outStr = void 0;
|
|
207
|
+
if (numerify.options.scalePercentBy100) {
|
|
208
|
+
value = value * 100;
|
|
209
|
+
}
|
|
210
|
+
formatType = formatType.replace(/\s?%/, '');
|
|
211
|
+
outStr = numerify._numberToFormat(value, formatType, roundingFunction);
|
|
212
|
+
if (~outStr.indexOf(')')) {
|
|
213
|
+
outStr = outStr.split('');
|
|
214
|
+
outStr.splice(-1, 0, space + '%');
|
|
215
|
+
outStr = outStr.join('');
|
|
216
|
+
} else {
|
|
217
|
+
outStr = outStr + space + '%';
|
|
218
|
+
}
|
|
219
|
+
return outStr;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
extend(options, DEFAULT_OPTIONS);
|
|
223
|
+
var numerify;
|
|
224
|
+
function format(value, formatType, roundingFunc) {
|
|
225
|
+
var zeroFormat = options.zeroFormat,
|
|
226
|
+
nullFormat = options.nullFormat,
|
|
227
|
+
defaultFormat = options.defaultFormat;
|
|
228
|
+
formatType = formatType || defaultFormat;
|
|
229
|
+
roundingFunc = roundingFunc || Math.round;
|
|
230
|
+
var _ref3 = {},
|
|
231
|
+
output = _ref3.output,
|
|
232
|
+
fmtFunc = _ref3.fmtFunc;
|
|
233
|
+
if (value === 0 && zeroFormat !== null) {
|
|
234
|
+
output = zeroFormat;
|
|
235
|
+
} else if (value === null && nullFormat !== null) {
|
|
236
|
+
output = nullFormat;
|
|
237
|
+
} else {
|
|
238
|
+
for (var key in formats) {
|
|
239
|
+
if (formats[key] && formatType.match(formats[key].regexp)) {
|
|
240
|
+
fmtFunc = formats[key].format;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
fmtFunc = fmtFunc || numberToFormat.bind(null, options);
|
|
245
|
+
output = fmtFunc(value, formatType, roundingFunc, numerify);
|
|
246
|
+
}
|
|
247
|
+
return output;
|
|
248
|
+
}
|
|
249
|
+
numerify = function numerify(input, formatType, roundingFunc) {
|
|
250
|
+
var zeroFormat = options.zeroFormat,
|
|
251
|
+
nullFormat = options.nullFormat;
|
|
252
|
+
var value = Number(input) || null;
|
|
253
|
+
if (typeof input === 'undefined' || input === 0) {
|
|
254
|
+
value = 0;
|
|
255
|
+
} else if (numIsNaN(input) || input === null) {
|
|
256
|
+
value = null;
|
|
257
|
+
} else if (typeof input === 'string') {
|
|
258
|
+
value = Number(input);
|
|
259
|
+
if (input === zeroFormat && zeroFormat) {
|
|
260
|
+
value = 0;
|
|
261
|
+
} else if (input === nullFormat && nullFormat || !input.replace(/[^0-9]+/g, '').length) {
|
|
262
|
+
value = null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return format(value, formatType, roundingFunc);
|
|
266
|
+
};
|
|
267
|
+
var _register = function _register(name, format) {
|
|
268
|
+
formats[name] = format;
|
|
269
|
+
};
|
|
270
|
+
var _unregister = function _unregister(name) {
|
|
271
|
+
formats[name] = null;
|
|
272
|
+
};
|
|
273
|
+
var _setOptions = function _setOptions(opts) {
|
|
274
|
+
extend(options, opts);
|
|
275
|
+
};
|
|
276
|
+
var _reset = function _reset() {
|
|
277
|
+
extend(options, DEFAULT_OPTIONS);
|
|
278
|
+
};
|
|
279
|
+
numerify.options = options;
|
|
280
|
+
numerify._numberToFormat = numberToFormat.bind(null, options);
|
|
281
|
+
numerify.register = _register;
|
|
282
|
+
numerify.unregister = _unregister;
|
|
283
|
+
numerify.setOptions = _setOptions;
|
|
284
|
+
numerify.reset = _reset;
|
|
285
|
+
numerify.register('percentage', numerifyPercent);
|
|
286
|
+
export default numerify;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
import { extend, copyArray } from '@opentiny/vue-renderless/common/object';
|
|
6
|
+
import { isObject, typeOf as getType, isNull } from '@opentiny/vue-renderless/common/type';
|
|
7
|
+
import _debounce from '@opentiny/vue-renderless/common/deps/debounce';
|
|
8
|
+
import _numerify from './numerify';
|
|
9
|
+
import { escapeHtml } from '@opentiny/vue-renderless/common/string';
|
|
10
|
+
import { xss } from '@opentiny/vue-renderless/common';
|
|
11
|
+
export { setObj as set, getObj as get, isEqual } from '@opentiny/vue-renderless/common/object';
|
|
12
|
+
export { typeOf as getType, isObject } from '@opentiny/vue-renderless/common/type';
|
|
13
|
+
export var debounce = function debounce(callback, delay) {
|
|
14
|
+
return _debounce(delay, false, callback);
|
|
15
|
+
};
|
|
16
|
+
export var camelToKebab = function camelToKebab(str) {
|
|
17
|
+
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
18
|
+
};
|
|
19
|
+
export var cloneDeep = function cloneDeep(data) {
|
|
20
|
+
if (isObject(data)) {
|
|
21
|
+
return extend(true, data);
|
|
22
|
+
} else if (Array.isArray(data)) {
|
|
23
|
+
return copyArray(data);
|
|
24
|
+
} else {
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export var getFormated = function getFormated(value, type, digit) {
|
|
29
|
+
var defaultVal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '-';
|
|
30
|
+
if (isNaN(value)) {
|
|
31
|
+
return defaultVal;
|
|
32
|
+
}
|
|
33
|
+
if (!type) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
if (getType(type) === 'function') {
|
|
37
|
+
return type(value, _numerify);
|
|
38
|
+
}
|
|
39
|
+
digit = !isNaN(digit) ? ++digit : 0;
|
|
40
|
+
var digitStr = ".[".concat(new Array(digit).join(0), "]");
|
|
41
|
+
var formatter = type;
|
|
42
|
+
if (type === 'KMB') {
|
|
43
|
+
formatter = digit ? "0,0".concat(digitStr, "a") : '0,0a';
|
|
44
|
+
} else if (type === 'normal') {
|
|
45
|
+
formatter = digit ? "0,0".concat(digitStr) : '0,0';
|
|
46
|
+
} else if (type === 'percent') {
|
|
47
|
+
formatter = digit ? "0,0".concat(digitStr, "%") : '0,0.[00]%';
|
|
48
|
+
}
|
|
49
|
+
return _numerify(value, formatter);
|
|
50
|
+
};
|
|
51
|
+
export var getStackMap = function getStackMap(stack) {
|
|
52
|
+
var result = {};
|
|
53
|
+
Object.keys(stack).forEach(function (item) {
|
|
54
|
+
stack[item].forEach(function (name) {
|
|
55
|
+
result[name] = item;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
export var $get = function $get(url) {
|
|
61
|
+
return new Promise(function (resolve, reject) {
|
|
62
|
+
var http = new XMLHttpRequest();
|
|
63
|
+
url = xss.filterUrl(url);
|
|
64
|
+
http.open('GET', url);
|
|
65
|
+
http.send(null);
|
|
66
|
+
http.onload = function () {
|
|
67
|
+
resolve(JSON.parse(http.responseText));
|
|
68
|
+
};
|
|
69
|
+
http.onerror = function () {
|
|
70
|
+
reject(JSON.parse(http.responseText));
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
var mapPromise = {};
|
|
75
|
+
export var getMapJSON = function getMapJSON(_ref) {
|
|
76
|
+
var position = _ref.position,
|
|
77
|
+
positionJsonLink = _ref.positionJsonLink,
|
|
78
|
+
beforeRegisterMapOnce = _ref.beforeRegisterMapOnce,
|
|
79
|
+
_ref$mapURLProfix = _ref.mapURLProfix,
|
|
80
|
+
mapURLProfix = _ref$mapURLProfix === void 0 ? '' : _ref$mapURLProfix;
|
|
81
|
+
var link = positionJsonLink || "".concat(mapURLProfix).concat(position, ".json");
|
|
82
|
+
if (!mapPromise[link]) {
|
|
83
|
+
mapPromise[link] = $get(link).then(function (res) {
|
|
84
|
+
if (beforeRegisterMapOnce) {
|
|
85
|
+
res = beforeRegisterMapOnce(res);
|
|
86
|
+
}
|
|
87
|
+
return res;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return mapPromise[link];
|
|
91
|
+
};
|
|
92
|
+
var _ref2 = {},
|
|
93
|
+
_ref2$amapPromise = _ref2.amapPromise,
|
|
94
|
+
amapPromise = _ref2$amapPromise === void 0 ? null : _ref2$amapPromise,
|
|
95
|
+
_ref2$bmapPromise = _ref2.bmapPromise,
|
|
96
|
+
bmapPromise = _ref2$bmapPromise === void 0 ? null : _ref2$bmapPromise;
|
|
97
|
+
export var getAmap = function getAmap(_ref3) {
|
|
98
|
+
var key = _ref3.key,
|
|
99
|
+
version = _ref3.version,
|
|
100
|
+
url = _ref3.url;
|
|
101
|
+
if (!amapPromise) {
|
|
102
|
+
amapPromise = new Promise(function (resolve) {
|
|
103
|
+
var cbName = 'amap' + Date.now();
|
|
104
|
+
var script = document.createElement('script');
|
|
105
|
+
var ver = version || '1.4.3';
|
|
106
|
+
window[cbName] = resolve;
|
|
107
|
+
script.src = ["".concat(url, "?v=").concat(ver), "key=".concat(key), "callback=".concat(cbName)].join('&');
|
|
108
|
+
document.body.appendChild(script);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return amapPromise;
|
|
112
|
+
};
|
|
113
|
+
export var getBmap = function getBmap(_ref4) {
|
|
114
|
+
var key = _ref4.key,
|
|
115
|
+
version = _ref4.version,
|
|
116
|
+
url = _ref4.url;
|
|
117
|
+
if (!bmapPromise) {
|
|
118
|
+
bmapPromise = new Promise(function (resolve) {
|
|
119
|
+
var cbName = 'bmap' + Date.now();
|
|
120
|
+
var script = document.createElement('script');
|
|
121
|
+
var ver = version || '2.0';
|
|
122
|
+
window[cbName] = resolve;
|
|
123
|
+
script.src = ["".concat(url, "?v=").concat(ver), "ak=".concat(key), "callback=".concat(cbName)].join('&');
|
|
124
|
+
document.body.appendChild(script);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return bmapPromise;
|
|
128
|
+
};
|
|
129
|
+
export var setArrayValue = function setArrayValue(arr, index, value) {
|
|
130
|
+
var store = arr[index];
|
|
131
|
+
if (typeof store === 'undefined') {
|
|
132
|
+
arr[index] = [value];
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
store.push(value);
|
|
136
|
+
};
|
|
137
|
+
export var numerify = _numerify;
|
|
138
|
+
export var merge = function merge(source, other) {
|
|
139
|
+
if (_typeof(source) !== 'object' || _typeof(other) !== 'object') {
|
|
140
|
+
return other === undefined ? source : other;
|
|
141
|
+
}
|
|
142
|
+
return Object.keys(_objectSpread(_objectSpread({}, source), other)).reduce(function (acc, key) {
|
|
143
|
+
acc[key] = merge(source[key], other[key]);
|
|
144
|
+
return acc;
|
|
145
|
+
}, Array.isArray(source) ? [] : {});
|
|
146
|
+
};
|
|
147
|
+
export var htmlHandler = function htmlHandler(data) {
|
|
148
|
+
if (!data || !Array.isArray(data)) {
|
|
149
|
+
return data;
|
|
150
|
+
}
|
|
151
|
+
return cloneDeep(data).map(function (item) {
|
|
152
|
+
if (typeof item === 'string' && /<[a-z]+/i.test(item)) {
|
|
153
|
+
return escapeHtml(item);
|
|
154
|
+
} else if (_typeof(item) === 'object') {
|
|
155
|
+
for (var key in item) {
|
|
156
|
+
if (typeof item[key] === 'string' && /<[a-z]+/i.test(item[key])) {
|
|
157
|
+
item[key] = escapeHtml(item[key]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return item;
|
|
161
|
+
} else {
|
|
162
|
+
return item;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
export var getLegend = function getLegend(args, legendItemStyle) {
|
|
167
|
+
var metrics = args.metrics,
|
|
168
|
+
legendName = args.legendName,
|
|
169
|
+
labelMap = args.labelMap;
|
|
170
|
+
if (!labelMap && !legendName) {
|
|
171
|
+
return {
|
|
172
|
+
data: metrics
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
var data = labelMap ? metrics.map(function (item) {
|
|
176
|
+
return isNull(labelMap[item]) ? item : labelMap[item];
|
|
177
|
+
}) : metrics;
|
|
178
|
+
return _objectSpread(_objectSpread({}, legendItemStyle), {}, {
|
|
179
|
+
data: data,
|
|
180
|
+
formatter: function formatter(name) {
|
|
181
|
+
return isNull(legendName[name]) ? name : legendName[name];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
export var hexToRgb = function hexToRgb(hex) {
|
|
186
|
+
var reg = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})/;
|
|
187
|
+
if (!reg.test(hex)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
hex = hex.replace(/#/g, '').toLowerCase();
|
|
191
|
+
var len = hex.length;
|
|
192
|
+
if (len === 3) {
|
|
193
|
+
var t = '';
|
|
194
|
+
for (var i = 0; i < len; i++) {
|
|
195
|
+
t += hex.slice(i, i + 1).concat(hex.slice(i, i + 1));
|
|
196
|
+
}
|
|
197
|
+
hex = t;
|
|
198
|
+
}
|
|
199
|
+
var rgbs = [];
|
|
200
|
+
for (var _i = 0; _i < 6; _i += 2) {
|
|
201
|
+
var s = hex.slice(_i, _i + 2);
|
|
202
|
+
rgbs.push(parseInt(s, 16));
|
|
203
|
+
}
|
|
204
|
+
return rgbs.join(',');
|
|
205
|
+
};
|