lowcoder-map-component 0.1.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.
Files changed (123) hide show
  1. package/README.md +37 -0
  2. package/icons/demo-icon.svg +10 -0
  3. package/icons/hills.svg +17 -0
  4. package/index.css +27 -0
  5. package/index.html +35 -0
  6. package/index.tsx +20 -0
  7. package/loader.mjs +11 -0
  8. package/package.json +175 -0
  9. package/src/README.md +35 -0
  10. package/src/components/ChartPropertyView.tsx +961 -0
  11. package/src/components/SeriesComp.tsx +368 -0
  12. package/src/components/TabPropertyView.tsx +127 -0
  13. package/src/comps/Barcharts/comp.tsx +338 -0
  14. package/src/comps/Barcharts/constants.tsx +77 -0
  15. package/src/comps/Linecharts/comp.tsx +350 -0
  16. package/src/comps/Linecharts/constants.tsx +53 -0
  17. package/src/comps/Linechartsv2/comp.tsx +350 -0
  18. package/src/comps/Linechartsv2/constants.tsx +68 -0
  19. package/src/comps/Mapcharts/comp.tsx +381 -0
  20. package/src/comps/Mapcharts/constants.tsx +312 -0
  21. package/src/comps/Mapchartsv2/comp.tsx +393 -0
  22. package/src/comps/Mapchartsv2/constants.tsx +340 -0
  23. package/src/comps/MixedLineBarCharts/comp.tsx +353 -0
  24. package/src/comps/MixedLineBarCharts/constants.tsx +60 -0
  25. package/src/comps/MultiLineCharts/comp.tsx +362 -0
  26. package/src/comps/MultiLineCharts/constants.tsx +96 -0
  27. package/src/comps/PercentageCharts/comp.tsx +359 -0
  28. package/src/comps/PercentageCharts/constants.tsx +98 -0
  29. package/src/comps/Piecharts/comp.tsx +334 -0
  30. package/src/comps/Piecharts/constants.tsx +48 -0
  31. package/src/comps/Tablecharts/comp.tsx +429 -0
  32. package/src/comps/Tablecharts/constants.tsx +97 -0
  33. package/src/comps/Totalcharts/comp.tsx +463 -0
  34. package/src/comps/Totalcharts/constants.tsx +66 -0
  35. package/src/comps/TwoLineCharts/comp.tsx +350 -0
  36. package/src/comps/TwoLineCharts/constants.tsx +82 -0
  37. package/src/comps/mapComponent/comp.tsx +338 -0
  38. package/src/comps/mapComponent/constants.tsx +2149 -0
  39. package/src/comps/tab/comp.tsx +283 -0
  40. package/src/comps/tab/constants.tsx +79 -0
  41. package/src/configs/barChartConfig.tsx +153 -0
  42. package/src/configs/baseConfig.tsx +66 -0
  43. package/src/configs/candleStickChartConfig.tsx +35 -0
  44. package/src/configs/cartesianAxisConfig.tsx +314 -0
  45. package/src/configs/chartUrls.tsx +9 -0
  46. package/src/configs/echartConfig.tsx +260 -0
  47. package/src/configs/echartsLabelConfig.tsx +47 -0
  48. package/src/configs/echartsLegendConfig.tsx +29 -0
  49. package/src/configs/echartsTitleConfig.tsx +49 -0
  50. package/src/configs/echartsTitleVerticalConfig.tsx +50 -0
  51. package/src/configs/funnelChartConfig.tsx +35 -0
  52. package/src/configs/gaugeChartConfig.tsx +31 -0
  53. package/src/configs/graphChartConfig.tsx +31 -0
  54. package/src/configs/heatmapChartConfig.tsx +31 -0
  55. package/src/configs/legendConfig.tsx +55 -0
  56. package/src/configs/lineChartConfig.tsx +246 -0
  57. package/src/configs/lineChartConfigv2.tsx +246 -0
  58. package/src/configs/mapChartConfig.tsx +106 -0
  59. package/src/configs/mapChartConfigv2.tsx +106 -0
  60. package/src/configs/mixedChartConfig.tsx +21 -0
  61. package/src/configs/pieChartConfig.tsx +156 -0
  62. package/src/configs/radarChartConfig.tsx +31 -0
  63. package/src/configs/sankeyChartConfig.tsx +35 -0
  64. package/src/configs/scatterChartConfig.tsx +152 -0
  65. package/src/configs/sunburstChartConfig.tsx +31 -0
  66. package/src/configs/tabConfig.tsx +0 -0
  67. package/src/configs/tableChartConfig.tsx +81 -0
  68. package/src/configs/themeriverChartConfig.tsx +31 -0
  69. package/src/configs/totalChartConfig.tsx +670 -0
  70. package/src/configs/treeChartConfig.tsx +31 -0
  71. package/src/configs/treemapChartConfig.tsx +31 -0
  72. package/src/controls/AnimationsControls.tsx +3 -0
  73. package/src/controls/AutoHeightControl.tsx +2 -0
  74. package/src/controls/AxisControls.tsx +146 -0
  75. package/src/controls/AxisVisibilityControl.tsx +14 -0
  76. package/src/controls/ChartTypeControl.tsx +15 -0
  77. package/src/controls/ColorScaleControl.tsx +221 -0
  78. package/src/controls/ColumnControl.tsx +204 -0
  79. package/src/controls/ConfigControl.tsx +37 -0
  80. package/src/controls/DirectionControls.tsx +20 -0
  81. package/src/controls/IconControl.tsx +88 -0
  82. package/src/controls/LegendControl.tsx +8 -0
  83. package/src/controls/RowLimitControl.tsx +91 -0
  84. package/src/controls/StyleControls.tsx +22 -0
  85. package/src/controls/TimeControls.tsx +41 -0
  86. package/src/controls/TrendlineControl.tsx +89 -0
  87. package/src/controls/UIEventControl.tsx +21 -0
  88. package/src/controls/index.ts +16 -0
  89. package/src/controls/radioControl.tsx +88 -0
  90. package/src/exposing/index.ts +3 -0
  91. package/src/exposing/setPoint.ts +19 -0
  92. package/src/geo/vn.geo.json +369897 -0
  93. package/src/geo/world.geo.json +32127 -0
  94. package/src/i18n/comps/index.tsx +39 -0
  95. package/src/i18n/comps/locales/en.ts +558 -0
  96. package/src/i18n/comps/locales/enObj.tsx +7186 -0
  97. package/src/i18n/comps/locales/index.ts +7 -0
  98. package/src/i18n/comps/locales/pt.ts +37 -0
  99. package/src/i18n/comps/locales/ptObj.tsx +40 -0
  100. package/src/i18n/comps/locales/types.tsx +622 -0
  101. package/src/i18n/comps/locales/zh.ts +3 -0
  102. package/src/i18n/comps/locales/zhObj.tsx +4 -0
  103. package/src/index.ts +31 -0
  104. package/src/types/global.d.ts +9 -0
  105. package/src/types/lowcoder-sdk.d.ts +578 -0
  106. package/src/utils/chartStyle.util.ts +121 -0
  107. package/src/utils/columnExtractor.util.ts +41 -0
  108. package/src/utils/dataTransform.util.ts +37 -0
  109. package/src/utils/deepEqual.util.ts +29 -0
  110. package/src/utils/echarts.util.tsx +822 -0
  111. package/src/utils/getDataKey.util.ts +115 -0
  112. package/src/utils/getLinearRegression.util.ts +46 -0
  113. package/src/utils/googleMaps.util.ts +28 -0
  114. package/src/utils/isEmpty.util.ts +10 -0
  115. package/src/utils/move.util.ts +6 -0
  116. package/src/utils/selection.util.ts +73 -0
  117. package/src/utils/style.util.ts +315 -0
  118. package/src/utils/time.util.ts +221 -0
  119. package/src/utils/timeFormatter.util.ts +104 -0
  120. package/src/utils/timeProcessing.util.ts +38 -0
  121. package/src/utils/trendline.util.ts +342 -0
  122. package/tsconfig.json +25 -0
  123. package/vite.config.js +19 -0
