@antv/gpt-vis 1.0.2 → 1.3.0

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 (168) hide show
  1. package/README.md +29 -6
  2. package/README.zh-CN.md +32 -9
  3. package/dist/cjs/index.d.ts +1 -1
  4. package/dist/cjs/theme/g2.d.ts +9 -0
  5. package/dist/cjs/theme/g2.js +605 -0
  6. package/dist/cjs/theme/g6.d.ts +28 -0
  7. package/dist/cjs/theme/g6.js +124 -0
  8. package/dist/cjs/theme/merge.d.ts +2 -0
  9. package/dist/cjs/theme/merge.js +49 -0
  10. package/dist/cjs/theme/resolve.d.ts +7 -0
  11. package/dist/cjs/theme/resolve.js +58 -0
  12. package/dist/cjs/theme/shared.d.ts +7 -0
  13. package/dist/cjs/theme/shared.js +61 -0
  14. package/dist/cjs/theme/summary.d.ts +11 -0
  15. package/dist/cjs/theme/summary.js +61 -0
  16. package/dist/cjs/theme/table.d.ts +13 -0
  17. package/dist/cjs/theme/table.js +121 -0
  18. package/dist/cjs/types/index.d.ts +8 -5
  19. package/dist/cjs/types/theme.d.ts +107 -0
  20. package/dist/cjs/types/theme.js +17 -0
  21. package/dist/cjs/util/animation.js +6 -1
  22. package/dist/cjs/util/components.d.ts +20 -0
  23. package/dist/cjs/util/components.js +40 -0
  24. package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
  25. package/dist/cjs/util/crosshair-axis-labels.js +17 -0
  26. package/dist/cjs/util/index.d.ts +0 -2
  27. package/dist/cjs/util/index.js +1 -5
  28. package/dist/cjs/util/interaction.d.ts +4 -3
  29. package/dist/cjs/util/interaction.js +14 -1
  30. package/dist/cjs/util/tokens.d.ts +4 -3
  31. package/dist/cjs/util/tokens.js +9 -6
  32. package/dist/cjs/vis/area/index.d.ts +3 -6
  33. package/dist/cjs/vis/area/index.js +43 -30
  34. package/dist/cjs/vis/bar/index.d.ts +5 -5
  35. package/dist/cjs/vis/bar/index.js +34 -20
  36. package/dist/cjs/vis/boxplot/index.d.ts +4 -5
  37. package/dist/cjs/vis/boxplot/index.js +36 -23
  38. package/dist/cjs/vis/column/index.d.ts +5 -5
  39. package/dist/cjs/vis/column/index.js +38 -26
  40. package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
  41. package/dist/cjs/vis/dual-axes/index.js +70 -52
  42. package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
  43. package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
  44. package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
  45. package/dist/cjs/vis/flow-diagram/index.js +21 -22
  46. package/dist/cjs/vis/funnel/index.d.ts +3 -5
  47. package/dist/cjs/vis/funnel/index.js +63 -42
  48. package/dist/cjs/vis/histogram/index.d.ts +4 -6
  49. package/dist/cjs/vis/histogram/index.js +17 -19
  50. package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
  51. package/dist/cjs/vis/indented-tree/index.js +58 -34
  52. package/dist/cjs/vis/line/index.d.ts +3 -6
  53. package/dist/cjs/vis/line/index.js +43 -22
  54. package/dist/cjs/vis/liquid/index.d.ts +4 -6
  55. package/dist/cjs/vis/liquid/index.js +22 -17
  56. package/dist/cjs/vis/mindmap/index.d.ts +4 -6
  57. package/dist/cjs/vis/mindmap/index.js +43 -25
  58. package/dist/cjs/vis/network-graph/index.d.ts +4 -6
  59. package/dist/cjs/vis/network-graph/index.js +26 -20
  60. package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
  61. package/dist/cjs/vis/organization-chart/index.js +39 -33
  62. package/dist/cjs/vis/pie/index.d.ts +3 -5
  63. package/dist/cjs/vis/pie/index.js +45 -26
  64. package/dist/cjs/vis/radar/index.d.ts +3 -6
  65. package/dist/cjs/vis/radar/index.js +32 -24
  66. package/dist/cjs/vis/sankey/index.d.ts +4 -6
  67. package/dist/cjs/vis/sankey/index.js +17 -7
  68. package/dist/cjs/vis/scatter/index.d.ts +3 -5
  69. package/dist/cjs/vis/scatter/index.js +32 -19
  70. package/dist/cjs/vis/summary/index.js +5 -6
  71. package/dist/cjs/vis/table/index.d.ts +4 -2
  72. package/dist/cjs/vis/table/index.js +44 -4
  73. package/dist/cjs/vis/treemap/index.d.ts +4 -6
  74. package/dist/cjs/vis/treemap/index.js +11 -7
  75. package/dist/cjs/vis/venn/index.d.ts +4 -6
  76. package/dist/cjs/vis/venn/index.js +18 -16
  77. package/dist/cjs/vis/violin/index.d.ts +4 -5
  78. package/dist/cjs/vis/violin/index.js +35 -27
  79. package/dist/cjs/vis/waterfall/index.d.ts +4 -4
  80. package/dist/cjs/vis/waterfall/index.js +48 -39
  81. package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
  82. package/dist/cjs/vis/word-cloud/index.js +18 -12
  83. package/dist/esm/index.d.ts +1 -1
  84. package/dist/esm/theme/g2.d.ts +9 -0
  85. package/dist/esm/theme/g2.js +504 -0
  86. package/dist/esm/theme/g6.d.ts +28 -0
  87. package/dist/esm/theme/g6.js +84 -0
  88. package/dist/esm/theme/merge.d.ts +2 -0
  89. package/dist/esm/theme/merge.js +36 -0
  90. package/dist/esm/theme/resolve.d.ts +7 -0
  91. package/dist/esm/theme/resolve.js +27 -0
  92. package/dist/esm/theme/shared.d.ts +7 -0
  93. package/dist/esm/theme/shared.js +21 -0
  94. package/dist/esm/theme/summary.d.ts +11 -0
  95. package/dist/esm/theme/summary.js +45 -0
  96. package/dist/esm/theme/table.d.ts +13 -0
  97. package/dist/esm/theme/table.js +112 -0
  98. package/dist/esm/types/index.d.ts +8 -5
  99. package/dist/esm/types/theme.d.ts +107 -0
  100. package/dist/esm/types/theme.js +1 -0
  101. package/dist/esm/util/animation.js +12 -2
  102. package/dist/esm/util/components.d.ts +20 -0
  103. package/dist/esm/util/components.js +57 -1
  104. package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
  105. package/dist/esm/util/crosshair-axis-labels.js +18 -0
  106. package/dist/esm/util/index.d.ts +0 -2
  107. package/dist/esm/util/index.js +1 -3
  108. package/dist/esm/util/interaction.d.ts +4 -3
  109. package/dist/esm/util/interaction.js +18 -1
  110. package/dist/esm/util/tokens.d.ts +4 -3
  111. package/dist/esm/util/tokens.js +9 -6
  112. package/dist/esm/vis/area/index.d.ts +3 -6
  113. package/dist/esm/vis/area/index.js +53 -45
  114. package/dist/esm/vis/bar/index.d.ts +5 -5
  115. package/dist/esm/vis/bar/index.js +38 -27
  116. package/dist/esm/vis/boxplot/index.d.ts +4 -5
  117. package/dist/esm/vis/boxplot/index.js +47 -29
  118. package/dist/esm/vis/column/index.d.ts +5 -5
  119. package/dist/esm/vis/column/index.js +46 -36
  120. package/dist/esm/vis/dual-axes/index.d.ts +3 -4
  121. package/dist/esm/vis/dual-axes/index.js +68 -58
  122. package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
  123. package/dist/esm/vis/fishbone-diagram/index.js +52 -27
  124. package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
  125. package/dist/esm/vis/flow-diagram/index.js +28 -23
  126. package/dist/esm/vis/funnel/index.d.ts +3 -5
  127. package/dist/esm/vis/funnel/index.js +63 -54
  128. package/dist/esm/vis/histogram/index.d.ts +4 -6
  129. package/dist/esm/vis/histogram/index.js +28 -21
  130. package/dist/esm/vis/indented-tree/index.d.ts +4 -6
  131. package/dist/esm/vis/indented-tree/index.js +59 -52
  132. package/dist/esm/vis/line/index.d.ts +3 -6
  133. package/dist/esm/vis/line/index.js +44 -32
  134. package/dist/esm/vis/liquid/index.d.ts +4 -6
  135. package/dist/esm/vis/liquid/index.js +28 -21
  136. package/dist/esm/vis/mindmap/index.d.ts +4 -6
  137. package/dist/esm/vis/mindmap/index.js +32 -28
  138. package/dist/esm/vis/network-graph/index.d.ts +4 -6
  139. package/dist/esm/vis/network-graph/index.js +37 -22
  140. package/dist/esm/vis/organization-chart/index.d.ts +4 -6
  141. package/dist/esm/vis/organization-chart/index.js +47 -36
  142. package/dist/esm/vis/pie/index.d.ts +3 -5
  143. package/dist/esm/vis/pie/index.js +42 -26
  144. package/dist/esm/vis/radar/index.d.ts +3 -6
  145. package/dist/esm/vis/radar/index.js +28 -20
  146. package/dist/esm/vis/sankey/index.d.ts +4 -6
  147. package/dist/esm/vis/sankey/index.js +20 -10
  148. package/dist/esm/vis/scatter/index.d.ts +3 -5
  149. package/dist/esm/vis/scatter/index.js +32 -21
  150. package/dist/esm/vis/summary/index.js +5 -7
  151. package/dist/esm/vis/table/index.d.ts +4 -2
  152. package/dist/esm/vis/table/index.js +41 -4
  153. package/dist/esm/vis/treemap/index.d.ts +4 -6
  154. package/dist/esm/vis/treemap/index.js +16 -11
  155. package/dist/esm/vis/venn/index.d.ts +4 -6
  156. package/dist/esm/vis/venn/index.js +24 -16
  157. package/dist/esm/vis/violin/index.d.ts +4 -5
  158. package/dist/esm/vis/violin/index.js +45 -37
  159. package/dist/esm/vis/waterfall/index.d.ts +4 -4
  160. package/dist/esm/vis/waterfall/index.js +46 -36
  161. package/dist/esm/vis/word-cloud/index.d.ts +3 -5
  162. package/dist/esm/vis/word-cloud/index.js +24 -17
  163. package/dist/umd/index.min.js +1 -1
  164. package/package.json +1 -1
  165. package/dist/cjs/util/theme.d.ts +0 -20
  166. package/dist/cjs/util/theme.js +0 -372
  167. package/dist/esm/util/theme.d.ts +0 -20
  168. package/dist/esm/util/theme.js +0 -326
