@nocobase/plugin-charts 0.11.1-alpha.4 → 0.12.0-alpha.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 (180) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -1
  3. package/{lib → dist}/client/index.d.ts +1 -0
  4. package/dist/client/index.js +3234 -0
  5. package/{lib → dist}/index.d.ts +1 -0
  6. package/dist/index.js +18 -0
  7. package/dist/locale/en-US.js +26 -0
  8. package/{src/locale/es-ES.ts → dist/locale/es-ES.js} +22 -18
  9. package/dist/locale/fr-FR.js +5 -0
  10. package/dist/locale/ja-JP.js +5 -0
  11. package/dist/locale/pt-BR.js +26 -0
  12. package/dist/locale/ru-RU.js +5 -0
  13. package/dist/locale/tr-TR.js +5 -0
  14. package/dist/locale/zh-CN.js +65 -0
  15. package/dist/node_modules/json5/dist/index.js +1737 -0
  16. package/dist/node_modules/json5/dist/index.min.js +1 -0
  17. package/dist/node_modules/json5/lib/cli.js +152 -0
  18. package/dist/node_modules/json5/lib/index.d.ts +4 -0
  19. package/dist/node_modules/json5/lib/index.js +1 -0
  20. package/dist/node_modules/json5/lib/parse.d.ts +15 -0
  21. package/dist/node_modules/json5/lib/parse.js +1114 -0
  22. package/dist/node_modules/json5/lib/register.js +13 -0
  23. package/dist/node_modules/json5/lib/require.js +4 -0
  24. package/dist/node_modules/json5/lib/stringify.d.ts +89 -0
  25. package/dist/node_modules/json5/lib/stringify.js +261 -0
  26. package/dist/node_modules/json5/lib/unicode.d.ts +3 -0
  27. package/dist/node_modules/json5/lib/unicode.js +4 -0
  28. package/dist/node_modules/json5/lib/util.d.ts +5 -0
  29. package/dist/node_modules/json5/lib/util.js +35 -0
  30. package/dist/node_modules/json5/package.json +1 -0
  31. package/dist/server/actions/chartsQueries.js +57 -0
  32. package/dist/server/actions/index.js +2 -0
  33. package/dist/server/collections/chartsQueries.js +30 -0
  34. package/dist/server/index.js +11 -0
  35. package/dist/server/plugin.js +66 -0
  36. package/dist/server/query.js +39 -0
  37. package/dist/server/shared/index.js +5 -0
  38. package/package.json +17 -28
  39. package/server.d.ts +2 -3
  40. package/server.js +1 -1
  41. package/lib/client/ChartBlockEngine.js +0 -146
  42. package/lib/client/ChartBlockEngineDesigner.js +0 -293
  43. package/lib/client/ChartBlockInitializer.js +0 -263
  44. package/lib/client/ChartQueryBlockInitializer.js +0 -191
  45. package/lib/client/ChartQueryMetadataProvider.js +0 -91
  46. package/lib/client/DataSetPreviewTable.js +0 -113
  47. package/lib/client/Icons.js +0 -210
  48. package/lib/client/chartRenderComponents/index.js +0 -20
  49. package/lib/client/hooks/index.js +0 -38
  50. package/lib/client/index.js +0 -143
  51. package/lib/client/locale/index.js +0 -37
  52. package/lib/client/select/CustomSelect.js +0 -148
  53. package/lib/client/select/ReadPretty.js +0 -77
  54. package/lib/client/select/index.js +0 -27
  55. package/lib/client/select/shared.js +0 -66
  56. package/lib/client/settings/AddNewQuery.js +0 -270
  57. package/lib/client/settings/ConfigureFields.js +0 -39
  58. package/lib/client/settings/QueriesTable.js +0 -77
  59. package/lib/client/settings/queryTypes.js +0 -77
  60. package/lib/client/settings/schemas/chartsQueries.js +0 -353
  61. package/lib/client/templates/AreaTemplate.js +0 -81
  62. package/lib/client/templates/BarTemplate.js +0 -98
  63. package/lib/client/templates/ColumnTemplate.js +0 -98
  64. package/lib/client/templates/FunnelTemplate.js +0 -82
  65. package/lib/client/templates/LineTemplate.js +0 -89
  66. package/lib/client/templates/PieTemplate.js +0 -87
  67. package/lib/client/templates/RadarTemplate.js +0 -88
  68. package/lib/client/templates/ScatterTemplate.js +0 -107
  69. package/lib/client/templates/TableTemplate.js +0 -54
  70. package/lib/client/templates/index.js +0 -25
  71. package/lib/client/utils.js +0 -50
  72. package/lib/index.js +0 -13
  73. package/lib/locale/en-US.js +0 -29
  74. package/lib/locale/es-ES.js +0 -59
  75. package/lib/locale/fr-FR.js +0 -8
  76. package/lib/locale/ja-JP.js +0 -8
  77. package/lib/locale/pt-BR.js +0 -29
  78. package/lib/locale/ru-RU.js +0 -8
  79. package/lib/locale/tr-TR.js +0 -8
  80. package/lib/locale/zh-CN.js +0 -68
  81. package/lib/server/actions/chartsQueries.js +0 -89
  82. package/lib/server/actions/index.js +0 -1
  83. package/lib/server/collections/chartsQueries.js +0 -33
  84. package/lib/server/index.js +0 -13
  85. package/lib/server/plugin.js +0 -106
  86. package/lib/server/query.js +0 -71
  87. package/lib/server/shared/index.js +0 -8
  88. package/src/client/ChartBlockEngine.tsx +0 -121
  89. package/src/client/ChartBlockEngineDesigner.tsx +0 -248
  90. package/src/client/ChartBlockInitializer.tsx +0 -223
  91. package/src/client/ChartQueryBlockInitializer.tsx +0 -156
  92. package/src/client/ChartQueryMetadataProvider.tsx +0 -64
  93. package/src/client/DataSetPreviewTable.tsx +0 -71
  94. package/src/client/Icons.tsx +0 -99
  95. package/src/client/chartRenderComponents/index.ts +0 -7
  96. package/src/client/hooks/index.ts +0 -19
  97. package/src/client/index.tsx +0 -115
  98. package/src/client/locale/index.ts +0 -18
  99. package/src/client/select/CustomSelect.tsx +0 -126
  100. package/src/client/select/ReadPretty.tsx +0 -39
  101. package/src/client/select/index.md +0 -31
  102. package/src/client/select/index.ts +0 -2
  103. package/src/client/select/shared.ts +0 -37
  104. package/src/client/settings/AddNewQuery.tsx +0 -176
  105. package/src/client/settings/ConfigureFields.tsx +0 -18
  106. package/src/client/settings/QueriesTable.tsx +0 -26
  107. package/src/client/settings/queryTypes.ts +0 -65
  108. package/src/client/settings/schemas/chartsQueries.ts +0 -319
  109. package/src/client/templates/AreaTemplate.tsx +0 -64
  110. package/src/client/templates/BarTemplate.tsx +0 -80
  111. package/src/client/templates/ColumnTemplate.tsx +0 -81
  112. package/src/client/templates/FunnelTemplate.tsx +0 -65
  113. package/src/client/templates/LineTemplate.tsx +0 -72
  114. package/src/client/templates/PieTemplate.tsx +0 -68
  115. package/src/client/templates/RadarTemplate.tsx +0 -71
  116. package/src/client/templates/ScatterTemplate.tsx +0 -90
  117. package/src/client/templates/TableTemplate.tsx +0 -48
  118. package/src/client/templates/index.ts +0 -21
  119. package/src/client/utils.ts +0 -39
  120. package/src/index.ts +0 -1
  121. package/src/locale/en-US.ts +0 -23
  122. package/src/locale/fr-FR.ts +0 -1
  123. package/src/locale/ja-JP.ts +0 -1
  124. package/src/locale/pt-BR.ts +0 -23
  125. package/src/locale/ru-RU.ts +0 -1
  126. package/src/locale/tr-TR.ts +0 -1
  127. package/src/locale/zh-CN.ts +0 -64
  128. package/src/server/actions/chartsQueries.ts +0 -49
  129. package/src/server/actions/index.ts +0 -0
  130. package/src/server/collections/.gitkeep +0 -0
  131. package/src/server/collections/chartsQueries.ts +0 -26
  132. package/src/server/index.ts +0 -1
  133. package/src/server/plugin.ts +0 -61
  134. package/src/server/query.ts +0 -39
  135. package/src/server/shared/index.ts +0 -2
  136. /package/{lib → dist}/client/ChartBlockEngine.d.ts +0 -0
  137. /package/{lib → dist}/client/ChartBlockEngineDesigner.d.ts +0 -0
  138. /package/{lib → dist}/client/ChartBlockInitializer.d.ts +0 -0
  139. /package/{lib → dist}/client/ChartQueryBlockInitializer.d.ts +0 -0
  140. /package/{lib → dist}/client/ChartQueryMetadataProvider.d.ts +0 -0
  141. /package/{lib → dist}/client/DataSetPreviewTable.d.ts +0 -0
  142. /package/{lib → dist}/client/Icons.d.ts +0 -0
  143. /package/{lib → dist}/client/chartRenderComponents/index.d.ts +0 -0
  144. /package/{lib → dist}/client/hooks/index.d.ts +0 -0
  145. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  146. /package/{lib → dist}/client/select/CustomSelect.d.ts +0 -0
  147. /package/{lib → dist}/client/select/ReadPretty.d.ts +0 -0
  148. /package/{lib → dist}/client/select/index.d.ts +0 -0
  149. /package/{lib → dist}/client/select/shared.d.ts +0 -0
  150. /package/{lib → dist}/client/settings/AddNewQuery.d.ts +0 -0
  151. /package/{lib → dist}/client/settings/ConfigureFields.d.ts +0 -0
  152. /package/{lib → dist}/client/settings/QueriesTable.d.ts +0 -0
  153. /package/{lib → dist}/client/settings/queryTypes.d.ts +0 -0
  154. /package/{lib → dist}/client/settings/schemas/chartsQueries.d.ts +0 -0
  155. /package/{lib → dist}/client/templates/AreaTemplate.d.ts +0 -0
  156. /package/{lib → dist}/client/templates/BarTemplate.d.ts +0 -0
  157. /package/{lib → dist}/client/templates/ColumnTemplate.d.ts +0 -0
  158. /package/{lib → dist}/client/templates/FunnelTemplate.d.ts +0 -0
  159. /package/{lib → dist}/client/templates/LineTemplate.d.ts +0 -0
  160. /package/{lib → dist}/client/templates/PieTemplate.d.ts +0 -0
  161. /package/{lib → dist}/client/templates/RadarTemplate.d.ts +0 -0
  162. /package/{lib → dist}/client/templates/ScatterTemplate.d.ts +0 -0
  163. /package/{lib → dist}/client/templates/TableTemplate.d.ts +0 -0
  164. /package/{lib → dist}/client/templates/index.d.ts +0 -0
  165. /package/{lib → dist}/client/utils.d.ts +0 -0
  166. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  167. /package/{lib → dist}/locale/es-ES.d.ts +0 -0
  168. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  169. /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
  170. /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
  171. /package/{lib → dist}/locale/ru-RU.d.ts +0 -0
  172. /package/{lib → dist}/locale/tr-TR.d.ts +0 -0
  173. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  174. /package/{lib → dist}/server/actions/chartsQueries.d.ts +0 -0
  175. /package/{lib → dist}/server/actions/index.d.ts +0 -0
  176. /package/{lib → dist}/server/collections/chartsQueries.d.ts +0 -0
  177. /package/{lib → dist}/server/index.d.ts +0 -0
  178. /package/{lib → dist}/server/plugin.d.ts +0 -0
  179. /package/{lib → dist}/server/query.d.ts +0 -0
  180. /package/{lib → dist}/server/shared/index.d.ts +0 -0