@@ -0,0 +1,121 @@
1
+ type StyleValue = string | undefined;
2
+
3
+ // ReplacePrefixes dạng { old: new }
4
+ type ReplacePrefixes = Record<string, string>;
5
+
6
+ // ----------- TYPE LEVEL -----------
7
+ type RemovePrefix<
8
+ K extends string,
9
+ Prefix extends string,
10
+ > = K extends `${Prefix}${infer Rest}` ? Uncapitalize<Rest> : K;
11
+
12
+ type ReplacePrefix<
13
+ K extends string,
14
+ P extends string,
15
+ R extends string,
16
+ > = K extends `${P}${infer Rest}` ? `${R}${Capitalize<Rest>}` : K;
17
+
18
+ type FormattedStyle<
19
+ T extends Record<string, StyleValue>,
20
+ Remove extends string = "chart",
21
+ Replace extends ReplacePrefixes = { text: "font" },
22
+ > = {
23
+ [K in keyof T as K extends string
24
+ ? {
25
+ [P in keyof Replace & string]: ReplacePrefix<K, P, Replace[P]>;
26
+ }[keyof Replace & string] extends infer R
27
+ ? R extends string
28
+ ? R
29
+ : RemovePrefix<K, Remove>
30
+ : never
31
+ : never]: string;
32
+ };
33
+
34
+ // ----------- RUNTIME LEVEL -----------
35
+ export function formatStyle<
36
+ T extends Record<string, StyleValue>,
37
+ Remove extends string = "chart",
38
+ Replace extends ReplacePrefixes = { text: "font" },
39
+ >(
40
+ data: T,
41
+ removePrefixes: Remove[] = ["chart"] as Remove[],
42
+ replacePrefixes: Replace = { text: "font" } as unknown as Replace
43
+ ): FormattedStyle<T, Remove, Replace> {
44
+ const formatted: Record<string, string> = {};
45
+
46
+ for (const [key, value] of Object.entries(data)) {
47
+ let newKey = key;
48
+
49
+ for (const prefix of removePrefixes) {
50
+ if (newKey.startsWith(prefix)) {
51
+ newKey =
52
+ newKey.charAt(prefix.length).toLowerCase() +
53
+ newKey.slice(prefix.length + 1);
54
+ break;
55
+ }
56
+ }
57
+
58
+ for (const [prefix, replacement] of Object.entries(replacePrefixes)) {
59
+ if (newKey.startsWith(prefix)) {
60
+ newKey =
61
+ replacement +
62
+ newKey.charAt(prefix.length).toUpperCase() +
63
+ newKey.slice(prefix.length + 1);
64
+ break;
65
+ }
66
+ }
67
+ if (newKey === "fontColor") formatted["color"] = value ?? "black";
68
+ else formatted[newKey] = value ?? "";
69
+ }
70
+
71
+ return formatted as FormattedStyle<T, Remove, Replace>;
72
+ }
73
+
74
+ export function formatAllStyles<
75
+ T extends Record<string, any>,
76
+ Remove extends string = "chart",
77
+ Replace extends ReplacePrefixes = { text: "font" },
78
+ >(
79
+ obj: T,
80
+ removePrefixes: Remove[] = ["chart"] as Remove[],
81
+ replacePrefixes: Replace = { text: "font" } as unknown as Replace
82
+ ): {
83
+ [K in keyof T]: K extends `${string}Style`
84
+ ? T[K] extends Record<string, StyleValue>
85
+ ? FormattedStyle<T[K], Remove, Replace>
86
+ : T[K]
87
+ : T[K] extends Record<string, any>
88
+ ? ReturnType<typeof formatAllStyles<T[K], Remove, Replace>>
89
+ : T[K];
90
+ } {
91
+ const result: Record<string, any> = {};
92
+
93
+ for (const [key, value] of Object.entries(obj)) {
94
+ if (
95
+ key.endsWith("Style") &&
96
+ typeof value === "object" &&
97
+ value !== null &&
98
+ !Array.isArray(value)
99
+ ) {
100
+ result[key] = formatStyle(
101
+ value as Record<string, StyleValue>,
102
+ removePrefixes,
103
+ replacePrefixes
104
+ );
105
+ } else if (
106
+ typeof value === "object" &&
107
+ value !== null &&
108
+ !Array.isArray(value)
109
+ ) {
110
+ result[key] = formatAllStyles(
111
+ value as Record<string, any>,
112
+ removePrefixes,
113
+ replacePrefixes
114
+ );
115
+ } else {
116
+ result[key] = value;
117
+ }
118
+ }
119
+
120
+ return result as any;
121
+ }
@@ -0,0 +1,41 @@
1
+ import { JSONObject } from "lowcoder-sdk";
2
+
3
+ export interface ColumnDefinition {
4
+ align?: string;
5
+ dataIndex: string;
6
+ defaultSortOrder?: any;
7
+ fixed?: string | boolean;
8
+ key: string;
9
+ sortable?: boolean;
10
+ title: string;
11
+ visible: boolean;
12
+ width?: number;
13
+ render?: (value: any, record: any, index: number) => React.ReactNode;
14
+ }
15
+
16
+ export const extractColumnsFromData = (
17
+ data: JSONObject[]
18
+ ): ColumnDefinition[] => {
19
+ if (!data || data.length === 0) return [];
20
+
21
+ const sampleItem = data[0];
22
+ const keys = Object.keys(sampleItem).filter((key) => key !== "key");
23
+
24
+ return keys.map((key) => {
25
+ const sampleValue = sampleItem[key];
26
+ const isNumeric = typeof sampleValue === "number";
27
+ const isSparkline = key === "sparkline" && Array.isArray(sampleValue);
28
+
29
+ return {
30
+ title: key.charAt(0).toUpperCase() + key.slice(1),
31
+ dataIndex: key,
32
+ key: key,
33
+ visible: true,
34
+ sortable: false,
35
+ defaultSortOrder: "none",
36
+ align: isNumeric ? "right" : "left",
37
+ fixed: "none",
38
+ width: isSparkline ? 200 : isNumeric ? 120 : 150,
39
+ };
40
+ });
41
+ };
@@ -0,0 +1,37 @@
1
+ import Big from "big.js";
2
+ import { isNumeric, JSONObject } from "lowcoder-sdk";
3
+
4
+ export function transformData(
5
+ originData: JSONObject[],
6
+ xAxis: string,
7
+ seriesColumnNames: string[]
8
+ ) {
9
+ const dataMap = new Map<string, Record<string, any>>();
10
+ const initValue = Object.fromEntries(
11
+ seriesColumnNames.map((name) => [name, 0])
12
+ );
13
+
14
+ originData.forEach((item) => {
15
+ if (item === null || item === undefined) return;
16
+
17
+ const groupValue = item[xAxis] as string;
18
+ if (!dataMap.has(groupValue)) {
19
+ dataMap.set(groupValue, { ...initValue, [xAxis]: groupValue });
20
+ }
21
+
22
+ const groupData = dataMap.get(groupValue)!;
23
+ seriesColumnNames.forEach((key) => {
24
+ if (key === xAxis) return;
25
+
26
+ if (isNumeric(item[key])) {
27
+ groupData[key] = Big(item[key] as string)
28
+ .add(groupData[key])
29
+ .toNumber();
30
+ } else {
31
+ groupData[key] += 1;
32
+ }
33
+ });
34
+ });
35
+
36
+ return Array.from(dataMap.values());
37
+ }
@@ -0,0 +1,29 @@
1
+ export function deepEqual(a: any, b: any): boolean {
2
+ // Handle null and undefined cases
3
+ if (a === b) return true;
4
+ if (a == null || b == null) return false;
5
+ if (typeof a !== typeof b) return false;
6
+
7
+ // Handle arrays
8
+ if (Array.isArray(a) && Array.isArray(b)) {
9
+ if (a.length !== b.length) return false;
10
+ for (let i = 0; i < a.length; i++) {
11
+ if (!deepEqual(a[i], b[i])) return false;
12
+ }
13
+ return true;
14
+ }
15
+
16
+ // Handle objects
17
+ if (typeof a === "object" && typeof b === "object") {
18
+ const keysA = Object.keys(a);
19
+ const keysB = Object.keys(b);
20
+ if (keysA.length !== keysB.length) return false;
21
+ for (const key of keysA) {
22
+ if (!b.hasOwnProperty(key) || !deepEqual(a[key], b[key])) return false;
23
+ }
24
+ return true;
25
+ }
26
+
27
+ // Handle primitives
28
+ return a === b;
29
+ }