@antv/gpt-vis 1.0.0-beta.1 → 1.0.0-beta.2

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 (157) hide show
  1. package/README.md +6 -4
  2. package/README.zh-CN.md +6 -4
  3. package/dist/cjs/gpt-vis/index.d.ts +8 -1
  4. package/dist/cjs/gpt-vis/index.js +43 -20
  5. package/dist/cjs/index.d.ts +15 -2
  6. package/dist/cjs/index.js +22 -2
  7. package/dist/cjs/syntax/parser.d.ts +17 -2
  8. package/dist/cjs/syntax/parser.js +151 -38
  9. package/dist/cjs/util/container.d.ts +5 -0
  10. package/dist/cjs/util/container.js +43 -0
  11. package/dist/cjs/util/theme.d.ts +5 -0
  12. package/dist/cjs/util/theme.js +9 -2
  13. package/dist/cjs/vis/area/index.js +2 -1
  14. package/dist/cjs/vis/bar/index.js +5 -4
  15. package/dist/cjs/vis/boxplot/index.js +7 -2
  16. package/dist/cjs/vis/column/index.js +5 -4
  17. package/dist/cjs/vis/dual-axes/index.js +2 -1
  18. package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
  19. package/dist/cjs/vis/fishbone-diagram/index.js +183 -0
  20. package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
  21. package/dist/cjs/vis/flow-diagram/index.js +271 -0
  22. package/dist/cjs/vis/funnel/index.js +2 -1
  23. package/dist/cjs/vis/histogram/index.js +3 -7
  24. package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
  25. package/dist/cjs/vis/indented-tree/index.js +375 -0
  26. package/dist/cjs/vis/line/index.js +2 -1
  27. package/dist/cjs/vis/liquid/index.js +2 -1
  28. package/dist/cjs/vis/mindmap/index.d.ts +32 -0
  29. package/dist/cjs/vis/mindmap/index.js +214 -0
  30. package/dist/cjs/vis/network-graph/index.d.ts +59 -0
  31. package/dist/cjs/vis/network-graph/index.js +166 -0
  32. package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
  33. package/dist/cjs/vis/organization-chart/index.js +191 -0
  34. package/dist/cjs/vis/pie/index.js +3 -3
  35. package/dist/cjs/vis/radar/index.d.ts +1 -0
  36. package/dist/cjs/vis/radar/index.js +10 -9
  37. package/dist/cjs/vis/sankey/index.js +2 -1
  38. package/dist/cjs/vis/scatter/index.js +2 -1
  39. package/dist/cjs/vis/summary/index.js +17 -3
  40. package/dist/cjs/vis/table/index.d.ts +1 -0
  41. package/dist/cjs/vis/table/index.js +37 -1
  42. package/dist/cjs/vis/treemap/index.js +2 -1
  43. package/dist/cjs/vis/venn/index.d.ts +2 -1
  44. package/dist/cjs/vis/venn/index.js +18 -3
  45. package/dist/cjs/vis/violin/index.js +2 -1
  46. package/dist/cjs/vis/waterfall/index.d.ts +6 -9
  47. package/dist/cjs/vis/waterfall/index.js +28 -5
  48. package/dist/cjs/vis/word-cloud/index.js +2 -1
  49. package/dist/cjs/vis-wrapper/icons.js +2 -2
  50. package/dist/cjs/vis-wrapper/index.d.ts +1 -0
  51. package/dist/cjs/vis-wrapper/index.js +27 -16
  52. package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
  53. package/dist/cjs/vis-wrapper/styles.js +8 -1
  54. package/dist/esm/gpt-vis/index.d.ts +8 -1
  55. package/dist/esm/gpt-vis/index.js +47 -26
  56. package/dist/esm/index.d.ts +15 -2
  57. package/dist/esm/index.js +7 -1
  58. package/dist/esm/syntax/parser.d.ts +17 -2
  59. package/dist/esm/syntax/parser.js +248 -90
  60. package/dist/esm/util/container.d.ts +5 -0
  61. package/dist/esm/util/container.js +20 -0
  62. package/dist/esm/util/theme.d.ts +5 -0
  63. package/dist/esm/util/theme.js +9 -0
  64. package/dist/esm/vis/area/index.js +3 -2
  65. package/dist/esm/vis/bar/index.js +7 -6
  66. package/dist/esm/vis/boxplot/index.js +17 -4
  67. package/dist/esm/vis/column/index.js +7 -6
  68. package/dist/esm/vis/dual-axes/index.js +3 -2
  69. package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
  70. package/dist/esm/vis/fishbone-diagram/index.js +218 -0
  71. package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
  72. package/dist/esm/vis/flow-diagram/index.js +342 -0
  73. package/dist/esm/vis/funnel/index.js +3 -2
  74. package/dist/esm/vis/histogram/index.js +6 -7
  75. package/dist/esm/vis/indented-tree/index.d.ts +40 -0
  76. package/dist/esm/vis/indented-tree/index.js +564 -0
  77. package/dist/esm/vis/line/index.js +3 -2
  78. package/dist/esm/vis/liquid/index.js +3 -2
  79. package/dist/esm/vis/mindmap/index.d.ts +32 -0
  80. package/dist/esm/vis/mindmap/index.js +315 -0
  81. package/dist/esm/vis/network-graph/index.d.ts +59 -0
  82. package/dist/esm/vis/network-graph/index.js +240 -0
  83. package/dist/esm/vis/organization-chart/index.d.ts +64 -0
  84. package/dist/esm/vis/organization-chart/index.js +269 -0
  85. package/dist/esm/vis/pie/index.js +4 -8
  86. package/dist/esm/vis/radar/index.d.ts +1 -0
  87. package/dist/esm/vis/radar/index.js +20 -4
  88. package/dist/esm/vis/sankey/index.js +3 -2
  89. package/dist/esm/vis/scatter/index.js +3 -2
  90. package/dist/esm/vis/summary/index.js +25 -4
  91. package/dist/esm/vis/table/index.d.ts +1 -0
  92. package/dist/esm/vis/table/index.js +9 -2
  93. package/dist/esm/vis/treemap/index.js +3 -2
  94. package/dist/esm/vis/venn/index.d.ts +2 -1
  95. package/dist/esm/vis/venn/index.js +29 -4
  96. package/dist/esm/vis/violin/index.js +3 -2
  97. package/dist/esm/vis/waterfall/index.d.ts +6 -9
  98. package/dist/esm/vis/waterfall/index.js +27 -9
  99. package/dist/esm/vis/word-cloud/index.js +3 -2
  100. package/dist/esm/vis-wrapper/icons.js +2 -2
  101. package/dist/esm/vis-wrapper/index.d.ts +1 -0
  102. package/dist/esm/vis-wrapper/index.js +15 -10
  103. package/dist/esm/vis-wrapper/styles.d.ts +1 -1
  104. package/dist/esm/vis-wrapper/styles.js +1 -1
  105. package/dist/umd/index.min.js +1 -1
  106. package/package.json +19 -19
  107. package/src/gpt-vis/index.ts +0 -283
  108. package/src/index.ts +0 -44
  109. package/src/readme.md +0 -37
  110. package/src/syntax/index.ts +0 -2
  111. package/src/syntax/parser.ts +0 -411
  112. package/src/types/index.ts +0 -29
  113. package/src/util/theme.ts +0 -167
  114. package/src/vis/area/README.md +0 -143
  115. package/src/vis/area/index.ts +0 -212
  116. package/src/vis/bar/README.md +0 -158
  117. package/src/vis/bar/index.ts +0 -186
  118. package/src/vis/boxplot/README.md +0 -168
  119. package/src/vis/boxplot/index.ts +0 -162
  120. package/src/vis/column/README.md +0 -158
  121. package/src/vis/column/index.ts +0 -185
  122. package/src/vis/dual-axes/README.md +0 -191
  123. package/src/vis/dual-axes/index.ts +0 -218
  124. package/src/vis/funnel/README.md +0 -143
  125. package/src/vis/funnel/index.ts +0 -238
  126. package/src/vis/histogram/README.md +0 -130
  127. package/src/vis/histogram/index.ts +0 -153
  128. package/src/vis/line/README.md +0 -138
  129. package/src/vis/line/index.ts +0 -159
  130. package/src/vis/liquid/README.md +0 -150
  131. package/src/vis/liquid/index.ts +0 -130
  132. package/src/vis/pie/README.md +0 -127
  133. package/src/vis/pie/index.ts +0 -163
  134. package/src/vis/radar/README.md +0 -184
  135. package/src/vis/radar/index.ts +0 -214
  136. package/src/vis/sankey/README.md +0 -144
  137. package/src/vis/sankey/index.ts +0 -144
  138. package/src/vis/scatter/README.md +0 -145
  139. package/src/vis/scatter/index.ts +0 -147
  140. package/src/vis/summary/README.md +0 -272
  141. package/src/vis/summary/index.ts +0 -91
  142. package/src/vis/table/README.md +0 -174
  143. package/src/vis/table/index.ts +0 -241
  144. package/src/vis/treemap/README.md +0 -199
  145. package/src/vis/treemap/index.ts +0 -167
  146. package/src/vis/venn/README.md +0 -153
  147. package/src/vis/venn/index.ts +0 -149
  148. package/src/vis/violin/README.md +0 -168
  149. package/src/vis/violin/index.ts +0 -216
  150. package/src/vis/waterfall/README.md +0 -178
  151. package/src/vis/waterfall/index.ts +0 -258
  152. package/src/vis/word-cloud/README.md +0 -137
  153. package/src/vis/word-cloud/index.ts +0 -137
  154. package/src/vis-wrapper/README.md +0 -159
  155. package/src/vis-wrapper/icons.ts +0 -35
  156. package/src/vis-wrapper/index.ts +0 -276
  157. package/src/vis-wrapper/styles.ts +0 -195