@@ -2,7 +2,7 @@ export { GPTVis } from './gpt-vis';
2
2
  export type { GPTVisConfig } from './gpt-vis';
3
3
  export { isVisSyntax, parse } from './syntax';
4
4
  export type { ParsedConfig } from './syntax';
5
- export type { VisualizationOptions } from './types';
5
+ export type * from './types';
6
6
  export { Area } from './vis/area';
7
7
  export type { AreaConfig, AreaDataItem } from './vis/area';
8
8
  export { Bar } from './vis/bar';
@@ -0,0 +1,9 @@
1
+ import type { Theme } from '@antv/g2';
2
+ import type { ChartType, ThemeStyle, VisualizationTheme } from '../types';
3
+ /** Resolve appearance once. Data, label content, visibility and layout stay in the chart. */
4
+ export declare function getThemeObject(type: ChartType, theme?: VisualizationTheme, localStyle?: ThemeStyle): {
5
+ theme: Theme & {
6
+ type: 'light' | 'dark' | 'academy';
7
+ };
8
+ mark: Record<keyof NonNullable<ThemeStyle['mark']>, Record<string, any>>;
9
+ };
@@ -0,0 +1,504 @@
1
+ var _excluded = ["axis"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ 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); }
12
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+ 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; }
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
+ 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); }
20
+ import { CHART_FONT_FAMILY, CHART_STYLE_DEFAULTS, getChartVisualTokens } from "../util/tokens";
21
+ import { mergeTheme } from "./merge";
22
+ import { resolveTheme } from "./resolve";
23
+ import { ACADEMY_COLOR_PALETTE, DEFAULT_COLOR_PALETTE, normalizePalette, pickStyle } from "./shared";
24
+ var createTheme = function createTheme(type) {
25
+ var tokens = getChartVisualTokens(type);
26
+ var isDark = type === 'dark';
27
+ var isAcademy = type === 'academy';
28
+ var colors = isAcademy ? ACADEMY_COLOR_PALETTE : DEFAULT_COLOR_PALETTE;
29
+ return {
30
+ type: type,
31
+ color: colors[0],
32
+ category10: colors,
33
+ category20: colors,
34
+ view: {
35
+ viewFill: tokens.background,
36
+ plotFill: 'transparent',
37
+ mainFill: 'transparent',
38
+ contentFill: 'transparent'
39
+ },
40
+ interval: {
41
+ rect: {
42
+ fillOpacity: 0.96
43
+ }
44
+ },
45
+ line: {
46
+ line: {
47
+ lineWidth: CHART_STYLE_DEFAULTS.lineWidth
48
+ }
49
+ },
50
+ area: {
51
+ area: {
52
+ fillOpacity: CHART_STYLE_DEFAULTS.areaOpacity
53
+ }
54
+ },
55
+ point: {
56
+ point: {
57
+ lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
58
+ fillOpacity: 0.82
59
+ },
60
+ hollow: {
61
+ lineWidth: 2,
62
+ strokeOpacity: 1
63
+ }
64
+ },
65
+ axis: _objectSpread({
66
+ labelAutoHide: {
67
+ keepHeader: true,
68
+ keepTail: true
69
+ },
70
+ titleOpacity: 1,
71
+ titleFillOpacity: 1,
72
+ labelOpacity: 1,
73
+ labelFillOpacity: 1,
74
+ line: true,
75
+ lineLineWidth: 1,
76
+ lineStroke: tokens.axisLine,
77
+ lineStrokeOpacity: 1,
78
+ tick: true,
79
+ tickLineWidth: 1,
80
+ tickStroke: tokens.axisTick,
81
+ tickStrokeOpacity: 1
82
+ }, isAcademy ? {
83
+ titleFill: '#000000',
84
+ titleStrokeOpacity: 1,
85
+ titleFontSize: 11,
86
+ titleFontWeight: 'bold',
87
+ titleSpacing: 12,
88
+ labelFill: '#000000',
89
+ labelStrokeOpacity: 1,
90
+ labelFontSize: 10,
91
+ labelFontWeight: 'normal',
92
+ labelSpacing: 4,
93
+ tickLength: 5
94
+ } : {
95
+ titleFill: tokens.textSecondary,
96
+ titleFontFamily: CHART_FONT_FAMILY,
97
+ titleFontSize: 12,
98
+ titleFontWeight: 500,
99
+ titleLineWidth: 0,
100
+ titleSpacing: 16,
101
+ labelFill: tokens.textSecondary,
102
+ labelFontFamily: CHART_FONT_FAMILY,
103
+ labelFontSize: 12,
104
+ labelFontWeight: 400,
105
+ labelLineWidth: 0,
106
+ labelSpacing: 6,
107
+ tickLength: 3,
108
+ tickOpacity: 1
109
+ }),
110
+ axisX: _objectSpread({
111
+ grid: isAcademy,
112
+ labelAutoRotate: {
113
+ optionalAngles: [0, 45, 90],
114
+ recoverWhenFailed: true
115
+ }
116
+ }, isAcademy ? {
117
+ gridStroke: tokens.axisGrid,
118
+ gridStrokeOpacity: 1,
119
+ gridLineWidth: 1,
120
+ gridLineDash: [0, 0]
121
+ } : {}),
122
+ axisY: {
123
+ lineLineWidth: 1,
124
+ grid: true,
125
+ gridStroke: tokens.axisGrid,
126
+ gridStrokeOpacity: 1,
127
+ gridLineWidth: isAcademy ? 1 : 0.75,
128
+ gridLineDash: isAcademy ? [0, 0] : [3, 3],
129
+ gridFilter: function gridFilter(_, index) {
130
+ return index !== 0;
131
+ }
132
+ },
133
+ axisRadar: {
134
+ zIndex: 1,
135
+ titleFill: isAcademy ? tokens.textPrimary : tokens.textSecondary,
136
+ titleFontFamily: CHART_FONT_FAMILY,
137
+ titleFontSize: isAcademy ? 10 : 12,
138
+ titleFontWeight: isAcademy ? 600 : 500,
139
+ titleSpacing: 10,
140
+ labelFill: tokens.textSecondary,
141
+ labelOpacity: 1,
142
+ labelFontFamily: CHART_FONT_FAMILY,
143
+ labelFontSize: isAcademy ? 10 : 11,
144
+ line: true,
145
+ lineStroke: tokens.axisLine,
146
+ lineStrokeOpacity: isAcademy ? 1 : 0.64,
147
+ lineLineWidth: isAcademy ? 1 : 0.75,
148
+ tick: true,
149
+ tickLength: isAcademy ? 4 : 2,
150
+ tickStroke: tokens.axisTick,
151
+ tickStrokeOpacity: isAcademy ? 1 : 0.68,
152
+ tickCount: 4,
153
+ gridStroke: tokens.axisGrid,
154
+ gridStrokeOpacity: isAcademy ? 1 : 0.9,
155
+ gridLineWidth: isAcademy ? 1 : 0.75,
156
+ gridLineDash: [0, 0]
157
+ },
158
+ title: {
159
+ spacing: 6,
160
+ titleFill: tokens.textPrimary,
161
+ titleFontSize: 16,
162
+ titleFontWeight: 600,
163
+ subtitleFill: tokens.textSecondary,
164
+ subtitleFontSize: 12,
165
+ subtitleFontWeight: 400
166
+ },
167
+ legendCategory: {
168
+ backgroundFill: 'transparent',
169
+ padding: [5, 0, 10, 0],
170
+ itemMarkerSize: 10,
171
+ itemMarkerFillOpacity: 0.92,
172
+ itemMarkerStrokeOpacity: 0.92,
173
+ itemLabelFill: tokens.textPrimary,
174
+ itemLabelFillOpacity: 0.78,
175
+ itemLabelFontFamily: CHART_FONT_FAMILY,
176
+ itemLabelFontSize: 12,
177
+ itemLabelFontWeight: 400,
178
+ itemLabelLineHeight: 16,
179
+ itemLabelLetterSpacing: 0.1,
180
+ itemLabelTextBaseline: 'middle',
181
+ itemSpacing: [8, 0, 0],
182
+ itemCursor: 'pointer',
183
+ rowPadding: 8,
184
+ colPadding: 22,
185
+ navButtonFill: tokens.textSecondary,
186
+ navButtonFillOpacity: 0.72,
187
+ navButtonSize: 9,
188
+ navPageNumFill: tokens.textSecondary,
189
+ navPageNumFillOpacity: 0.72,
190
+ navPageNumFontFamily: CHART_FONT_FAMILY,
191
+ navPageNumFontSize: 11,
192
+ navPageNumFontWeight: 400,
193
+ navControllerPadding: 4,
194
+ navControllerSpacing: 14
195
+ },
196
+ tooltip: {
197
+ markerR: 4,
198
+ markerLineWidth: 2,
199
+ markerStroke: tokens.background,
200
+ crosshairsStroke: tokens.textSecondary,
201
+ crosshairsStrokeOpacity: 0.18,
202
+ crosshairsLineWidth: 1,
203
+ crosshairsLineDash: [0, 0],
204
+ css: {
205
+ '.g2-tooltip': {
206
+ 'background-color': tokens.tooltipBackground,
207
+ border: "1px solid ".concat(tokens.tooltipBorder),
208
+ 'border-radius': '10px',
209
+ 'box-shadow': tokens.tooltipShadow,
210
+ color: tokens.textSecondary,
211
+ padding: '10px 12px',
212
+ 'min-width': '164px',
213
+ 'max-width': '300px',
214
+ overflow: 'hidden',
215
+ 'box-sizing': 'border-box',
216
+ 'backdrop-filter': 'blur(10px) saturate(1.08)',
217
+ '-webkit-backdrop-filter': 'blur(10px) saturate(1.08)',
218
+ 'font-family': CHART_FONT_FAMILY,
219
+ 'font-size': '12px',
220
+ 'line-height': '18px',
221
+ 'font-variant-numeric': 'tabular-nums',
222
+ 'font-feature-settings': '"tnum" 1, "zero" 1',
223
+ '-webkit-font-smoothing': 'antialiased',
224
+ contain: 'layout paint style'
225
+ },
226
+ '.g2-tooltip-title': {
227
+ color: tokens.textSecondary,
228
+ 'font-size': '11px',
229
+ 'font-weight': '500',
230
+ 'line-height': '16px',
231
+ 'letter-spacing': '0.01em',
232
+ 'margin-bottom': '6px',
233
+ 'padding-bottom': '7px',
234
+ 'border-bottom': "1px solid ".concat(tokens.tooltipDivider),
235
+ 'max-width': '276px'
236
+ },
237
+ '.g2-tooltip-list': {
238
+ display: 'grid',
239
+ gap: '4px'
240
+ },
241
+ '.g2-tooltip-list-item': {
242
+ display: 'grid',
243
+ 'grid-template-columns': 'minmax(0, 1fr) auto',
244
+ 'align-items': 'center',
245
+ 'column-gap': '18px',
246
+ 'min-height': '22px',
247
+ 'line-height': '22px'
248
+ },
249
+ '.g2-tooltip-list-item-name': {
250
+ gap: '8px',
251
+ 'min-width': '0',
252
+ 'max-width': '208px',
253
+ overflow: 'hidden',
254
+ color: tokens.textSecondary
255
+ },
256
+ '.g2-tooltip-list-item-name-label': {
257
+ color: tokens.textSecondary,
258
+ 'font-weight': '400'
259
+ },
260
+ '.g2-tooltip-list-item-value': {
261
+ color: tokens.textPrimary,
262
+ 'font-weight': '600',
263
+ flex: '0 0 auto',
264
+ 'min-width': '40px',
265
+ 'margin-left': '0',
266
+ 'text-align': 'right',
267
+ 'letter-spacing': '-0.01em',
268
+ 'font-variant-numeric': 'tabular-nums',
269
+ 'font-feature-settings': '"tnum" 1, "zero" 1'
270
+ },
271
+ '.g2-tooltip-list-item-marker': {
272
+ width: '7px',
273
+ height: '7px',
274
+ flex: '0 0 auto',
275
+ 'margin-right': '0',
276
+ 'border-radius': '999px',
277
+ 'box-shadow': tokens.tooltipMarkerShadow
278
+ },
279
+ '.g2-tooltip-crosshair-x': {
280
+ 'background-color': isDark ? 'rgba(255, 255, 255, 0.16)' : 'rgba(71, 84, 103, 0.16)'
281
+ },
282
+ '.g2-tooltip-crosshair-y': {
283
+ 'background-color': isDark ? 'rgba(255, 255, 255, 0.16)' : 'rgba(71, 84, 103, 0.16)'
284
+ }
285
+ }
286
+ }
287
+ };
288
+ };
289
+ var TITLE_KEYS = ['align', 'spacing', 'titleFill', 'titleFillOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'subtitleFill', 'subtitleFillOpacity', 'subtitleFontFamily', 'subtitleFontSize', 'subtitleFontWeight'];
290
+ var AXIS_KEYS = ['line', 'lineStroke', 'lineStrokeOpacity', 'lineLineWidth', 'lineLineDash', 'tick', 'tickStroke', 'tickStrokeOpacity', 'tickOpacity', 'tickLineWidth', 'tickLength', 'grid', 'gridStroke', 'gridStrokeOpacity', 'gridLineWidth', 'gridLineDash', 'labelFill', 'labelFillOpacity', 'labelOpacity', 'labelFontFamily', 'labelFontSize', 'labelFontWeight', 'labelSpacing', 'titleFill', 'titleFillOpacity', 'titleOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'titleSpacing'];
291
+ var LEGEND_KEYS = ['titleFill', 'titleFillOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'titleSpacing', 'itemLabelFill', 'itemLabelFillOpacity', 'itemLabelFontFamily', 'itemLabelFontSize', 'itemLabelFontWeight', 'itemLabelLineHeight', 'itemLabelLetterSpacing', 'itemSpacing', 'itemMarkerSize', 'itemMarkerFillOpacity', 'itemMarkerStroke', 'itemMarkerStrokeOpacity', 'itemMarkerLineWidth', 'rowPadding', 'colPadding'];
292
+ var LABEL_KEYS = ['fill', 'fillOpacity', 'stroke', 'strokeOpacity', 'lineWidth', 'opacity', 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'lineHeight'];
293
+ var MARK_PAINT_KEYS = ['fillOpacity', 'strokeOpacity', 'lineWidth', 'lineDash', 'opacity', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY'];
294
+ var MARK_KEYS = {
295
+ line: [].concat(MARK_PAINT_KEYS, ['shape', 'lineCap', 'lineJoin']),
296
+ area: [].concat(MARK_PAINT_KEYS, ['shape']),
297
+ point: [].concat(MARK_PAINT_KEYS, ['shape', 'size', 'stroke']),
298
+ interval: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke', 'radius', 'radiusTopLeft', 'radiusTopRight', 'radiusBottomLeft', 'radiusBottomRight']),
299
+ box: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke']),
300
+ path: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke']),
301
+ density: [].concat(MARK_PAINT_KEYS, ['stroke']),
302
+ link: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke']),
303
+ connector: [].concat(MARK_PAINT_KEYS, ['stroke', 'endMarker', 'endMarkerSize', 'endMarkerFill', 'endMarkerFillOpacity'])
304
+ };
305
+ var COMPOSITE_KEYS = {
306
+ liquid: [].concat(MARK_PAINT_KEYS, ['shape', 'contentFill', 'contentStroke', 'contentStrokeOpacity', 'contentLineWidth', 'contentFontFamily', 'contentFontSize', 'contentFontWeight', 'backgroundFill', 'backgroundFillOpacity', 'backgroundStroke', 'backgroundStrokeOpacity', 'backgroundLineWidth', 'outlineBorder', 'outlineStroke', 'outlineStrokeOpacity']),
307
+ treemap: [].concat(MARK_PAINT_KEYS, ['stroke', 'radius']),
308
+ wordCloud: ['fontFamily', 'opacity', 'fillOpacity', 'strokeOpacity'],
309
+ sankey: ['nodeFillOpacity', 'nodeStroke', 'nodeStrokeOpacity', 'nodeLineWidth', 'linkFillOpacity', 'linkStroke', 'linkStrokeOpacity', 'linkLineWidth', 'labelFill', 'labelFillOpacity', 'labelFontFamily', 'labelFontSize', 'labelFontWeight']
310
+ };
311
+ var expandTokens = function expandTokens(t) {
312
+ return {
313
+ axis: {
314
+ lineStroke: t.colorStroke,
315
+ tickStroke: t.colorStroke,
316
+ gridStroke: t.colorStroke,
317
+ lineLineWidth: t.lineWidth,
318
+ tickLineWidth: t.lineWidth,
319
+ gridLineWidth: t.lineWidth,
320
+ labelFill: t.colorTextSecondary,
321
+ titleFill: t.colorTextSecondary,
322
+ labelFontFamily: t.fontFamily,
323
+ titleFontFamily: t.fontFamily,
324
+ labelFontSize: t.fontSize,
325
+ titleFontSize: t.fontSize,
326
+ labelFontWeight: t.fontWeight,
327
+ titleFontWeight: t.fontWeight,
328
+ labelSpacing: t.spacingSmall,
329
+ titleSpacing: t.spacingMedium
330
+ },
331
+ legend: {
332
+ titleFill: t.colorText,
333
+ itemLabelFill: t.colorText,
334
+ titleFontFamily: t.fontFamily,
335
+ itemLabelFontFamily: t.fontFamily,
336
+ titleFontSize: t.fontSize,
337
+ itemLabelFontSize: t.fontSize,
338
+ titleFontWeight: t.fontWeight,
339
+ itemLabelFontWeight: t.fontWeight,
340
+ itemLabelLineHeight: t.lineHeight,
341
+ titleSpacing: t.spacingSmall,
342
+ itemSpacing: t.spacingSmall,
343
+ rowPadding: t.spacingSmall,
344
+ colPadding: t.spacingMedium
345
+ },
346
+ label: {
347
+ fontFamily: t.fontFamily,
348
+ fontSize: t.fontSize,
349
+ fontWeight: t.fontWeight,
350
+ lineHeight: t.lineHeight
351
+ },
352
+ mark: {
353
+ line: {
354
+ lineWidth: t.lineWidth
355
+ },
356
+ point: {
357
+ lineWidth: t.lineWidth
358
+ },
359
+ interval: {
360
+ lineWidth: t.lineWidth,
361
+ radius: t.radius
362
+ },
363
+ box: {
364
+ lineWidth: t.lineWidth
365
+ },
366
+ connector: {
367
+ lineWidth: t.lineWidth
368
+ },
369
+ path: {
370
+ lineWidth: t.lineWidth
371
+ },
372
+ density: {
373
+ lineWidth: t.lineWidth
374
+ },
375
+ link: {
376
+ lineWidth: t.lineWidth
377
+ },
378
+ treemap: {
379
+ lineWidth: t.lineWidth,
380
+ radius: t.radius
381
+ },
382
+ liquid: {
383
+ contentFill: t.colorText,
384
+ contentFontFamily: t.fontFamily,
385
+ contentFontWeight: t.fontWeight,
386
+ backgroundFill: t.colorSurface,
387
+ backgroundStroke: t.colorStroke,
388
+ outlineStroke: t.colorDefault
389
+ },
390
+ sankey: {
391
+ nodeStroke: t.colorStroke,
392
+ nodeLineWidth: t.lineWidth,
393
+ linkStroke: t.colorStroke,
394
+ linkLineWidth: t.lineWidth,
395
+ labelFill: t.colorText,
396
+ labelFontFamily: t.fontFamily,
397
+ labelFontSize: t.fontSize,
398
+ labelFontWeight: t.fontWeight
399
+ },
400
+ wordCloud: {
401
+ fontFamily: t.fontFamily
402
+ }
403
+ }
404
+ };
405
+ };
406
+
407
+ /** Resolve appearance once. Data, label content, visibility and layout stay in the chart. */
408
+ export function getThemeObject(type, theme, localStyle) {
409
+ var _style$palette, _tokens$colorTextSeco, _tokens$colorText, _tokens$colorTextInve, _tokens$colorTextSeco2, _tokens$lineWidth, _tokens$colorStroke, _tokens$spacingSmall, _tokens$spacingMedium, _tokens$lineWidth2, _tokens$colorStroke2;
410
+ var _resolveTheme = resolveTheme(type, theme, localStyle),
411
+ baseTheme = _resolveTheme.baseTheme,
412
+ tokens = _resolveTheme.tokens,
413
+ styles = _resolveTheme.styles;
414
+ // Existing Line/Area/Radar shorthand is normalized before higher-priority styles merge.
415
+ var layers = styles.map(function (layer) {
416
+ var _layer$mark$line$line, _layer$mark;
417
+ return ['line', 'area', 'radar'].includes(type) && (layer === null || layer === void 0 ? void 0 : layer.lineWidth) !== undefined ? mergeTheme(layer, {
418
+ mark: {
419
+ line: {
420
+ lineWidth: (_layer$mark$line$line = (_layer$mark = layer.mark) === null || _layer$mark === void 0 || (_layer$mark = _layer$mark.line) === null || _layer$mark === void 0 ? void 0 : _layer$mark.lineWidth) !== null && _layer$mark$line$line !== void 0 ? _layer$mark$line$line : layer.lineWidth
421
+ }
422
+ }
423
+ }) : layer;
424
+ });
425
+ var style = mergeTheme.apply(void 0, [expandTokens(tokens)].concat(_toConsumableArray(layers)));
426
+ var values = getChartVisualTokens(baseTheme);
427
+ var colors = normalizePalette((_style$palette = style.palette) !== null && _style$palette !== void 0 && _style$palette.length ? style.palette : type === 'waterfall' ? ['#FF4D4F', '#2EBB59', '#1783FF'] : undefined, baseTheme);
428
+ if (type === 'dual-axes' && style.palette) {
429
+ colors.push.apply(colors, _toConsumableArray(normalizePalette(undefined, baseTheme).filter(function (color) {
430
+ return !colors.includes(color);
431
+ })));
432
+ }
433
+ var backgroundColor = style.backgroundColor || values.background;
434
+ var mark = {};
435
+ for (var _i = 0, _Object$entries = Object.entries(_objectSpread(_objectSpread({}, MARK_KEYS), COMPOSITE_KEYS)); _i < _Object$entries.length; _i++) {
436
+ var _style$mark;
437
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
438
+ name = _Object$entries$_i[0],
439
+ keys = _Object$entries$_i[1];
440
+ var kind = name;
441
+ mark[kind] = pickStyle((_style$mark = style.mark) === null || _style$mark === void 0 ? void 0 : _style$mark[kind], keys);
442
+ }
443
+ var axisStyle = pickStyle(style.axis, AXIS_KEYS);
444
+ var titleStyle = pickStyle(style.title, TITLE_KEYS);
445
+ var legendStyle = pickStyle(style.legend, LEGEND_KEYS);
446
+ var labelStyle = pickStyle(style.label, LABEL_KEYS);
447
+ var _createTheme = createTheme(baseTheme),
448
+ axisDefaults = _createTheme.axis,
449
+ builtInTheme = _objectWithoutProperties(_createTheme, _excluded);
450
+ var rendererTheme = mergeTheme(builtInTheme, {
451
+ color: colors[0],
452
+ category10: colors,
453
+ category20: colors,
454
+ view: {
455
+ viewFill: backgroundColor
456
+ },
457
+ tooltip: {
458
+ markerStroke: backgroundColor,
459
+ crosshairsStroke: (_tokens$colorTextSeco = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco !== void 0 ? _tokens$colorTextSeco : values.textSecondary
460
+ },
461
+ title: titleStyle,
462
+ axis: axisStyle,
463
+ axisX: _objectSpread(_objectSpread(_objectSpread({}, axisDefaults), builtInTheme.axisX), axisStyle),
464
+ axisY: _objectSpread(_objectSpread(_objectSpread({}, axisDefaults), builtInTheme.axisY), axisStyle),
465
+ axisRadar: axisStyle,
466
+ legendCategory: legendStyle,
467
+ label: _objectSpread({
468
+ fill: (_tokens$colorText = tokens.colorText) !== null && _tokens$colorText !== void 0 ? _tokens$colorText : values.textPrimary
469
+ }, labelStyle),
470
+ innerLabel: _objectSpread({
471
+ fill: (_tokens$colorTextInve = tokens.colorTextInverse) !== null && _tokens$colorTextInve !== void 0 ? _tokens$colorTextInve : values.textInverse
472
+ }, labelStyle)
473
+ });
474
+ // Tooltips are existing renderer components; token expansion does not add interactions.
475
+ var css = rendererTheme.tooltip.css;
476
+ css['.g2-tooltip'] = mergeTheme(css['.g2-tooltip'], {
477
+ 'background-color': tokens.colorSurface,
478
+ color: (_tokens$colorTextSeco2 = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco2 !== void 0 ? _tokens$colorTextSeco2 : tokens.colorText,
479
+ border: tokens.colorStroke === undefined && tokens.lineWidth === undefined ? undefined : "".concat((_tokens$lineWidth = tokens.lineWidth) !== null && _tokens$lineWidth !== void 0 ? _tokens$lineWidth : 1, "px solid ").concat((_tokens$colorStroke = tokens.colorStroke) !== null && _tokens$colorStroke !== void 0 ? _tokens$colorStroke : values.tooltipBorder),
480
+ 'border-radius': tokens.radius === undefined ? undefined : "".concat(tokens.radius, "px"),
481
+ 'font-family': tokens.fontFamily,
482
+ 'font-size': tokens.fontSize === undefined ? undefined : "".concat(tokens.fontSize, "px"),
483
+ 'font-weight': tokens.fontWeight === undefined ? undefined : String(tokens.fontWeight),
484
+ 'line-height': tokens.lineHeight === undefined ? undefined : "".concat(tokens.lineHeight, "px"),
485
+ padding: tokens.spacingSmall === undefined && tokens.spacingMedium === undefined ? undefined : "".concat((_tokens$spacingSmall = tokens.spacingSmall) !== null && _tokens$spacingSmall !== void 0 ? _tokens$spacingSmall : 10, "px ").concat((_tokens$spacingMedium = tokens.spacingMedium) !== null && _tokens$spacingMedium !== void 0 ? _tokens$spacingMedium : 12, "px")
486
+ });
487
+ for (var _i2 = 0, _arr = ['.g2-tooltip-title', '.g2-tooltip-list-item-name', '.g2-tooltip-list-item-name-label']; _i2 < _arr.length; _i2++) {
488
+ var _tokens$colorTextSeco3, _tokens$colorTextSeco4;
489
+ var _name = _arr[_i2];
490
+ if (tokens.fontSize !== undefined && _name === '.g2-tooltip-title') css[_name]['font-size'] = "".concat(tokens.fontSize, "px");
491
+ if (tokens.lineHeight !== undefined && _name === '.g2-tooltip-title') css[_name]['line-height'] = "".concat(tokens.lineHeight, "px");
492
+ if ((_tokens$colorTextSeco3 = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco3 !== void 0 ? _tokens$colorTextSeco3 : tokens.colorText) css[_name].color = (_tokens$colorTextSeco4 = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco4 !== void 0 ? _tokens$colorTextSeco4 : tokens.colorText;
493
+ }
494
+ if (tokens.colorText !== undefined) css['.g2-tooltip-list-item-value'].color = tokens.colorText;
495
+ if (tokens.colorStroke !== undefined || tokens.lineWidth !== undefined) css['.g2-tooltip-title']['border-bottom'] = "".concat((_tokens$lineWidth2 = tokens.lineWidth) !== null && _tokens$lineWidth2 !== void 0 ? _tokens$lineWidth2 : 1, "px solid ").concat((_tokens$colorStroke2 = tokens.colorStroke) !== null && _tokens$colorStroke2 !== void 0 ? _tokens$colorStroke2 : values.tooltipDivider);
496
+ if (tokens.lineHeight !== undefined) css['.g2-tooltip-list-item']['line-height'] = "".concat(tokens.lineHeight, "px");
497
+ if (tokens.colorSurface !== undefined) css['.g2-tooltip-list-item-marker']['box-shadow'] = "0 0 0 2px ".concat(tokens.colorSurface);
498
+ return {
499
+ theme: _objectSpread(_objectSpread({}, rendererTheme), {}, {
500
+ type: baseTheme
501
+ }),
502
+ mark: mark
503
+ };
504
+ }
@@ -0,0 +1,28 @@
1
+ import type { ChartType, ThemeStyle, VisualizationTheme } from '../types';
2
+ export declare function getThemeObject(type: ChartType, theme?: VisualizationTheme, localStyle?: ThemeStyle): {
3
+ baseTheme: "light" | "dark" | "academy";
4
+ theme: "light" | "dark";
5
+ colors: string[];
6
+ backgroundColor: string;
7
+ node: {
8
+ type: string | undefined;
9
+ style: {
10
+ [k: string]: any;
11
+ };
12
+ };
13
+ edge: {
14
+ type: string | undefined;
15
+ style: {
16
+ [k: string]: any;
17
+ };
18
+ };
19
+ titleStyle: {
20
+ titleFill: string;
21
+ titleFontFamily: string;
22
+ subtitleFill: string;
23
+ };
24
+ tooltipStyle: {
25
+ [k: string]: any;
26
+ };
27
+ texture: "rough" | "default" | undefined;
28
+ };
@@ -0,0 +1,84 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ 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); }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+ 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; }
13
+ import { getChartVisualTokens } from "../util/tokens";
14
+ import { mergeTheme } from "./merge";
15
+ import { resolveTheme } from "./resolve";
16
+ import { normalizePalette, pickStyle } from "./shared";
17
+ var ELEMENT_KEYS = ['stroke', 'strokeOpacity', 'lineWidth', 'lineDash', 'opacity', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'radius', 'labelFill', 'labelFontFamily', 'labelFontSize', 'labelFontWeight'];
18
+ var TITLE_KEYS = ['align', 'spacing', 'titleFill', 'titleFillOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'subtitleFill', 'subtitleFillOpacity', 'subtitleFontFamily', 'subtitleFontSize', 'subtitleFontWeight'];
19
+ export function getThemeObject(type, theme, localStyle) {
20
+ var _style$node, _style$edge, _t$spacingSmall, _t$spacingMedium;
21
+ var _resolveTheme = resolveTheme(type, theme, localStyle),
22
+ baseTheme = _resolveTheme.baseTheme,
23
+ t = _resolveTheme.tokens,
24
+ styles = _resolveTheme.styles;
25
+ var text = {
26
+ labelFontFamily: t.fontFamily,
27
+ labelFontSize: t.fontSize,
28
+ labelFontWeight: t.fontWeight
29
+ };
30
+ var paint = {
31
+ stroke: t.colorStroke,
32
+ lineWidth: t.lineWidth,
33
+ radius: t.radius
34
+ };
35
+ var style = mergeTheme.apply(void 0, [{
36
+ node: _objectSpread(_objectSpread(_objectSpread({}, paint), text), {}, {
37
+ labelFill: t.colorText
38
+ }),
39
+ edge: _objectSpread(_objectSpread({
40
+ stroke: t.colorStroke,
41
+ lineWidth: t.lineWidth
42
+ }, text), {}, {
43
+ labelFill: t.colorTextSecondary
44
+ })
45
+ }].concat(_toConsumableArray(styles)));
46
+ // Keep branch/category fills and hierarchy contrast unless explicitly overridden.
47
+ var nodeStyle = pickStyle(style.node, [].concat(ELEMENT_KEYS, ['fill', 'fillOpacity']));
48
+ var edgeStyle = pickStyle(style.edge, ELEMENT_KEYS);
49
+ var nodeType = (_style$node = style.node) === null || _style$node === void 0 ? void 0 : _style$node.type;
50
+ var edgeType = (_style$edge = style.edge) === null || _style$edge === void 0 ? void 0 : _style$edge.type;
51
+ var values = getChartVisualTokens(baseTheme);
52
+ return {
53
+ baseTheme: baseTheme,
54
+ theme: baseTheme === 'dark' ? 'dark' : 'light',
55
+ colors: normalizePalette(style.palette, baseTheme),
56
+ backgroundColor: style.backgroundColor || values.background,
57
+ node: {
58
+ type: type === 'network-graph' && ['circle', 'diamond', 'ellipse', 'hexagon', 'rect', 'star', 'triangle'].includes(String(nodeType)) ? String(nodeType) : undefined,
59
+ style: nodeStyle
60
+ },
61
+ edge: {
62
+ type: type === 'network-graph' && ['line', 'polyline', 'quadratic', 'cubic'].includes(String(edgeType)) ? String(edgeType) : undefined,
63
+ style: edgeStyle
64
+ },
65
+ titleStyle: _objectSpread({
66
+ titleFill: baseTheme === 'dark' ? '#e0e6ed' : '#000',
67
+ titleFontFamily: 'sans-serif',
68
+ subtitleFill: values.textSecondary
69
+ }, pickStyle(style.title, TITLE_KEYS)),
70
+ tooltipStyle: pickStyle({
71
+ background: t.colorSurface,
72
+ color: t.colorText,
73
+ borderColor: t.colorStroke,
74
+ borderWidth: t.lineWidth === undefined ? undefined : "".concat(t.lineWidth, "px"),
75
+ borderRadius: t.radius === undefined ? undefined : "".concat(t.radius, "px"),
76
+ fontFamily: t.fontFamily,
77
+ fontSize: t.fontSize === undefined ? undefined : "".concat(t.fontSize, "px"),
78
+ fontWeight: t.fontWeight,
79
+ lineHeight: t.lineHeight === undefined ? undefined : "".concat(t.lineHeight, "px"),
80
+ padding: t.spacingSmall === undefined && t.spacingMedium === undefined ? undefined : "".concat((_t$spacingSmall = t.spacingSmall) !== null && _t$spacingSmall !== void 0 ? _t$spacingSmall : 8, "px ").concat((_t$spacingMedium = t.spacingMedium) !== null && _t$spacingMedium !== void 0 ? _t$spacingMedium : 10, "px")
81
+ }),
82
+ texture: style.texture
83
+ };
84
+ }
@@ -0,0 +1,2 @@
1
+ /** Theme objects merge recursively; arrays replace and undefined keeps the previous value. */
2
+ export declare function mergeTheme(...sources: (Record<string, any> | undefined)[]): Record<string, any>;