@antv/infographic 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/dist/infographic.min.js +110 -105
  2. package/dist/infographic.min.js.map +1 -1
  3. package/esm/constants/element.d.ts +1 -1
  4. package/esm/constants/index.d.ts +1 -0
  5. package/esm/constants/index.js +1 -0
  6. package/esm/constants/service.d.ts +1 -0
  7. package/esm/constants/service.js +1 -0
  8. package/esm/designs/components/Illus.js +1 -1
  9. package/esm/designs/structures/chart-wordcloud.d.ts +11 -0
  10. package/esm/designs/structures/chart-wordcloud.js +156 -0
  11. package/esm/designs/structures/hierarchy-tree.d.ts +2 -0
  12. package/esm/designs/structures/hierarchy-tree.js +179 -50
  13. package/esm/designs/structures/index.d.ts +2 -0
  14. package/esm/designs/structures/index.js +2 -0
  15. package/esm/designs/structures/sequence-stairs-front.d.ts +8 -0
  16. package/esm/designs/structures/sequence-stairs-front.js +116 -0
  17. package/esm/designs/types.d.ts +8 -0
  18. package/esm/editor/managers/state.js +1 -1
  19. package/esm/index.d.ts +2 -0
  20. package/esm/index.js +1 -0
  21. package/esm/options/parser.d.ts +1 -1
  22. package/esm/options/parser.js +33 -15
  23. package/esm/renderer/composites/icon.js +1 -1
  24. package/esm/renderer/composites/illus.js +1 -1
  25. package/esm/resource/loader.d.ts +2 -2
  26. package/esm/resource/loader.js +22 -11
  27. package/esm/resource/loaders/index.d.ts +1 -0
  28. package/esm/resource/loaders/index.js +1 -0
  29. package/esm/resource/loaders/remote.d.ts +1 -1
  30. package/esm/resource/loaders/remote.js +10 -2
  31. package/esm/resource/loaders/search.d.ts +1 -0
  32. package/esm/resource/loaders/search.js +51 -0
  33. package/esm/resource/types/index.d.ts +1 -0
  34. package/esm/resource/types/resource.d.ts +8 -1
  35. package/esm/resource/types/scene.d.ts +1 -0
  36. package/esm/resource/utils/data-uri.js +20 -11
  37. package/esm/resource/utils/parser.js +92 -1
  38. package/esm/resource/utils/ref.js +2 -2
  39. package/esm/runtime/Infographic.d.ts +7 -6
  40. package/esm/runtime/Infographic.js +48 -17
  41. package/esm/runtime/utils.d.ts +4 -2
  42. package/esm/runtime/utils.js +33 -13
  43. package/esm/syntax/index.d.ts +3 -0
  44. package/esm/syntax/index.js +101 -0
  45. package/esm/syntax/mapper.d.ts +3 -0
  46. package/esm/syntax/mapper.js +238 -0
  47. package/esm/syntax/parser.d.ts +14 -0
  48. package/esm/syntax/parser.js +142 -0
  49. package/esm/syntax/schema.d.ts +6 -0
  50. package/esm/syntax/schema.js +74 -0
  51. package/esm/syntax/types.d.ts +61 -0
  52. package/esm/syntax/types.js +1 -0
  53. package/esm/templates/built-in.js +4 -0
  54. package/esm/templates/hierarchy-tree.js +25 -11
  55. package/esm/templates/sequence-stairs.d.ts +2 -0
  56. package/esm/templates/sequence-stairs.js +42 -0
  57. package/esm/templates/word-cloud.d.ts +2 -0
  58. package/esm/templates/word-cloud.js +19 -0
  59. package/esm/themes/types.d.ts +1 -1
  60. package/esm/utils/design.d.ts +2 -0
  61. package/esm/utils/design.js +10 -0
  62. package/esm/utils/font.js +11 -1
  63. package/esm/utils/index.d.ts +1 -0
  64. package/esm/utils/index.js +1 -0
  65. package/lib/constants/element.d.ts +1 -1
  66. package/lib/constants/index.d.ts +1 -0
  67. package/lib/constants/index.js +1 -0
  68. package/lib/constants/service.d.ts +1 -0
  69. package/lib/constants/service.js +4 -0
  70. package/lib/designs/components/Illus.js +1 -1
  71. package/lib/designs/structures/chart-wordcloud.d.ts +11 -0
  72. package/lib/designs/structures/chart-wordcloud.js +160 -0
  73. package/lib/designs/structures/hierarchy-tree.d.ts +2 -0
  74. package/lib/designs/structures/hierarchy-tree.js +179 -50
  75. package/lib/designs/structures/index.d.ts +2 -0
  76. package/lib/designs/structures/index.js +2 -0
  77. package/lib/designs/structures/sequence-stairs-front.d.ts +8 -0
  78. package/lib/designs/structures/sequence-stairs-front.js +120 -0
  79. package/lib/designs/types.d.ts +8 -0
  80. package/lib/editor/managers/state.js +1 -1
  81. package/lib/index.d.ts +2 -0
  82. package/lib/index.js +4 -1
  83. package/lib/options/parser.d.ts +1 -1
  84. package/lib/options/parser.js +32 -14
  85. package/lib/renderer/composites/icon.js +1 -1
  86. package/lib/renderer/composites/illus.js +1 -1
  87. package/lib/resource/loader.d.ts +2 -2
  88. package/lib/resource/loader.js +21 -10
  89. package/lib/resource/loaders/index.d.ts +1 -0
  90. package/lib/resource/loaders/index.js +1 -0
  91. package/lib/resource/loaders/remote.d.ts +1 -1
  92. package/lib/resource/loaders/remote.js +10 -2
  93. package/lib/resource/loaders/search.d.ts +1 -0
  94. package/lib/resource/loaders/search.js +54 -0
  95. package/lib/resource/types/index.d.ts +1 -0
  96. package/lib/resource/types/resource.d.ts +8 -1
  97. package/lib/resource/types/scene.d.ts +1 -0
  98. package/lib/resource/utils/data-uri.js +20 -11
  99. package/lib/resource/utils/parser.js +92 -1
  100. package/lib/resource/utils/ref.js +2 -2
  101. package/lib/runtime/Infographic.d.ts +7 -6
  102. package/lib/runtime/Infographic.js +47 -16
  103. package/lib/runtime/utils.d.ts +4 -2
  104. package/lib/runtime/utils.js +35 -13
  105. package/lib/syntax/index.d.ts +3 -0
  106. package/lib/syntax/index.js +104 -0
  107. package/lib/syntax/mapper.d.ts +3 -0
  108. package/lib/syntax/mapper.js +242 -0
  109. package/lib/syntax/parser.d.ts +14 -0
  110. package/lib/syntax/parser.js +146 -0
  111. package/lib/syntax/schema.d.ts +6 -0
  112. package/lib/syntax/schema.js +77 -0
  113. package/lib/syntax/types.d.ts +61 -0
  114. package/lib/syntax/types.js +2 -0
  115. package/lib/templates/built-in.js +4 -0
  116. package/lib/templates/hierarchy-tree.js +25 -11
  117. package/lib/templates/sequence-stairs.d.ts +2 -0
  118. package/lib/templates/sequence-stairs.js +45 -0
  119. package/lib/templates/word-cloud.d.ts +2 -0
  120. package/lib/templates/word-cloud.js +22 -0
  121. package/lib/themes/types.d.ts +1 -1
  122. package/lib/utils/design.d.ts +2 -0
  123. package/lib/utils/design.js +13 -0
  124. package/lib/utils/font.js +11 -1
  125. package/lib/utils/index.d.ts +1 -0
  126. package/lib/utils/index.js +1 -0
  127. package/package.json +1 -1
  128. package/src/constants/element.ts +1 -1
  129. package/src/constants/index.ts +1 -0
  130. package/src/constants/service.ts +1 -0
  131. package/src/designs/components/Illus.tsx +1 -1
  132. package/src/designs/structures/chart-wordcloud.tsx +278 -0
  133. package/src/designs/structures/hierarchy-tree.tsx +212 -59
  134. package/src/designs/structures/index.ts +2 -0
  135. package/src/designs/structures/sequence-stairs-front.tsx +291 -0
  136. package/src/designs/types.ts +9 -0
  137. package/src/editor/managers/state.ts +1 -1
  138. package/src/index.ts +2 -0
  139. package/src/options/parser.ts +57 -28
  140. package/src/renderer/composites/icon.ts +1 -1
  141. package/src/renderer/composites/illus.ts +1 -1
  142. package/src/resource/loader.ts +22 -8
  143. package/src/resource/loaders/index.ts +1 -0
  144. package/src/resource/loaders/remote.ts +9 -2
  145. package/src/resource/loaders/search.ts +52 -0
  146. package/src/resource/types/index.ts +2 -1
  147. package/src/resource/types/resource.ts +12 -1
  148. package/src/resource/types/scene.ts +1 -0
  149. package/src/resource/utils/data-uri.ts +20 -11
  150. package/src/resource/utils/parser.ts +103 -2
  151. package/src/resource/utils/ref.ts +2 -2
  152. package/src/runtime/Infographic.tsx +74 -22
  153. package/src/runtime/utils.ts +38 -16
  154. package/src/syntax/index.ts +124 -0
  155. package/src/syntax/mapper.ts +362 -0
  156. package/src/syntax/parser.ts +171 -0
  157. package/src/syntax/schema.ts +98 -0
  158. package/src/syntax/types.ts +89 -0
  159. package/src/templates/built-in.ts +4 -0
  160. package/src/templates/hierarchy-tree.ts +34 -11
  161. package/src/templates/sequence-stairs.ts +44 -0
  162. package/src/templates/word-cloud.ts +21 -0
  163. package/src/themes/types.ts +1 -1
  164. package/src/utils/design.ts +14 -0
  165. package/src/utils/font.ts +11 -1
  166. package/src/utils/index.ts +1 -0
  167. package/esm/resource/types/font.d.ts +0 -12
  168. package/lib/resource/types/font.d.ts +0 -12
  169. package/src/resource/types/font.ts +0 -23
  170. /package/esm/resource/types/{font.js → scene.js} +0 -0
  171. /package/lib/resource/types/{font.js → scene.js} +0 -0