package/dist/esm/index.js CHANGED
@@ -1,14 +1,20 @@
1
1
  export { GPTVis } from "./gpt-vis";
2
- export { isVisSyntax } from "./syntax";
2
+ export { isVisSyntax, parse } from "./syntax";
3
3
  export { Area } from "./vis/area";
4
4
  export { Bar } from "./vis/bar";
5
5
  export { Boxplot } from "./vis/boxplot";
6
6
  export { Column } from "./vis/column";
7
7
  export { DualAxes } from "./vis/dual-axes";
8
+ export { FishboneDiagram } from "./vis/fishbone-diagram";
9
+ export { FlowDiagram } from "./vis/flow-diagram";
8
10
  export { Funnel } from "./vis/funnel";
9
11
  export { Histogram } from "./vis/histogram";
12
+ export { IndentedTree } from "./vis/indented-tree";
10
13
  export { Line } from "./vis/line";
11
14
  export { Liquid } from "./vis/liquid";
15
+ export { Mindmap } from "./vis/mindmap";
16
+ export { NetworkGraph } from "./vis/network-graph";
17
+ export { OrganizationChart } from "./vis/organization-chart";
12
18
  export { Pie } from "./vis/pie";
13
19
  export { Radar } from "./vis/radar";
14
20
  export { Sankey } from "./vis/sankey";