@@ -1,71 +0,0 @@
1
- import { ISchema } from '@formily/react';
2
- import { FormItem, Input, SchemaComponent, SchemaComponentProvider, TableV2 } from '@nocobase/client';
3
- import { Empty, Spin } from 'antd';
4
- import React from 'react';
5
- import { useGetDataSet } from './ChartBlockEngine';
6
-
7
- export default ({ queryId, fields }: { queryId: number; fields }) => {
8
- const { dataSet, loading, error } = useGetDataSet(queryId);
9
- const columns = {};
10
- if (fields) {
11
- for (const field of fields) {
12
- columns[field.name] = {
13
- type: 'void',
14
- title: field.name,
15
- 'x-component': 'TableV2.Column',
16
- 'x-component-props': {
17
- // width: 200,
18
- },
19
- properties: {
20
- [field.name]: {
21
- type: 'string',
22
- 'x-component': 'Input',
23
- 'x-read-pretty': true,
24
- },
25
- },
26
- };
27
- }
28
- }
29
- const schema: ISchema = {
30
- type: 'void',
31
- properties: {
32
- input: {
33
- type: 'array',
34
- 'x-component': 'TableV2',
35
- 'x-component-props': {
36
- scroll: { y: 300 },
37
- },
38
- default: dataSet,
39
- properties: columns,
40
- },
41
- },
42
- };
43
-
44
- if (error) {
45
- return (
46
- <>
47
- <Empty description={<span>May be this chart block's query data has been deleted,please check!</span>} />
48
- </>
49
- );
50
- }
51
-
52
- if (loading)
53
- return (
54
- <>
55
- <Spin />
56
- </>
57
- );
58
- //对dataset中引用类型数据类型进行序列化处理
59
- dataSet.forEach((item) => {
60
- for (const key in item) {
61
- if (item[key] && item[key] instanceof Object) {
62
- item[key] = JSON.stringify(item[key]);
63
- }
64
- }
65
- });
66
- return (
67
- <SchemaComponentProvider scope={{ dataSet }} components={{ TableV2, Input, FormItem }}>
68
- <SchemaComponent schema={schema} />
69
- </SchemaComponentProvider>
70
- );
71
- };
@@ -1,99 +0,0 @@
1
- import { Icon } from '@nocobase/client';
2
- import React from 'react';
3
-
4
- const RadarChart = () => (
5
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
6
- <path d="M523 573.5c-3.9 0.7-7.9 1.1-12 1.1-5.3 0-10.4-0.6-15.2-1.8l-62.2 189.7 167.4-76L523 573.5z"></path>
7
- <path d="M398.3 767.3l68.9-210.1c-6.4-6-11.5-13.3-15-21.4l-192.6 52.7L398.3 767.3z"></path>
8
- <path d="M528 448.9c4.1 1.1 8 2.6 11.7 4.5l72.5-61.8L528 263.7 528 448.9z"></path>
9
- <path d="M259.6 555.4 447.3 504c0.4-4.2 1.3-8.3 2.5-12.2L270.9 373.4 259.6 555.4z"></path>
10
- <path d="M655.5 396.7l208.3 185.7 30.2 4.8c4.8-24.6 7.4-49.9 7.4-75.9 0-95.9-34.6-183.7-92-251.6L655.5 396.7z"></path>
11
- <path d="M794.4 563.4 630.9 417.7l-67 57.1c5.6 8.3 9.3 18 10.6 28.4L794.4 563.4z"></path>
12
- <path d="M496 448.4 496 239.6l-218.8 99.6 189.4 125.4C474.7 456.8 484.8 451.1 496 448.4z"></path>
13
- <path d="M619.3 713.3 420 803.8l-19.1 81.6c35 10.3 72.1 15.9 110.4 15.9 74.4 0 143.9-20.8 203-56.9L619.3 713.3z"></path>
14
- <path d="M648.7 699.5l92.3 127.2c63.3-46.2 112.2-111 138.6-186.4L648.7 699.5z"></path>
15
- <path d="M386.2 804 226.1 597.7l-87.9 27.4c34.9 114.7 121.3 207 232.2 250L386.2 804z"></path>
16
- <path d="M226.9 564.3 240.2 353l-64.4-40.5c-34.6 58.2-54.4 126.2-54.4 198.8 0 28.4 3 56.2 8.8 82.9L226.9 564.3z"></path>
17
- <path d="M842.8 609.8l-272.7-74.7c-4 9.5-10.1 17.9-17.9 24.4l77.3 112.1L842.8 609.8z"></path>
18
- <path d="M528 205.4l108.8 165.2 151-134.5c-67-67.3-158.4-110.2-259.7-114.5L528.1 205.4z"></path>
19
- <path d="M245.7 318.4l250.3-114 0-82.8c-125 4.8-234.8 68.5-302.8 164L245.7 318.4z"></path>
20
- </svg>
21
- );
22
- const FunnelChart = () => (
23
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
24
- <path d="M533.6 784.5c6.6 16.4-1.3 35-17.6 41.7l0 0c-16.4 6.6-35-1.3-41.7-17.6L129.9 236c-6.6-16.4 1.3-35 17.6-41.7l0 0c16.4-6.6 35 1.3 41.7 17.6L533.6 784.5z"></path>
25
- <path d="M536 812.2c-6.9 16.3-25.7 23.9-41.9 17l0 0c-16.3-6.9-23.9-25.7-17-41.9l357.6-575.7c6.9-16.3 25.7-23.9 41.9-17l0 0c16.3 6.9 23.9 25.7 17 41.9L536 812.2z"></path>
26
- <path d="M895.4 224c0 17.7-14.3 32-32 32l-704 0c-17.7 0-32-14.3-32-32l0 0c0-17.7 14.3-32 32-32l704 0C881 192 895.4 206.3 895.4 224L895.4 224z"></path>
27
- <path d="M278.6 384l465 0 0 64-465 0 0-64Z"></path>
28
- <path d="M391.6 576l232.5 0 0 64-232.5 0 0-64Z"></path>
29
- </svg>
30
- );
31
- const ScatterChart = () => (
32
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
33
- <path d="M191 864c0 17.7-14.3 32-32 32l0 0c-17.7 0-32-14.3-32-32L127 160c0-17.7 14.3-32 32-32l0 0c17.7 0 32 14.3 32 32L191 864z"></path>
34
- <path d="M159 896c-17.7 0-32-14.3-32-32l0 0c0-17.7 14.3-32 32-32l712 0c17.7 0 32 14.3 32 32l0 0c0 17.7-14.3 32-32 32L159 896z"></path>
35
- <path d="M745.6 765.9"></path>
36
- <path d="M307.6 244.3m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
37
- <path d="M560 479.2m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
38
- <path d="M391.9 387.7m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
39
- <path d="M540.4 244.3m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
40
- <path d="M732.9 292.3m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
41
- <path d="M792.9 717.9m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
42
- <path d="M307.6 527.2m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
43
- <path d="M439.9 662.4m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z"></path>
44
- </svg>
45
- );
46
- const ColumnChart = () => (
47
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
48
- <path d="M191 864c0 17.7-14.3 32-32 32l0 0c-17.7 0-32-14.3-32-32L127 160c0-17.7 14.3-32 32-32l0 0c17.7 0 32 14.3 32 32L191 864z"></path>
49
- <path d="M159 896c-17.7 0-32-14.3-32-32l0 0c0-17.7 14.3-32 32-32l712 0c17.7 0 32 14.3 32 32l0 0c0 17.7-14.3 32-32 32L159 896z"></path>
50
- <path d="M745.6 765.9"></path>
51
- <path d="M342.1 734.3c0 17.5-14.2 31.7-31.7 31.7l0 0c-17.5 0-31.7-14.2-31.7-31.7L278.7 489c0-17.5 14.2-31.7 31.7-31.7l0 0c17.5 0 31.7 14.2 31.7 31.7L342.1 734.3z"></path>
52
- <path d="M493.8 734.3c0 17.5-14.2 31.7-31.7 31.7l0 0c-17.5 0-31.7-14.2-31.7-31.7L430.4 387c0-17.5 14.2-31.7 31.7-31.7l0 0c17.5 0 31.7 14.2 31.7 31.7L493.8 734.3z"></path>
53
- <path d="M797.3 734.3c0 17.5-14.2 31.7-31.7 31.7l0 0c-17.5 0-31.7-14.2-31.7-31.7L733.9 234.5c0-17.5 14.2-31.7 31.7-31.7l0 0c17.5 0 31.7 14.2 31.7 31.7L797.3 734.3z"></path>
54
- <path d="M645.5 734.3c0 17.5-14.2 31.7-31.7 31.7l0 0c-17.5 0-31.7-14.2-31.7-31.7l0-97.2c0-17.5 14.2-31.7 31.7-31.7l0 0c17.5 0 31.7 14.2 31.7 31.7L645.5 734.3z"></path>
55
- </svg>
56
- );
57
-
58
- const BarChart = () => (
59
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
60
- <path d="M131.072 156.16c0-17.92 14.336-31.744 31.744-31.744 17.92 0 31.744 14.336 31.744 31.744v712.192c0 17.92-14.336 31.744-31.744 31.744-17.92 0-31.744-14.336-31.744-31.744V156.16zM292.864 338.944c-17.408 0-31.744-14.336-31.744-31.744 0-17.408 14.336-31.744 31.744-31.744h245.248c17.408 0 31.744 14.336 31.744 31.744 0 17.408-14.336 31.744-31.744 31.744h-245.248zM292.864 490.496c-17.408 0-31.744-14.336-31.744-31.744 0-17.408 14.336-31.744 31.744-31.744H640c17.408 0 31.744 14.336 31.744 31.744 0 17.408-14.336 31.744-31.744 31.744h-347.136zM292.864 794.112c-17.408 0-31.744-14.336-31.744-31.744 0-17.408 14.336-31.744 31.744-31.744h499.712c17.408 0 31.744 14.336 31.744 31.744 0 17.408-14.336 31.744-31.744 31.744h-499.712zM292.864 642.56c-17.408 0-31.744-14.336-31.744-31.744 0-17.408 14.336-31.744 31.744-31.744h97.28c17.408 0 31.744 14.336 31.744 31.744 0 17.408-14.336 31.744-31.744 31.744h-97.28z"></path>
61
- </svg>
62
- );
63
-
64
- const LineChart = () => (
65
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
66
- <path d="M191 864c0 17.7-14.3 32-32 32l0 0c-17.7 0-32-14.3-32-32L127 160c0-17.7 14.3-32 32-32l0 0c17.7 0 32 14.3 32 32L191 864z"></path>
67
- <path d="M159 896c-17.7 0-32-14.3-32-32l0 0c0-17.7 14.3-32 32-32l712 0c17.7 0 32 14.3 32 32l0 0c0 17.7-14.3 32-32 32L159 896z"></path>
68
- <path d="M307.1 686.3c-12.4 12.4-32.4 12.4-44.8 0l0 0c-12.4-12.4-12.4-32.4 0-44.8l173.4-173.4c12.4-12.4 32.4-12.4 44.8 0l0 0c12.4 12.4 12.4 32.4 0 44.8L307.1 686.3z"></path>
69
- <path d="M608.8 640c-12.4 12.4-32.4 12.4-44.8 0l0 0c-12.4-12.4-12.4-32.4 0-44.8l212.7-212.7c12.4-12.4 32.4-12.4 44.8 0l0 0c12.4 12.4 12.4 32.4 0 44.8L608.8 640z"></path>
70
- <path d="M608 595.3c12.4 12.4 12.4 32.4 0 44.8l0 0c-12.4 12.4-32.4 12.4-44.8 0L436 512.8c-12.4-12.4-12.4-32.4 0-44.8l0 0c12.4-12.4 32.4-12.4 44.8 0L608 595.3z"></path>
71
- </svg>
72
- );
73
-
74
- const PieChart = () => (
75
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
76
- <path d="M489.7 511 489 511 489 126.9c-201 12.3-360.1 179.2-360.1 383.3 0 212.1 171.9 384 384 384 106.5 0 202.9-43.4 272.5-113.4L489.7 511z"></path>
77
- <path d="M773.1 237.2l6-6c-62.7-59.6-143.5-95.8-228.2-104l0 304.7L773.1 237.2z"></path>
78
- <path d="M819.5 281.6 564.1 505.1 822 739c3-4 5.9-8.1 8.7-12.3 41.4-61.3 65.6-135.2 65.6-214.7C896.3 425.6 867.7 345.8 819.5 281.6z"></path>
79
- </svg>
80
- );
81
-
82
- const AreaChart = () => (
83
- <svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" viewBox="0 0 1024 1024">
84
- <path d="M191 864c0 17.7-14.3 32-32 32l0 0c-17.7 0-32-14.3-32-32L127 160c0-17.7 14.3-32 32-32l0 0c17.7 0 32 14.3 32 32L191 864z"></path>
85
- <path d="M159 896c-17.7 0-32-14.3-32-32l0 0c0-17.7 14.3-32 32-32l712 0c17.7 0 32 14.3 32 32l0 0c0 17.7-14.3 32-32 32L159 896z"></path>
86
- <path d="M830.6 338.2 830.6 338.2c0.9-9.2-2.1-18.6-9.1-25.7-12.4-12.4-32.4-12.4-44.8 0L586 503.3 480.8 398.1c-6.2-6.2-14.4-9.3-22.5-9.3-8.1 0-16.3 3.1-22.5 9.3L262.4 571.5c-6 6-9.1 13.8-9.3 21.6 0 0.1 0 0.1 0 0.2l0 111.8c0 35.3 28.7 64 64 64l449.7 0c33.8 0 61.4-26.1 63.8-59.3l0 0 0-0.2c0.1-1.5 0.2-3 0.2-4.5L830.8 593.3c0-0.3-0.1-0.7-0.2-1L830.6 338.2z"></path>
87
- </svg>
88
- );
89
-
90
- Icon.register({
91
- 'icon-area': (props) => <Icon component={AreaChart} {...props} />,
92
- 'icon-pie': (props) => <Icon component={PieChart} {...props} />,
93
- 'icon-radar': (props) => <Icon component={RadarChart} {...props} />,
94
- 'icon-funnel': (props) => <Icon component={FunnelChart} {...props} />,
95
- 'icon-line': (props) => <Icon component={LineChart} {...props} />,
96
- 'icon-bar': (props) => <Icon component={BarChart} {...props} />,
97
- 'icon-column': (props) => <Icon component={ColumnChart} {...props} />,
98
- 'icon-scatter': (props) => <Icon component={ScatterChart} {...props} />,
99
- });
@@ -1,7 +0,0 @@
1
- import { G2Plot } from '@nocobase/client';
2
- import DataSetPreviewTable from '../DataSetPreviewTable';
3
-
4
- const chartRenderComponentsMap = new Map();
5
- chartRenderComponentsMap.set('G2Plot', G2Plot);
6
- chartRenderComponentsMap.set('DataSetPreviewTable', DataSetPreviewTable);
7
- export default chartRenderComponentsMap;
@@ -1,19 +0,0 @@
1
- import { useChartQueryMetadataContext } from '../ChartQueryMetadataProvider';
2
- import { useEffect, useState } from 'react';
3
-
4
- const useFieldsById = (queryId: number) => {
5
- const [fields, setFields] = useState([]);
6
- const ctx = useChartQueryMetadataContext();
7
- useEffect(() => {
8
- const chartQueryList = ctx?.data;
9
- if (chartQueryList && Array.isArray(chartQueryList)) {
10
- const currentQuery = chartQueryList.find((chartQuery) => chartQuery.id === queryId);
11
- setFields(currentQuery?.fields || []);
12
- }
13
- }, [queryId]);
14
- return {
15
- fields,
16
- };
17
- };
18
-
19
- export { useFieldsById };
@@ -1,115 +0,0 @@
1
- import { registerValidateRules } from '@formily/core';
2
- import {
3
- BlockSchemaComponentPlugin,
4
- Plugin,
5
- SchemaComponentOptions,
6
- SchemaInitializerContext,
7
- SettingsCenterProvider,
8
- useAPIClient,
9
- } from '@nocobase/client';
10
- import JSON5 from 'json5';
11
- import React, { useContext } from 'react';
12
- import { ChartBlockEngine } from './ChartBlockEngine';
13
- import { ChartBlockInitializer } from './ChartBlockInitializer';
14
- import { ChartQueryMetadataProvider } from './ChartQueryMetadataProvider';
15
- import './Icons';
16
- import { lang } from './locale';
17
- import { CustomSelect } from './select';
18
- import { QueriesTable } from './settings/QueriesTable';
19
-
20
- registerValidateRules({
21
- json5: (value, rule) => {
22
- if (!value) {
23
- return '';
24
- }
25
- try {
26
- const val = JSON5.parse(value);
27
- if (!isNaN(val)) {
28
- return {
29
- type: 'error',
30
- message: lang('Invalid JSON format'),
31
- };
32
- }
33
- return '';
34
- } catch (error) {
35
- console.error(error);
36
- return {
37
- type: 'error',
38
- message: lang('Invalid JSON format'),
39
- };
40
- }
41
- },
42
- });
43
-
44
- const ChartsProvider = React.memo((props) => {
45
- const api = useAPIClient();
46
- const items = useContext<any>(SchemaInitializerContext);
47
- const children = items.BlockInitializers.items[0].children;
48
- if (children) {
49
- const hasChartItem = children.some((child) => child?.component === 'ChartBlockInitializer');
50
- if (!hasChartItem) {
51
- children.push({
52
- key: 'chart',
53
- type: 'item',
54
- icon: 'PieChartOutlined',
55
- title: '{{t("Chart (Old)",{ns:"charts"})}}',
56
- component: 'ChartBlockInitializer',
57
- });
58
- }
59
- }
60
- const validateSQL = (sql) => {
61
- return new Promise((resolve) => {
62
- api
63
- .request({
64
- url: 'chartsQueries:validate',
65
- method: 'post',
66
- data: {
67
- sql,
68
- },
69
- })
70
- .then(({ data }) => {
71
- resolve(data?.data?.errorMessage);
72
- })
73
- .catch(() => {
74
- resolve('Invalid SQL');
75
- });
76
- });
77
- };
78
- return (
79
- <ChartQueryMetadataProvider>
80
- <SettingsCenterProvider
81
- settings={{
82
- charts: {
83
- title: '{{t("Charts", {ns:"charts"})}}',
84
- icon: 'PieChartOutlined',
85
- tabs: {
86
- queries: {
87
- title: '{{t("Queries", {ns:"charts"})}}',
88
- component: QueriesTable,
89
- },
90
- },
91
- },
92
- }}
93
- >
94
- <SchemaComponentOptions
95
- scope={{ validateSQL }}
96
- components={{ CustomSelect, ChartBlockInitializer, ChartBlockEngine }}
97
- >
98
- <SchemaInitializerContext.Provider value={items}>{props.children}</SchemaInitializerContext.Provider>
99
- </SchemaComponentOptions>
100
- </SettingsCenterProvider>
101
- </ChartQueryMetadataProvider>
102
- );
103
- });
104
- ChartsProvider.displayName = 'ChartsProvider';
105
-
106
- export class ChartsPlugin extends Plugin {
107
- async load() {
108
- this.app.use(ChartsProvider);
109
-
110
- // TODO: 主应用应该会有这个插件,按道理不需要再注册
111
- this.app.pm.add(BlockSchemaComponentPlugin);
112
- }
113
- }
114
-
115
- export default ChartsPlugin;
@@ -1,18 +0,0 @@
1
- import { i18n } from '@nocobase/client';
2
- import { useTranslation } from 'react-i18next';
3
-
4
- export const NAMESPACE = 'charts';
5
-
6
- // i18n.addResources('zh-CN', NAMESPACE, zhCN);
7
- // i18n.addResources('en-US', NAMESPACE, enUS);
8
- // i18n.addResources('ja-JP', NAMESPACE, jaJP);
9
- // i18n.addResources('ru-RU', NAMESPACE, ruRU);
10
- // i18n.addResources('tr-TR', NAMESPACE, trTR);
11
-
12
- export function lang(key: string) {
13
- return i18n.t(key, { ns: NAMESPACE });
14
- }
15
-
16
- export function useChartsTranslation() {
17
- return useTranslation(NAMESPACE);
18
- }
@@ -1,126 +0,0 @@
1
- import { LoadingOutlined } from '@ant-design/icons';
2
- import { connect, mapProps, mapReadPretty } from '@formily/react';
3
- import { isValid } from '@formily/shared';
4
- import { css, Icon } from '@nocobase/client';
5
- import type { SelectProps } from 'antd';
6
- import { Popover, Select as AntdSelect } from 'antd';
7
- import React from 'react';
8
- import { lang } from '../locale';
9
- import { ReadPretty } from './ReadPretty';
10
-
11
- type Props = SelectProps<any, any> & { objectValue?: boolean; onChange?: (v: any) => void; multiple: boolean };
12
-
13
- const isEmptyObject = (val: any) => !isValid(val) || (typeof val === 'object' && Object.keys(val).length === 0);
14
-
15
- const { Option, OptGroup } = AntdSelect;
16
- const filterOption = (input, option) => (option?.label ?? '').toLowerCase().includes((input || '').toLowerCase());
17
-
18
- const InternalSelect = connect(
19
- (props: Props) => {
20
- const { ...others } = props;
21
- const { options, ...othersProps } = { ...others };
22
- const mode = props.mode || props.multiple ? 'multiple' : undefined;
23
- const group1 = options.filter((option) => option.group === 2);
24
- const group2 = options.filter((option) => option.group === 1);
25
- return (
26
- <AntdSelect
27
- showSearch
28
- filterOption={filterOption}
29
- allowClear
30
- {...othersProps}
31
- onChange={(changed) => {
32
- props.onChange?.(changed === undefined ? null : changed);
33
- }}
34
- mode={mode}
35
- >
36
- <OptGroup label={lang('Basic charts')}>
37
- {group1.map((option) => (
38
- <Option value={option.key} label={lang(option.title)}>
39
- <Popover
40
- placement={'right'}
41
- zIndex={99999999999}
42
- content={() => (
43
- <span>
44
- {lang(option?.description)
45
- ?.split(',')
46
- .map((item) => (
47
- <div>{item}</div>
48
- ))}
49
- </span>
50
- )}
51
- trigger="hover"
52
- >
53
- <div
54
- className={css`
55
- display: flex;
56
- gap: 4px;
57
- align-items: center;
58
- `}
59
- >
60
- <Icon type={option.iconId} />
61
- <span role="img" aria-label={lang(option.title)}>
62
- {lang(option.title)}
63
- </span>
64
- </div>
65
- </Popover>
66
- </Option>
67
- ))}
68
- </OptGroup>
69
- <OptGroup label={lang('More charts')}>
70
- {group2.map((option) => (
71
- <Option value={option.key} label={lang(option.title)}>
72
- <Popover
73
- placement={'right'}
74
- zIndex={99999999999}
75
- content={() => (
76
- <span>
77
- {lang(option?.description)
78
- ?.split(',')
79
- .map((item) => (
80
- <div>{item}</div>
81
- ))}
82
- </span>
83
- )}
84
- trigger="hover"
85
- >
86
- <div
87
- className={css`
88
- display: flex;
89
- gap: 4px;
90
- align-items: center;
91
- `}
92
- >
93
- <Icon type={option.iconId} />
94
- <span role="img" aria-label={lang(option.title)}>
95
- {lang(option.title)}
96
- </span>
97
- </div>
98
- </Popover>
99
- </Option>
100
- ))}
101
- </OptGroup>
102
- </AntdSelect>
103
- );
104
- },
105
- mapProps(
106
- {
107
- dataSource: 'options',
108
- loading: true,
109
- },
110
- (props, field) => {
111
- return {
112
- ...props,
113
- suffixIcon: field?.['loading'] || field?.['validating'] ? <LoadingOutlined /> : props?.suffixIcon,
114
- };
115
- },
116
- ),
117
- mapReadPretty(ReadPretty),
118
- );
119
-
120
- export const CustomSelect = InternalSelect as unknown as typeof InternalSelect & {
121
- ReadPretty: typeof ReadPretty;
122
- };
123
-
124
- CustomSelect.ReadPretty = ReadPretty;
125
-
126
- export default CustomSelect;
@@ -1,39 +0,0 @@
1
- import { isArrayField } from '@formily/core';
2
- import { observer, useField } from '@formily/react';
3
- import { isValid } from '@formily/shared';
4
- import { Tag } from 'antd';
5
- import React from 'react';
6
- import { defaultFieldNames, getCurrentOptions } from './shared';
7
- import { useCompile } from '@nocobase/client';
8
-
9
- type Composed = {
10
- Select?: React.FC<any>;
11
- Object?: React.FC<any>;
12
- };
13
-
14
- export const ReadPretty = observer(
15
- (props: any) => {
16
- const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
17
- const field = useField<any>();
18
- const compile = useCompile();
19
-
20
- if (!isValid(props.value)) {
21
- return <div />;
22
- }
23
- if (isArrayField(field) && field?.value?.length === 0) {
24
- return <div />;
25
- }
26
- const dataSource = field.dataSource || props.options || [];
27
- const options = getCurrentOptions(field.value, dataSource, fieldNames);
28
- return (
29
- <div>
30
- {options.map((option, key) => (
31
- <Tag key={key} color={option[fieldNames.color]} icon={option.icon}>
32
- {compile(option[fieldNames.label])}
33
- </Tag>
34
- ))}
35
- </div>
36
- );
37
- },
38
- { displayName: 'ReadPretty' },
39
- );
@@ -1,31 +0,0 @@
1
- # Select
2
-
3
- ## Examples
4
-
5
- ### 单选
6
-
7
- <code src="./demos/demo1.tsx"></code>
8
-
9
- ### 多选
10
-
11
- <code src="./demos/demo2.tsx"></code>
12
-
13
- ### 值为 Object 类型的 Select
14
-
15
- <code src="./demos/demo3.tsx"></code>
16
-
17
- ## API
18
-
19
- 基于 Ant Design 的 [Select](https://ant.design/components/select/#API),相关扩展属性有:
20
-
21
- - `objectValue` 值为 object 类型
22
- - `fieldNames` 默认值有区别
23
-
24
- ```ts
25
- export const defaultFieldNames = {
26
- label: 'label',
27
- value: 'value',
28
- color: 'color',
29
- options: 'children',
30
- };
31
- ```
@@ -1,2 +0,0 @@
1
- export * from './CustomSelect';
2
- export * from './shared';
@@ -1,37 +0,0 @@
1
- import { lodash } from '@nocobase/utils/client';
2
-
3
- export const defaultFieldNames = {
4
- label: 'label',
5
- value: 'value',
6
- color: 'color',
7
- options: 'children',
8
- };
9
-
10
- export const getCurrentOptions = (values, dataSource, fieldNames) => {
11
- function flatData(data) {
12
- const newArr = [];
13
- for (let i = 0; i < data.length; i++) {
14
- const children = data[i][fieldNames.options];
15
- if (Array.isArray(children)) {
16
- newArr.push(...flatData(children));
17
- }
18
- newArr.push({ ...data[i] });
19
- }
20
- return newArr;
21
- }
22
- const result = flatData(dataSource);
23
- values = lodash
24
- .castArray(values)
25
- .filter((item) => item != null)
26
- .map((val) => (typeof val === 'object' ? val[fieldNames.value] : val));
27
- const findOptions = (options: any[]) => {
28
- if (!options) return [];
29
- const current = [];
30
- for (const value of values) {
31
- const option = options.find((v) => v[fieldNames.value] === value) || { value: value, label: value };
32
- current.push(option);
33
- }
34
- return current;
35
- };
36
- return findOptions(result);
37
- };