@@ -1,7 +1,9 @@
1
1
  import { hierarchyMindmapTemplates } from './hierarchy-mindmap';
2
2
  import { hierarchyTreeTemplates } from './hierarchy-tree';
3
3
  import { registerTemplate } from './registry';
4
+ import { sequenceStairsTemplates } from './sequence-stairs';
4
5
  import type { TemplateOptions } from './types';
6
+ import { wordCloudTemplate } from './word-cloud';
5
7
 
6
8
  const BUILT_IN_TEMPLATES: Record<string, TemplateOptions> = {
7
9
  'compare-hierarchy-left-right-circle-node-pill-badge': {
@@ -803,6 +805,8 @@ const BUILT_IN_TEMPLATES: Record<string, TemplateOptions> = {
803
805
  },
804
806
  ...hierarchyTreeTemplates,
805
807
  ...hierarchyMindmapTemplates,
808
+ ...sequenceStairsTemplates,
809
+ ...wordCloudTemplate,
806
810
  };
807
811
 
808
812
  Object.entries(BUILT_IN_TEMPLATES).forEach(([name, options]) => {
@@ -52,19 +52,42 @@ const items: string[] = [
52
52
  export const hierarchyTreeTemplates: Record<string, TemplateOptions> = {};
53
53
 
54
54
  const structureName = 'hierarchy-tree';
55
+ const orientationConfigs: Array<{
56
+ key: string;
57
+ orientation?: HierarchyTreeProps['orientation'];
58
+ }> = [
59
+ { key: '' },
60
+ { key: 'bt', orientation: 'bottom-top' },
61
+ { key: 'lr', orientation: 'left-right' },
62
+ { key: 'rl', orientation: 'right-left' },
63
+ ];
64
+
65
+ const createTemplateName = (
66
+ oriKey: string,
67
+ name: string,
68
+ item: string,
69
+ ): string => {
70
+ return oriKey
71
+ ? `${structureName}-${oriKey}-${name}-${item}`
72
+ : `${structureName}-${name}-${item}`;
73
+ };
74
+
55
75
  for (const item of items) {
56
76
  for (const [name, structureProps] of Object.entries(structures)) {
57
- const templateName = `${structureName}-${name}-${item}`;
58
- hierarchyTreeTemplates[templateName] = {
59
- design: {
60
- structure: {
61
- type: 'hierarchy-tree',
62
- ...structureProps,
63
- },
64
- item: {
65
- type: item,
77
+ for (const { key, orientation } of orientationConfigs) {
78
+ const templateName = createTemplateName(key, name, item);
79
+ hierarchyTreeTemplates[templateName] = {
80
+ design: {
81
+ structure: {
82
+ type: 'hierarchy-tree',
83
+ ...(orientation ? { orientation } : {}),
84
+ ...structureProps,
85
+ },
86
+ item: {
87
+ type: item,
88
+ },
66
89
  },
67
- },
68
- };
90
+ };
91
+ }
69
92
  }
70
93
  }
@@ -0,0 +1,44 @@
1
+ import type { TemplateOptions } from './types';
2
+
3
+ export const sequenceStairsTemplates: Record<string, TemplateOptions> = {
4
+ 'sequence-stairs-front-pill-badge': {
5
+ design: {
6
+ title: 'default',
7
+ structure: {
8
+ type: 'sequence-stairs-front',
9
+ },
10
+ items: [
11
+ {
12
+ type: 'pill-badge',
13
+ },
14
+ ],
15
+ },
16
+ },
17
+ 'sequence-stairs-front-compact-card': {
18
+ design: {
19
+ title: 'default',
20
+ structure: {
21
+ type: 'sequence-stairs-front',
22
+ },
23
+ items: [
24
+ {
25
+ type: 'compact-card',
26
+ },
27
+ ],
28
+ },
29
+ },
30
+ 'sequence-stairs-front-simple': {
31
+ design: {
32
+ title: 'default',
33
+ structure: {
34
+ type: 'sequence-stairs-front',
35
+ },
36
+ items: [
37
+ {
38
+ type: 'simple',
39
+ usePaletteColor: true,
40
+ },
41
+ ],
42
+ },
43
+ },
44
+ };
@@ -0,0 +1,21 @@
1
+ import type { TemplateOptions } from './types';
2
+
3
+ export const wordCloudTemplate: Record<string, TemplateOptions> = {
4
+ 'chart-wordcloud-rotate': {
5
+ design: {
6
+ structure: {
7
+ type: 'chart-wordcloud',
8
+ },
9
+ item: 'simple',
10
+ },
11
+ },
12
+ 'chart-wordcloud': {
13
+ design: {
14
+ structure: {
15
+ type: 'chart-wordcloud',
16
+ enableRotate: false,
17
+ },
18
+ item: 'simple',
19
+ },
20
+ },
21
+ };
@@ -29,7 +29,7 @@ export interface ThemeConfig {
29
29
  palette?: Palette;
30
30
  title?: TextAttributes;
31
31
  desc?: TextAttributes;
32
- shape?: TextAttributes;
32
+ shape?: ShapeAttributes;
33
33
  item?: {
34
34
  icon?: DynamicAttributes<IconAttributes>;
35
35
  label?: DynamicAttributes<TextAttributes>;
@@ -0,0 +1,14 @@
1
+ import type {
2
+ NullableParsedDesignsOptions,
3
+ ParsedDesignsOptions,
4
+ } from '../designs';
5
+
6
+ export function isNonNullableParsedDesignsOptions(
7
+ options: NullableParsedDesignsOptions,
8
+ ): options is ParsedDesignsOptions {
9
+ const { structure, item, items } = options;
10
+ if (!structure) return false;
11
+ if (!item) return false;
12
+ if (items.some((it) => !it)) return false;
13
+ return true;
14
+ }
package/src/utils/font.ts CHANGED
@@ -14,21 +14,31 @@ export function encodeFontFamily(font: string) {
14
14
  const FontWeightNameMap: Record<string, FontWeightName> = {
15
15
  '100': 'thin',
16
16
  hairline: 'thin',
17
+ thin: 'thin',
17
18
  '200': 'extralight',
18
19
  ultralight: 'extralight',
20
+ extralight: 'extralight',
19
21
  '300': 'light',
22
+ light: 'light',
20
23
  '400': 'regular',
21
24
  normal: 'regular',
25
+ regular: 'regular',
22
26
  '500': 'medium',
27
+ medium: 'medium',
23
28
  '600': 'semibold',
24
29
  demibold: 'semibold',
30
+ semibold: 'semibold',
25
31
  '700': 'bold',
32
+ bold: 'bold',
26
33
  '800': 'extrabold',
27
- ultrabold: 'bold',
34
+ ultrabold: 'extrabold',
35
+ extrabold: 'extrabold',
28
36
  '900': 'black',
29
37
  heavy: 'black',
38
+ black: 'black',
30
39
  '950': 'extrablack',
31
40
  ultrablack: 'extrablack',
41
+ extrablack: 'extrablack',
32
42
  };
33
43
 
34
44
  export function normalizeFontWeightName(
@@ -1,6 +1,7 @@
1
1
  export * from './attrs';
2
2
  export * from './color';
3
3
  export * from './data';
4
+ export * from './design';
4
5
  export * from './element';
5
6
  export * from './font';
6
7
  export * from './get-types';
@@ -1,12 +0,0 @@
1
- /**
2
- * https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping
3
- */
4
- export type FontWeightName = 'thin' | 'extralight' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'extrabold' | 'black' | 'extrablack';
5
- export interface Font {
6
- font: string;
7
- name: string;
8
- /** 字体 CDN */
9
- fontWeight: {
10
- [keys in FontWeightName]?: string;
11
- };
12
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping
3
- */
4
- export type FontWeightName = 'thin' | 'extralight' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'extrabold' | 'black' | 'extrablack';
5
- export interface Font {
6
- font: string;
7
- name: string;
8
- /** 字体 CDN */
9
- fontWeight: {
10
- [keys in FontWeightName]?: string;
11
- };
12
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping
3
- */
4
- export type FontWeightName =
5
- | 'thin'
6
- | 'extralight'
7
- | 'light'
8
- | 'regular'
9
- | 'medium'
10
- | 'semibold'
11
- | 'bold'
12
- | 'extrabold'
13
- | 'black'
14
- | 'extrablack';
15
-
16
- export interface Font {
17
- font: string;
18
- name: string;
19
- /** 字体 CDN */
20
- fontWeight: {
21
- [keys in FontWeightName]?: string;
22
- };
23
- }
File without changes
File without changes