@@ -8,9 +8,12 @@
8
8
  * - `data` - Starts a data array section
9
9
  * - ` - key value` - Array item with key-value pairs
10
10
  * - ` - value` - Simple array item (for flat arrays like histogram data)
11
+ * - ` - "value with spaces"` - Quoted string item; single or double quotes both supported.
12
+ * Quotes are required when the value contains spaces; optional otherwise.
13
+ * Quoted values are never coerced to numbers or booleans.
11
14
  * - `key: value` or `key value` - Top-level key-value pair
12
15
  * - `style` - Starts a style object section
13
- * - Multiple values separated by spaces become arrays (e.g., `palette #ff5a5f #1fb6ff`)
16
+ * - `palette` inside `style` uses array syntax with dash-prefixed items
14
17
  * - `children` - Nested array for hierarchical data (mind-map, treemap, etc.)
15
18
  *
16
19
  * @example
@@ -24,7 +27,10 @@
24
27
  * innerRadius: 0.6
25
28
  * style
26
29
  * backgroundColor #333
27
- * palette #ff5a5f #1fb6ff #13ce66
30
+ * palette
31
+ * - #ff5a5f
32
+ * - #1fb6ff
33
+ * - #13ce66
28
34
  * ```
29
35
  *
30
36
  * @example Simple array (histogram)
@@ -37,6 +43,15 @@
37
43
  * binNumber 5
38
44
  * ```
39
45
  *
46
+ * @example Quoted string values (values containing spaces)
47
+ * ```
48
+ * vis dual-axes
49
+ * categories
50
+ * - "North America"
51
+ * - '东南 亚'
52
+ * - 欧洲
53
+ * ```
54
+ *
40
55
  * @example Hierarchical data (mind-map)
41
56
  * ```
42
57
  * vis mind-map
@@ -1,3 +1,6 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1
4
  /**
2
5
  * GPT-Vis Syntax Parser
3
6
  *
@@ -8,9 +11,12 @@
8
11
  * - `data` - Starts a data array section
9
12
  * - ` - key value` - Array item with key-value pairs
10
13
  * - ` - value` - Simple array item (for flat arrays like histogram data)
14
+ * - ` - "value with spaces"` - Quoted string item; single or double quotes both supported.
15
+ * Quotes are required when the value contains spaces; optional otherwise.
16
+ * Quoted values are never coerced to numbers or booleans.
11
17
  * - `key: value` or `key value` - Top-level key-value pair
12
18
  * - `style` - Starts a style object section
13
- * - Multiple values separated by spaces become arrays (e.g., `palette #ff5a5f #1fb6ff`)
19
+ * - `palette` inside `style` uses array syntax with dash-prefixed items
14
20
  * - `children` - Nested array for hierarchical data (mind-map, treemap, etc.)
