hfn-components 0.2.7 → 0.2.8

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.
Files changed (89) hide show
  1. package/dist/index.css +1 -0
  2. package/es/_virtual/_plugin-vue_export-helper.mjs +9 -0
  3. package/es/component.d.ts +3 -0
  4. package/es/component.mjs +12 -0
  5. package/es/components/chart/index.d.ts +171 -0
  6. package/es/components/chart/index.mjs +7 -0
  7. package/es/components/chart/src/HtChart.d.ts +65 -0
  8. package/es/components/chart/src/HtChart.mjs +77 -0
  9. package/es/components/chart/src/HtChart.vue.d.ts +177 -0
  10. package/es/components/chart/src/HtChart.vue.mjs +90 -0
  11. package/es/components/chart/src/HtChart.vue2.mjs +109 -0
  12. package/es/components/chart/src/chartConfig.d.ts +7 -0
  13. package/es/components/chart/src/chartConfig.mjs +88 -0
  14. package/es/components/chart/style/index.d.ts +1 -0
  15. package/es/components/chart/style/index.mjs +1 -0
  16. package/es/components/elTable/index.d.ts +771 -0
  17. package/es/components/elTable/index.mjs +7 -0
  18. package/es/components/elTable/src/columnDeal.vue.d.ts +39 -0
  19. package/es/components/elTable/src/columnDeal.vue.mjs +35 -0
  20. package/es/components/elTable/src/columnDeal.vue2.mjs +20 -0
  21. package/es/components/elTable/src/elTable.d.ts +38 -0
  22. package/es/components/elTable/src/elTable.mjs +30 -0
  23. package/es/components/elTable/src/elTable.vue.d.ts +770 -0
  24. package/es/components/elTable/src/elTable.vue.mjs +56 -0
  25. package/es/components/elTable/src/elTable.vue2.mjs +30 -0
  26. package/es/components/htTarget/index.d.ts +1979 -0
  27. package/es/components/htTarget/index.mjs +6 -0
  28. package/es/components/htTarget/src/htTarget.d.ts +1 -0
  29. package/es/components/htTarget/src/htTarget.mjs +3 -0
  30. package/es/components/htTarget/src/htTarget.vue.d.ts +1978 -0
  31. package/es/components/htTarget/src/htTarget.vue.mjs +204 -0
  32. package/es/components/htTarget/src/htTarget.vue2.mjs +108 -0
  33. package/es/components/index.d.ts +4 -0
  34. package/es/components/index.mjs +7 -0
  35. package/es/components/pieChart/index.d.ts +107 -0
  36. package/es/components/pieChart/index.mjs +7 -0
  37. package/es/components/pieChart/src/HtPieChart.d.ts +40 -0
  38. package/es/components/pieChart/src/HtPieChart.mjs +47 -0
  39. package/es/components/pieChart/src/HtPieChart.vue.d.ts +106 -0
  40. package/es/components/pieChart/src/HtPieChart.vue.mjs +23 -0
  41. package/es/components/pieChart/src/HtPieChart.vue2.mjs +84 -0
  42. package/es/components/pieChart/style/index.d.ts +1 -0
  43. package/es/components/pieChart/style/index.mjs +1 -0
  44. package/es/components/table/HtTable.d.ts +142 -0
  45. package/es/components/table/HtTable.mjs +136 -0
  46. package/es/components/table/HtTable.vue.d.ts +1847 -0
  47. package/es/components/table/HtTable.vue.mjs +449 -0
  48. package/es/components/table/HtTable.vue2.mjs +124 -0
  49. package/es/components/table/index.d.ts +1845 -0
  50. package/es/components/table/index.mjs +7 -0
  51. package/es/constants/chartConfig.d.ts +8 -0
  52. package/es/constants/chartConfig.mjs +110 -0
  53. package/es/constants/index.d.ts +4 -0
  54. package/es/constants/index.mjs +4 -0
  55. package/es/constants/key.d.ts +1 -0
  56. package/es/constants/key.mjs +3 -0
  57. package/es/constants/table.d.ts +118 -0
  58. package/es/constants/table.mjs +144 -0
  59. package/es/constants/target.d.ts +20 -0
  60. package/es/constants/target.mjs +54 -0
  61. package/es/defaults.d.ts +4 -0
  62. package/es/defaults.mjs +7 -0
  63. package/es/index.d.ts +5 -0
  64. package/es/index.mjs +13 -0
  65. package/es/make-installer.d.ts +4 -0
  66. package/es/make-installer.mjs +15 -0
  67. package/es/plugin.d.ts +2 -0
  68. package/es/plugin.mjs +3 -0
  69. package/es/utils/chart.d.ts +7 -0
  70. package/es/utils/chart.mjs +172 -0
  71. package/es/utils/common.d.ts +3 -0
  72. package/es/utils/common.mjs +15 -0
  73. package/es/utils/index.d.ts +4 -0
  74. package/es/utils/index.mjs +4 -0
  75. package/es/utils/table.d.ts +2 -0
  76. package/es/utils/table.mjs +31 -0
  77. package/es/utils/tool.d.ts +2 -0
  78. package/es/utils/tool.mjs +42 -0
  79. package/global.d.ts +14 -0
  80. package/package.json +1 -1
  81. package/theme-chalk/ht-chart.css +1 -0
  82. package/theme-chalk/index.css +1 -0
  83. package/theme-chalk/src/chart.scss +58 -0
  84. package/theme-chalk/src/index.scss +1 -0
  85. package/component.ts +0 -13
  86. package/defaults.ts +0 -5
  87. package/index.ts +0 -6
  88. package/make-installer.ts +0 -17
  89. package/plugin.ts +0 -1