15
21
  *
16
22
  * @example
@@ -24,7 +30,10 @@
24
30
  * innerRadius: 0.6
25
31
  * style
26
32
  * backgroundColor #333
27
- * palette #ff5a5f #1fb6ff #13ce66
33
+ * palette
34
+ * - #ff5a5f
35
+ * - #1fb6ff
36
+ * - #13ce66
28
37
  * ```
29
38
  *
30
39
  * @example Simple array (histogram)
@@ -37,6 +46,15 @@
37
46
  * binNumber 5
38
47
  * ```
39
48
  *
49
+ * @example Quoted string values (values containing spaces)
50
+ * ```
51
+ * vis dual-axes
52
+ * categories
53
+ * - "North America"
54
+ * - '东南 亚'
55
+ * - 欧洲
56
+ * ```
57
+ *
40
58
  * @example Hierarchical data (mind-map)
41
59
  * ```
42
60
  * vis mind-map
@@ -56,7 +74,7 @@
56
74
  */
57
75
 
58
76
  // Known section names that contain arrays
59
- var ARRAY_SECTIONS = new Set(['data', 'categories', 'series', 'children']);
77
+ var ARRAY_SECTIONS = new Set(['data', 'categories', 'series', 'children', 'nodes', 'edges']);
60
78
 
61
79
  // Known section names that contain objects
62
80
  var OBJECT_SECTIONS = new Set(['style']);
@@ -64,6 +82,12 @@ var OBJECT_SECTIONS = new Set(['style']);
64
82
  /**
65
83
  * Try to parse a value as number, boolean, or keep as string
66
84
  */
85
+ function isQuotedString(s) {
86
+ if (s.length < 2) return false;
87
+ var quote = s[0];
88
+ if (quote !== '"' && quote !== "'") return false;
89
+ return s.endsWith(quote) && s.indexOf(quote, 1) === s.length - 1;
90
+ }
67
91
  function parseValue(value) {
68
92
  // Trim the value
69
93
  var trimmed = value.trim();
@@ -73,6 +97,11 @@ function parseValue(value) {
73
97
  return '';
74
98
  }
75
99
 
100
+ // Quoted string — strip quotes and return as-is, skipping numeric/boolean coercion
101
+ if (isQuotedString(trimmed)) {
102
+ return trimmed.slice(1, -1);
103
+ }
104
+
76
105
  // Boolean values
77
106
  if (trimmed === 'true') return true;
78
107
  if (trimmed === 'false') return false;
@@ -86,60 +115,31 @@ function parseValue(value) {
86
115
  }
87
116
 
88
117
  /**
89
- * Parse multiple space-separated values into an array or single value
90
- * Used for style properties like palette where multiple colors are expected
118
+ * Parse a key-value line (supports "key: value", "key=value" and "key value" formats)
119
+ * Supports Unicode characters (Chinese, Japanese, Korean, etc.) in key names
120
+ * Also supports special characters like parentheses, percent signs in key names
91
121
  */
92
- function parseMultipleValues(values) {
93
- var trimmed = values.trim();
94
-
95
- // Split by spaces, but handle the case where we want a single value
96
- var parts = trimmed.split(/\s+/).filter(function (p) {
97
- return p.length > 0;
98
- });
99
- if (parts.length === 0) {
100
- return '';
101
- }
102
- if (parts.length === 1) {
103
- return parseValue(parts[0]);
104
- }
105
-
106
- // Multiple values become an array
107
- return parts.map(parseValue);
108
- }
109
-
110
- /**
111
- * Parse a key-value line (supports both "key: value" and "key value" formats)
112
- */
113
- function parseKeyValue(line) {
114
- var trimmed = line.trim();
115
-
116
- // Try "key: value" format first
117
- var colonMatch = trimmed.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s*:\s*(.*)$/);
118
- if (colonMatch) {
122
+ function parseKeyValue(raw) {
123
+ var text = raw.trim();
124
+ if (!text) return null;
125
+ var match = text.match(/^([^:\s=]+)\s*[:=]\s*(.*)$/);
126
+ if (match) {
119
127
  return {
120
- key: colonMatch[1],
121
- value: colonMatch[2]
128
+ key: match[1],
129
+ value: match[2]
122
130
  };
123
131
  }
124
-
125
- // Try "key value" format (key must be a valid identifier)
126
- var spaceMatch = trimmed.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s+(.+)$/);
127
- if (spaceMatch) {
132
+ var matchSpace = text.match(/^([^\s]+)\s+(.*)$/);
133
+ if (matchSpace) {
128
134
  return {
129
- key: spaceMatch[1],
130
- value: spaceMatch[2]
135
+ key: matchSpace[1],
136
+ value: matchSpace[2]
131
137
  };
132
138
  }
133
-
134
- // Single key without value
135
- var singleKey = trimmed.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)$/);
136
- if (singleKey) {
137
- return {
138
- key: singleKey[1],
139
- value: ''
140
- };
141
- }
142
- return null;
139
+ return {
140
+ key: text,
141
+ value: ''
142
+ };
143
143
  }
144
144
 
145
145
  /**
@@ -149,6 +149,11 @@ function parseKeyValue(line) {
149
149
  function isSimpleValue(line) {
150
150
  var trimmed = line.trim();
151
151
 
152
+ // Quoted string is always a simple value, regardless of content
153
+ if (isQuotedString(trimmed)) {
154
+ return true;
155
+ }
156
+
152
157
  // Check if it looks like a key-value pair
153
158
  var hasKeyValue = parseKeyValue(trimmed);
154
159
  if (hasKeyValue && hasKeyValue.value !== '') {
@@ -159,12 +164,30 @@ function isSimpleValue(line) {
159
164
  return true;
160
165
  }
161
166
 
167
+ /** Visual width of one tab for indent comparison (matches common 2-space nesting). */
168
+ var TAB_INDENT_WIDTH = 2;
169
+
162
170
  /**
163
- * Get the indentation level of a line (normalized to units of 2 spaces)
171
+ * Get the indentation level of a line (leading spaces + tabs; each tab counts as TAB_INDENT_WIDTH).
172
+ * This avoids treating a tab as "1 column" which breaks sibling vs child detection when users mix tabs and spaces.
164
173
  */
165
174
  function getIndentLevel(line) {
166
- var match = line.match(/^(\s*)/);
167
- return match ? match[1].length : 0;
175
+ var match = line.match(/^([\t ]*)/);
176
+ if (!match) return 0;
177
+ var w = 0;
178
+ var _iterator = _createForOfIteratorHelper(match[1]),
179
+ _step;
180
+ try {
181
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
182
+ var ch = _step.value;
183
+ w += ch === '\t' ? TAB_INDENT_WIDTH : 1;
184
+ }
185
+ } catch (err) {
186
+ _iterator.e(err);
187
+ } finally {
188
+ _iterator.f();
189
+ }
190
+ return w;
168
191
  }
169
192
 
170
193
  /**
@@ -216,6 +239,39 @@ function parseLines(syntax) {
216
239
  return result;
217
240
  }
218
241
 
242
+ /**
243
+ * Parse a single tree node object (for indented-tree / organization-chart root data).
244
+ * Handles key-value pairs and a nested `children` array.
245
+ */
246
+ function parseTreeNode(lines, startIndex, baseIndent) {
247
+ var node = {};
248
+ var i = startIndex;
249
+ while (i < lines.length) {
250
+ var _lines$i = lines[i],
251
+ trimmed = _lines$i.trimmed,
252
+ indent = _lines$i.indent;
253
+ if (indent <= baseIndent) break;
254
+ var kv = parseKeyValue(trimmed);
255
+ if (kv) {
256
+ if (kv.key === 'children' && kv.value === '') {
257
+ var _parseArraySection = parseArraySection(lines, i + 1, indent),
258
+ childItems = _parseArraySection.items,
259
+ nextIndex = _parseArraySection.nextIndex;
260
+ node.children = childItems;
261
+ i = nextIndex;
262
+ continue;
263
+ } else {
264
+ node[kv.key] = parseValue(kv.value);
265
+ }
266
+ }
267
+ i++;
268
+ }
269
+ return {
270
+ node: node,
271
+ nextIndex: i
272
+ };
273
+ }
274
+
219
275
  /**
220
276
  * Parse an array of items (data, children, etc.)
221
277
  * Supports nested children arrays for hierarchical data
@@ -227,9 +283,9 @@ function parseArraySection(lines, startIndex, baseIndent) {
227
283
  var i = startIndex;
228
284
  var firstItemIndent = -1;
229
285
  while (i < lines.length) {
230
- var _lines$i = lines[i],
231
- trimmed = _lines$i.trimmed,
232
- indent = _lines$i.indent;
286
+ var _lines$i2 = lines[i],
287
+ trimmed = _lines$i2.trimmed,
288
+ indent = _lines$i2.indent;
233
289
 
234
290
  // If we see something at base indent level or lower and it's not an array item,
235
291
  // we're done with this section
@@ -237,9 +293,10 @@ function parseArraySection(lines, startIndex, baseIndent) {
237
293
  break;
238
294
  }
239
295
 
240
- // If we see an array item at a lower or equal indent to base,
241
- // we've reached a sibling at the parent level - return
242
- if (isArrayItemLine(trimmed) && indent <= baseIndent) {
296
+ // If we see an array item strictly shallower than this `children` block, the list ends here
297
+ // (e.g. parent's next `- name` sibling). Use `<` not `<=`: when the first `-` bullet shares the
298
+ // same indent as the `children` keyword (common LLM/formatting), `<=` would break before any item.
299
+ if (isArrayItemLine(trimmed) && indent < baseIndent) {
243
300
  break;
244
301
  }
245
302
 
@@ -281,30 +338,64 @@ function parseArraySection(lines, startIndex, baseIndent) {
281
338
  continue;
282
339
  }
283
340
 
284
- // If we have a first item indent set and we see an array item at a different indent,
285
- // it might be a nested child's item - just skip for now, let nested parsing handle it
341
+ // Array item at a different indent than the first bullet in this section
286
342
  if (isArrayItemLine(trimmed) && firstItemIndent !== -1 && indent !== firstItemIndent) {
287
- // This shouldn't happen if we're parsing correctly - skip and continue
343
+ // Shallower bullet (still inside this section): new sibling — recover from mixed indent
344
+ if (indent < firstItemIndent && indent > baseIndent && currentItem !== null && !isSimpleArray) {
345
+ items.push(currentItem);
346
+ var _itemContent = parseArrayItemLine(trimmed);
347
+ currentItem = {};
348
+ var _kv = parseKeyValue(_itemContent);
349
+ if (_kv) {
350
+ currentItem[_kv.key] = parseValue(_kv.value);
351
+ }
352
+ firstItemIndent = indent;
353
+ i++;
354
+ continue;
355
+ }
356
+ // Deeper bullet: treat as the next sibling (recover off-by-N indent). The old "implicit nested"
357
+ // branch merged these into currentItem.children and collapsed lists to a single branch — wrong
358
+ // for normal `children` blocks where bullets are only slightly deeper than the first.
359
+ if (indent > firstItemIndent && currentItem !== null && !isSimpleArray) {
360
+ items.push(currentItem);
361
+ var _itemContent2 = parseArrayItemLine(trimmed);
362
+ currentItem = {};
363
+ var _kv2 = parseKeyValue(_itemContent2);
364
+ if (_kv2) {
365
+ currentItem[_kv2.key] = parseValue(_kv2.value);
366
+ }
367
+ firstItemIndent = indent;
368
+ i++;
369
+ continue;
370
+ }
288
371
  i++;
289
372
  continue;
290
373
  }
291
374
 
292
375
  // Handle properties of current item (including nested children)
293
376
  if (currentItem !== null && !isSimpleArray) {
294
- var _kv = parseKeyValue(trimmed);
295
- if (_kv) {
377
+ var _kv3 = parseKeyValue(trimmed);
378
+ if (_kv3) {
296
379
  // Check if this is a 'children' key (start of nested array)
297
- if (_kv.key === 'children' && _kv.value === '') {
380
+ if (_kv3.key === 'children' && _kv3.value === '') {
298
381
  // Parse nested children array - the children start after this line
299
- var _parseArraySection = parseArraySection(lines, i + 1, indent),
300
- childItems = _parseArraySection.items,
301
- nextIndex = _parseArraySection.nextIndex;
382
+ var _parseArraySection2 = parseArraySection(lines, i + 1, indent),
383
+ childItems = _parseArraySection2.items,
384
+ nextIndex = _parseArraySection2.nextIndex;
302
385
  currentItem.children = childItems;
303
386
  i = nextIndex;
304
387
  continue;
305
- } else {
306
- currentItem[_kv.key] = parseValue(_kv.value);
307
388
  }
389
+ // Same as children: dual-axes `series` items use `data` followed by `- n` lines (see site examples).
390
+ if (_kv3.key === 'data' && _kv3.value === '') {
391
+ var _parseArraySection3 = parseArraySection(lines, i + 1, indent),
392
+ nestedData = _parseArraySection3.items,
393
+ _nextIndex = _parseArraySection3.nextIndex;
394
+ currentItem.data = nestedData;
395
+ i = _nextIndex;
396
+ continue;
397
+ }
398
+ currentItem[_kv3.key] = parseValue(_kv3.value);
308
399
  }
309
400
  }
310
401
  i++;
@@ -330,9 +421,9 @@ export function parse(syntax) {
330
421
  };
331
422
  var i = 0;
332
423
  while (i < lines.length) {
333
- var _lines$i2 = lines[i],
334
- trimmed = _lines$i2.trimmed,
335
- indent = _lines$i2.indent;
424
+ var _lines$i3 = lines[i],
425
+ trimmed = _lines$i3.trimmed,
426
+ indent = _lines$i3.indent;
336
427
 
337
428
  // Handle "vis [type]" declaration
338
429
  if (trimmed.startsWith('vis ')) {
@@ -346,32 +437,99 @@ export function parse(syntax) {
346
437
  var isSectionHeader = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(trimmed) && indent === 0 && isKnownSection(trimmed);
347
438
  if (isSectionHeader) {
348
439
  if (ARRAY_SECTIONS.has(trimmed)) {
349
- // Parse array section
350
- var _parseArraySection2 = parseArraySection(lines, i + 1, indent),
351
- items = _parseArraySection2.items,
352
- nextIndex = _parseArraySection2.nextIndex;
440
+ // Check if the next non-empty indented line is a sub-section header (e.g. nodes/edges inside data)
441
+ var sectionName = trimmed;
442
+ var nextIndex = i + 1;
443
+ var hasSubSections = false;
444
+ if (nextIndex < lines.length && lines[nextIndex].indent > indent) {
445
+ var nextTrimmed = lines[nextIndex].trimmed;
446
+ hasSubSections = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(nextTrimmed) && !isArrayItemLine(nextTrimmed);
447
+ }
448
+ if (hasSubSections) {
449
+ // Parse as an object with named sub-arrays (e.g. data: { nodes: [], edges: [] })
450
+ var dataObj = {};
451
+ i++;
452
+ while (i < lines.length && lines[i].indent > indent) {
453
+ var subTrimmed = lines[i].trimmed;
454
+ var subIndent = lines[i].indent;
455
+ if (/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(subTrimmed) && !isArrayItemLine(subTrimmed)) {
456
+ var _parseArraySection4 = parseArraySection(lines, i + 1, subIndent),
457
+ subItems = _parseArraySection4.items,
458
+ subNext = _parseArraySection4.nextIndex;
459
+ dataObj[subTrimmed] = subItems;
460
+ i = subNext;
461
+ } else {
462
+ i++;
463
+ }
464
+ }
465
+ result[sectionName] = dataObj;
466
+ continue;
467
+ }
468
+
469
+ // Detect tree root object: first content is a key-value pair (not array item, not single-word section)
470
+ var isTreeRoot = false;
471
+ if (nextIndex < lines.length && lines[nextIndex].indent > indent) {
472
+ var firstTrimmed = lines[nextIndex].trimmed;
473
+ if (!isArrayItemLine(firstTrimmed) && !hasSubSections) {
474
+ isTreeRoot = true;
475
+ }
476
+ }
477
+ if (isTreeRoot) {
478
+ // Parse as a single tree root object (indented-tree / organization-chart data)
479
+ var _parseTreeNode = parseTreeNode(lines, i + 1, indent),
480
+ node = _parseTreeNode.node,
481
+ treeNext = _parseTreeNode.nextIndex;
482
+ result[sectionName] = node;
483
+ i = treeNext;
484
+ continue;
485
+ }
486
+
487
+ // Parse array section (standard behavior)
488
+ var _parseArraySection5 = parseArraySection(lines, i + 1, indent),
489
+ items = _parseArraySection5.items,
490
+ arrNext = _parseArraySection5.nextIndex;
353
491
  if (items.length > 0) {
354
- result[trimmed] = items;
492
+ result[sectionName] = items;
355
493
  }
356
- i = nextIndex;
494
+ i = arrNext;
357
495
  continue;
358
496
  } else if (OBJECT_SECTIONS.has(trimmed)) {
359
497
  // Parse object section (style)
360
- var sectionName = trimmed;
361
- result[sectionName] = {};
498
+ var _sectionName = trimmed;
499
+ var sectionObj = {};
500
+ result[_sectionName] = sectionObj;
501
+ var sectionIndent = indent;
362
502
  i++;
363
503
  while (i < lines.length) {
364
- var _lines$i3 = lines[i],
365
- innerTrimmed = _lines$i3.trimmed,
366
- innerIndent = _lines$i3.indent;
504
+ var _lines$i4 = lines[i],
505
+ innerTrimmed = _lines$i4.trimmed,
506
+ innerIndent = _lines$i4.indent;
367
507
 
368
- // If indent goes back to 0, we're done with this section
369
- if (innerIndent === 0) {
508
+ // If indent goes back to section level or lower, we're done with this section
509
+ if (innerIndent <= sectionIndent) {
370
510
  break;
371
511
  }
512
+
513
+ // Check for array item lines (palette sub-array items)
514
+ if (isArrayItemLine(innerTrimmed)) {
515
+ i++;
516
+ continue;
517
+ }
372
518
  var kv = parseKeyValue(innerTrimmed);
373
519
  if (kv) {
374
- result[sectionName][kv.key] = parseMultipleValues(kv.value);
520
+ // Check if this key is followed by dash-prefixed array items (e.g., palette)
521
+ if (kv.value === '' && i + 1 < lines.length) {
522
+ var nextLine = lines[i + 1];
523
+ if (nextLine.indent > innerIndent && isArrayItemLine(nextLine.trimmed)) {
524
+ var _parseArraySection6 = parseArraySection(lines, i + 1, innerIndent),
525
+ _items = _parseArraySection6.items,
526
+ _nextIndex2 = _parseArraySection6.nextIndex;
527
+ sectionObj[kv.key] = _items;
528
+ i = _nextIndex2;
529
+ continue;
530
+ }
531
+ }
532
+ sectionObj[kv.key] = parseValue(kv.value);
375
533
  }
376
534
  i++;
377
535
  }
@@ -381,9 +539,9 @@ export function parse(syntax) {
381
539
 
382
540
  // Top-level key-value pair
383
541
  if (indent === 0) {
384
- var _kv2 = parseKeyValue(trimmed);
385
- if (_kv2) {
386
- result[_kv2.key] = parseValue(_kv2.value);
542
+ var _kv4 = parseKeyValue(trimmed);
543
+ if (_kv4) {
544
+ result[_kv4.key] = parseValue(_kv4.value);
387
545
  }
388
546
  }
389
547
  i++;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Resolve a container parameter to an HTMLElement.
3
+ * Supports CSS selectors (e.g., '#container', '.my-chart') and direct HTMLElement references.
4
+ */
5
+ export declare function resolveContainer(container: string | HTMLElement): HTMLElement;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Resolve a container parameter to an HTMLElement.
3
+ * Supports CSS selectors (e.g., '#container', '.my-chart') and direct HTMLElement references.
4
+ */
5
+ export function resolveContainer(container) {
6
+ if (typeof container === 'string') {
7
+ if (typeof document === 'undefined') {
8
+ // In a non-browser (SSR) environment, a string container cannot be resolved to a real HTMLElement.
9
+ // Throwing an error here prevents a ReferenceError from document.querySelector
10
+ // and clearly indicates that DOM resolution is not possible in this environment.
11
+ throw new Error("Container element \"".concat(container, "\" cannot be resolved in a non-browser environment."));
12
+ }
13
+ var el = document.querySelector(container);
14
+ if (!el) {
15
+ throw new Error("Container element \"".concat(container, "\" not found"));
16
+ }
17
+ return el;
18
+ }
19
+ return container;
20
+ }
@@ -19,3 +19,8 @@ export declare const getThemeColors: (theme: string) => string[];
19
19
  * Get background color based on theme.
20
20
  */
21
21
  export declare const getBackgroundColor: (theme: string) => string;
22
+ /**
23
+ * Normalize palette to always return an array.
24
+ * Handles the case where a single color is parsed as a string instead of an array.
25
+ */
26
+ export declare const normalizePalette: (palette: string | string[] | undefined, theme: string) => string[];
@@ -138,4 +138,13 @@ export var getBackgroundColor = function getBackgroundColor(theme) {
138
138
  default:
139
139
  return '#FFF';
140
140
  }
141
+ };
142
+
143
+ /**
144
+ * Normalize palette to always return an array.
145
+ * Handles the case where a single color is parsed as a string instead of an array.
146
+ */
147
+ export var normalizePalette = function normalizePalette(palette, theme) {
148
+ if (!palette || Array.isArray(palette) && palette.length === 0) return getThemeColors(theme);
149
+ return Array.isArray(palette) ? palette : [palette];
141
150
  };
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
8
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
9
9
 
10
10
  /**
11
11
  * AreaDataItem is the type for each data item in the area chart.
@@ -82,7 +82,7 @@ export var Area = function Area(options) {
82
82
  var _style$lineWidth = style.lineWidth,
83
83
  lineWidth = _style$lineWidth === void 0 ? 2 : _style$lineWidth;
84
84
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
85
- var colors = style.palette || getThemeColors(theme);
85
+ var colors = normalizePalette(style.palette, theme);
86
86
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
87
87
  var fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR);
88
88
 
@@ -177,6 +177,7 @@ export var Area = function Area(options) {
177
177
  // Note: Using 'any' type due to G2's complex type system with transformations
178
178
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
179
179
  var chartOptions = {
180
+ animate: false,
180
181
  type: 'view',
181
182
  data: data,
182
183
  title: title !== null && title !== void 0 ? title : '',