@@ -0,0 +1,172 @@
1
+ const legendEnterOperate = (options, name) => {
2
+ options.series.forEach((series) => {
3
+ if (series.name === name) {
4
+ if (series.type === "line") {
5
+ if (series.lineStyle) {
6
+ series.lineStyle.opacity = 1;
7
+ } else {
8
+ series.lineStyle = {
9
+ opacity: 1
10
+ };
11
+ }
12
+ } else if (series.type === "bar") {
13
+ if (series.itemStyle) {
14
+ series.itemStyle.opacity = 1;
15
+ } else {
16
+ series.itemStyle = {
17
+ opacity: 1
18
+ };
19
+ }
20
+ }
21
+ } else {
22
+ if (series.type === "line") {
23
+ if (series.lineStyle) {
24
+ series.lineStyle.opacity = 0.1;
25
+ } else {
26
+ series.lineStyle = {
27
+ opacity: 0.1
28
+ };
29
+ }
30
+ } else if (series.type === "bar") {
31
+ if (series.itemStyle) {
32
+ series.itemStyle.opacity = 0.1;
33
+ } else {
34
+ series.itemStyle = {
35
+ opacity: 0.1
36
+ };
37
+ }
38
+ }
39
+ }
40
+ });
41
+ };
42
+ const legendLeaveOperate = (options) => {
43
+ options.series.forEach((series) => {
44
+ if (series.type === "line") {
45
+ if (series.lineStyle) {
46
+ series.lineStyle.opacity = 1;
47
+ } else {
48
+ series.lineStyle = {
49
+ opacity: 1
50
+ };
51
+ }
52
+ } else if (series.type === "bar") {
53
+ if (series.itemStyle) {
54
+ series.itemStyle.opacity = 1;
55
+ } else {
56
+ series.itemStyle = {
57
+ opacity: 1
58
+ };
59
+ }
60
+ }
61
+ });
62
+ };
63
+ const setEchartXAxis = (options, type, xAxisData) => {
64
+ if (type === "category") {
65
+ const xAxis = [...xAxisData];
66
+ options.xAxis = {
67
+ type,
68
+ data: xAxis,
69
+ axisTick: {
70
+ alignWithLabel: true
71
+ }
72
+ };
73
+ } else if (type === "time") {
74
+ options.xAxis = {
75
+ type,
76
+ minInterval: 24 * 60 * 60 * 1e3,
77
+ axisLine: {
78
+ onZero: false
79
+ }
80
+ };
81
+ }
82
+ };
83
+ const setEchartYAxis = (options, props) => {
84
+ options.yAxis = {
85
+ type: "value",
86
+ axisLabel: {
87
+ show: true,
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ formatter: function(val) {
90
+ return (props.yAxisUnit === "%" ? val > 0 ? "+" : "" : "") + parseFloat(val.toFixed(props.floatNumber)) + props.yAxisUnit;
91
+ }
92
+ }
93
+ };
94
+ };
95
+ const setEchartTooltip = (options, props) => {
96
+ options.tooltip = {
97
+ trigger: "axis",
98
+ // tooltip提示框格式自定义
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ formatter: function(paramItems) {
101
+ let html = "";
102
+ if (Array.isArray(paramItems)) {
103
+ const params = paramItems.filter((item) => item.data !== void 0 && item.data !== null);
104
+ if (params.length === 0) return "";
105
+ if (props.chartType === "category") {
106
+ params.sort((a, b) => b.value - a.value);
107
+ } else {
108
+ params.sort((a, b) => {
109
+ if (Array.isArray(a.value) && Array.isArray(b.value)) {
110
+ return props.collation === "des" ? b.value[1] - a.value[1] : a.value[1] - b.value[1];
111
+ } else {
112
+ return 0;
113
+ }
114
+ });
115
+ }
116
+ html += `<div>${props.chartType === "category" ? params[0].name : Array.isArray(params[0].value) ? params[0].value[0] : ""}</div>`;
117
+ if (params.length > 30) html += '<div style="display: flex;">';
118
+ const len = Math.ceil(params.length / 3);
119
+ for (let i = 0; i < params.length; i++) {
120
+ if ((i + 1) % len === 1 && params.length > 30) {
121
+ html += '<div style="display: flex; flex-direction: column;">';
122
+ }
123
+ if (params[i].value === void 0 || params[i].value === null) ; else {
124
+ html += '<div style="display: flex;align-items:center">';
125
+ html += `<span
126
+ style="display:inline-block;
127
+ margin-right:5px;
128
+ border-radius:10px;
129
+ width:10px;height:10px;
130
+ background-color:${params[i].color};
131
+ ">
132
+ </span>`;
133
+ if (props.isReturn) {
134
+ if (
135
+ // params[i].seriesId === 'excess' ||
136
+ params[i].seriesName === "\u7D2F\u8BA1\u8D85\u989D"
137
+ ) {
138
+ html += `<span style='color:${params[i].color}'>
139
+ ${params[i].seriesName}</span>\uFF1A${params[i].value[1].toFixed(2)}%
140
+ `;
141
+ } else {
142
+ html += `<span style='color:${params[i].color}'>${params[i].seriesName}</span>\uFF1A${params[i].value[2]?.toFixed(props.floatNumber)}\uFF08${params[i].value[1] > 0 ? "+" : ""}${params[i].value[1]}%\uFF09`;
143
+ }
144
+ } else {
145
+ if (props.chartType === "category") {
146
+ html += `<span style='color:${params[i].color}'>
147
+ ${params[i].seriesName.includes("series") ? params[i].name : params[i].seriesName}
148
+ </span>\uFF1A
149
+ ${params[i].value.toFixed(props.floatNumber)}${props.tooltipUnit}
150
+ `;
151
+ } else {
152
+ html += `<span style='color:${params[i].color}'>${params[i].seriesName}</span>\uFF1A${params[i].value[1]?.toFixed(props.floatNumber)}${props.tooltipUnit}`;
153
+ }
154
+ }
155
+ html += "</div>";
156
+ }
157
+ if ((i + 1) % len === 0 && params.length > 30) {
158
+ html += "</div>";
159
+ }
160
+ }
161
+ if (params.length > 30) html += "</div>";
162
+ }
163
+ return html;
164
+ },
165
+ textStyle: {
166
+ color: "rgba(0,0,0,0.7)"
167
+ // 设置文字颜色
168
+ }
169
+ };
170
+ };
171
+
172
+ export { legendEnterOperate, legendLeaveOperate, setEchartTooltip, setEchartXAxis, setEchartYAxis };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'vue';
2
+ export type SFCWithInstall<T> = T & Plugin;
3
+ export declare const withInstall: <T, E extends Record<string, any>>(main: T, extra?: E) => SFCWithInstall<T> & E;
@@ -0,0 +1,15 @@
1
+ const withInstall = (main, extra) => {
2
+ main.install = (app) => {
3
+ for (const comp of [main, ...Object.values(extra ?? {})]) {
4
+ app.component(comp.name, comp);
5
+ }
6
+ };
7
+ if (extra) {
8
+ for (const [key, comp] of Object.entries(extra)) {
9
+ main[key] = comp;
10
+ }
11
+ }
12
+ return main;
13
+ };
14
+
15
+ export { withInstall };
@@ -0,0 +1,4 @@
1
+ export * from './common';
2
+ export * from './table';
3
+ export * from './tool';
4
+ export * from './chart';
@@ -0,0 +1,4 @@
1
+ export { withInstall } from './common.mjs';
2
+ export { handleData, handleText } from './table.mjs';
3
+ export { dataHandle, splitK } from './tool.mjs';
4
+ export { legendEnterOperate, legendLeaveOperate, setEchartTooltip, setEchartXAxis, setEchartYAxis } from './chart.mjs';
@@ -0,0 +1,2 @@
1
+ export declare const handleData: (value: any, type: string) => string | number;
2
+ export declare const handleText: (value: any, type: string) => any;
@@ -0,0 +1,31 @@
1
+ import { splitK } from './tool.mjs';
2
+
3
+ const handleData = (value, type) => {
4
+ if (isNaN(parseFloat(value))) return "-";
5
+ let val = parseFloat(value);
6
+ if (type.includes("percent")) {
7
+ val = val * 100;
8
+ }
9
+ const floatMatch = type.match(/float(\d+)/);
10
+ if (floatMatch) {
11
+ const precision = Number(floatMatch[1]);
12
+ val = val.toFixed(precision);
13
+ }
14
+ if (type.includes("splitK")) {
15
+ val = splitK(val);
16
+ }
17
+ if (type.includes("sign")) {
18
+ val = Number(val) > 0 ? "+" + val : val;
19
+ }
20
+ if (type.includes("percent")) {
21
+ val = val + "%";
22
+ }
23
+ return val;
24
+ };
25
+ const handleText = (value, type) => {
26
+ if (type === "name") {
27
+ return value;
28
+ }
29
+ };
30
+
31
+ export { handleData, handleText };
@@ -0,0 +1,2 @@
1
+ export declare function dataHandle(val: any, isPer: boolean, floatNum: number): any;
2
+ export declare function splitK(num: string | number): string;
@@ -0,0 +1,42 @@
1
+ function dataHandle(val, isPer, floatNum) {
2
+ val = parseFloat(val);
3
+ if (isNaN(val)) {
4
+ return "-";
5
+ } else {
6
+ if (isPer) {
7
+ val = val * 100;
8
+ }
9
+ if (Number(val.toFixed(floatNum)) === 0) {
10
+ const a = 0;
11
+ return a.toFixed(floatNum);
12
+ } else {
13
+ return val.toFixed(floatNum);
14
+ }
15
+ }
16
+ }
17
+ function splitK(num) {
18
+ let decimal = String(num).split(".")[1] || "";
19
+ if (decimal === "") {
20
+ decimal = "00";
21
+ }
22
+ const tempArr = [];
23
+ const revNumArr = String(num).split(".")[0].split("").reverse();
24
+ const mark = revNumArr[revNumArr.length - 1];
25
+ if (mark === "-") {
26
+ revNumArr.splice(-1, 1);
27
+ }
28
+ for (const i in revNumArr) {
29
+ tempArr.push(revNumArr[i]);
30
+ const index = parseFloat(i);
31
+ if ((index + 1) % 3 === 0 && Number(i) !== revNumArr.length - 1) {
32
+ tempArr.push(",");
33
+ }
34
+ }
35
+ if (mark === "-") {
36
+ tempArr.push(mark);
37
+ }
38
+ const zs = tempArr.reverse().join("");
39
+ return decimal ? zs + "." + decimal : zs;
40
+ }
41
+
42
+ export { dataHandle, splitK };
package/global.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ // declare module '*.vue' {
2
+ // import { defineComponent } from 'vue'
3
+ // const componentOptions:ReturnType<typeof defineComponent>
4
+ // export default componentOptions
5
+ // }
6
+
7
+ declare module '@vue/runtime-core' {
8
+ export interface GlobalComponents {
9
+ HtTable: (typeof import('hfn-components'))['HtTable']
10
+ }
11
+ interface ComponentCustomProperties {
12
+ // 你可以在这里添加自定义属性
13
+ }
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfn-components",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "module": "es/index.mjs",
@@ -0,0 +1 @@
1
+ .echart-box{display:flex;flex-direction:column;height:100%;position:relative;width:100%}.echart-content{flex:auto}.echart-lenged{box-sizing:border-box;display:flex;flex-wrap:wrap;font-size:12px;height:auto;margin-top:6px;padding-right:22px;position:relative;width:100%;z-index:999}.bg-span{height:2px;width:14px}.bg-span,.bg-span-bar{display:inline-block;margin-right:6px}.bg-span-bar{border-radius:2px;height:10px;width:16px}.span-box{cursor:pointer;margin-left:5px;margin-right:6px}.noData,.span-box{align-items:center;display:flex}.noData{bottom:0;color:#ccc;font-size:16px;justify-content:center;position:absolute}._100,.noData{height:100%;width:100%}
@@ -0,0 +1 @@
1
+ .echart-box{display:flex;flex-direction:column;height:100%;position:relative;width:100%}.echart-content{flex:auto}.echart-lenged{box-sizing:border-box;display:flex;flex-wrap:wrap;font-size:12px;height:auto;margin-top:6px;padding-right:22px;position:relative;width:100%;z-index:999}.bg-span{height:2px;width:14px}.bg-span,.bg-span-bar{display:inline-block;margin-right:6px}.bg-span-bar{border-radius:2px;height:10px;width:16px}.span-box{cursor:pointer;margin-left:5px;margin-right:6px}.noData,.span-box{align-items:center;display:flex}.noData{bottom:0;color:#ccc;font-size:16px;justify-content:center;position:absolute}._100,.noData{height:100%;width:100%}
@@ -0,0 +1,58 @@
1
+ .echart-box {
2
+ width: 100%;
3
+ height: 100%;
4
+ display: flex;
5
+ flex-direction: column;
6
+ position: relative;
7
+ }
8
+ .echart-content {
9
+ flex: auto;
10
+ }
11
+ .echart-lenged {
12
+ width: 100%;
13
+ height: auto;
14
+ margin-top: 6px;
15
+ padding-right: 22px;
16
+ box-sizing: border-box;
17
+ display: flex;
18
+ flex-wrap: wrap;
19
+ font-size: 12px;
20
+ position: relative;
21
+ z-index: 999;
22
+ }
23
+ .bg-span {
24
+ display: inline-block;
25
+ width: 14px;
26
+ height: 2px;
27
+ margin-right: 6px;
28
+ }
29
+ .bg-span-bar {
30
+ display: inline-block;
31
+ width: 16px;
32
+ height: 10px;
33
+ border-radius: 2px;
34
+ margin-right: 6px;
35
+ }
36
+ .span-box {
37
+ margin-left: 5px;
38
+ margin-right: 6px;
39
+ cursor: pointer;
40
+ display: flex;
41
+ align-items: center;
42
+ }
43
+ .noData {
44
+ width: 100%;
45
+ height: 100%;
46
+ font-size: 16px;
47
+ display: flex;
48
+ justify-content: center;
49
+ align-items: center;
50
+ position: absolute;
51
+ bottom: 0px;
52
+ color: #ccc;
53
+ }
54
+
55
+ ._100 {
56
+ width: 100%;
57
+ height: 100%;
58
+ }
@@ -0,0 +1 @@
1
+ @use './chart.scss';
package/component.ts DELETED
@@ -1,13 +0,0 @@
1
- // import { HtTable } from '@hfn-components/components/table'
2
- import { HtElTable } from '@hfn-components/components/elTable'
3
- import { HtChart } from '@hfn-components/components/chart'
4
- import { HtPieChart } from '@hfn-components/components/pieChart'
5
-
6
- import type { Plugin } from 'vue'
7
-
8
- export default [
9
- // HtTable,
10
- HtChart,
11
- HtElTable,
12
- HtPieChart
13
- ] as Plugin[]
package/defaults.ts DELETED
@@ -1,5 +0,0 @@
1
- import { makeInstaller } from './make-installer'
2
- import Components from './component'
3
- import Plugins from './plugin'
4
-
5
- export default makeInstaller([...Components, ...Plugins])
package/index.ts DELETED
@@ -1,6 +0,0 @@
1
- import installer from './defaults'
2
- export * from './make-installer'
3
- export * from '@hfn-components/components'
4
-
5
- export const install = installer.install
6
- export default installer
package/make-installer.ts DELETED
@@ -1,17 +0,0 @@
1
- import type { App, Plugin } from 'vue'
2
- import { INSTALLED_KEY } from '@hfn-components/constants'
3
-
4
- export const makeInstaller = (components: Plugin[] = []) => {
5
- const install = (app: App) => {
6
- if (app[INSTALLED_KEY]) return
7
-
8
- app[INSTALLED_KEY] = true
9
- components.forEach(c => app.use(c))
10
-
11
- // if (options) provideGlobalConfig(options, app, true)
12
- }
13
-
14
- return {
15
- install
16
- }
17
- }
package/plugin.ts DELETED
@@ -1 +0,0 @@
1
- export default []