@antv/gpt-vis 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RendererAnnotation } from '../../annotation/registry';
|
|
2
|
-
import type { VisualizationOptions } from '../../types';
|
|
2
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* T8 syntax, or an object pairing syntax with text highlight annotations.
|
|
5
5
|
* Supports markdown-like syntax with special annotations for metrics.
|
|
@@ -12,6 +12,8 @@ import type { VisualizationOptions } from '../../types';
|
|
|
12
12
|
export type SummaryConfig = string | {
|
|
13
13
|
type?: 'summary';
|
|
14
14
|
text: string;
|
|
15
|
+
theme?: VisualizationTheme;
|
|
16
|
+
style?: ThemeStyle;
|
|
15
17
|
annotations?: RendererAnnotation<{
|
|
16
18
|
text: string;
|
|
17
19
|
}, 'summary', 'summary'>[];
|
|
@@ -27,8 +27,6 @@ var import_annotation = require("../../annotation");
|
|
|
27
27
|
var import_annotation2 = require("../../theme/annotation");
|
|
28
28
|
var import_summary = require("../../theme/summary");
|
|
29
29
|
var Summary = (options) => {
|
|
30
|
-
const appearance = (0, import_summary.getThemeObject)("summary", options.theme);
|
|
31
|
-
const { theme } = appearance;
|
|
32
30
|
const container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
|
|
33
31
|
if (!container) {
|
|
34
32
|
throw new Error("Container not found");
|
|
@@ -39,8 +37,10 @@ var Summary = (options) => {
|
|
|
39
37
|
let text = null;
|
|
40
38
|
let cleanupAnnotations;
|
|
41
39
|
const render = (config) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
40
|
+
const input = typeof config === "string" ? { text: config } : config;
|
|
41
|
+
const { text: syntax, annotations, theme = options.theme, style: localStyle } = input;
|
|
42
|
+
const appearance = (0, import_summary.getThemeObject)("summary", theme, localStyle);
|
|
43
|
+
let activeTheme = appearance.theme;
|
|
44
44
|
const cleanedSyntax = syntax.replace(/^theme\s+(light|dark)\s*$/im, (_, t) => {
|
|
45
45
|
activeTheme = t;
|
|
46
46
|
return "";
|
|
@@ -63,7 +63,8 @@ var Summary = (options) => {
|
|
|
63
63
|
annotations,
|
|
64
64
|
defaults: (0, import_annotation2.getAnnotationDefaults)(
|
|
65
65
|
"summary",
|
|
66
|
-
activeTheme === theme ?
|
|
66
|
+
activeTheme === appearance.theme ? theme : activeTheme,
|
|
67
|
+
localStyle
|
|
67
68
|
)
|
|
68
69
|
});
|
|
69
70
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RendererAnnotation } from '../../annotation/registry';
|
|
2
|
-
import type { VisualizationOptions } from '../../types';
|
|
2
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* T8 syntax, or an object pairing syntax with text highlight annotations.
|
|
5
5
|
* Supports markdown-like syntax with special annotations for metrics.
|
|
@@ -12,6 +12,8 @@ import type { VisualizationOptions } from '../../types';
|
|
|
12
12
|
export type SummaryConfig = string | {
|
|
13
13
|
type?: 'summary';
|
|
14
14
|
text: string;
|
|
15
|
+
theme?: VisualizationTheme;
|
|
16
|
+
style?: ThemeStyle;
|
|
15
17
|
annotations?: RendererAnnotation<{
|
|
16
18
|
text: string;
|
|
17
19
|
}, 'summary', 'summary'>[];
|
|
@@ -40,8 +40,6 @@ import { getThemeObject } from "../../theme/summary";
|
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
export var Summary = function Summary(options) {
|
|
43
|
-
var appearance = getThemeObject('summary', options.theme);
|
|
44
|
-
var theme = appearance.theme;
|
|
45
43
|
var container = typeof options.container === 'string' ? document.querySelector(options.container) : options.container;
|
|
46
44
|
if (!container) {
|
|
47
45
|
throw new Error('Container not found');
|
|
@@ -60,15 +58,18 @@ export var Summary = function Summary(options) {
|
|
|
60
58
|
*/
|
|
61
59
|
var render = function render(config) {
|
|
62
60
|
var _cleanupAnnotations, _text;
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
var input = typeof config === 'string' ? {
|
|
62
|
+
text: config
|
|
63
|
+
} : config;
|
|
64
|
+
var syntax = input.text,
|
|
65
|
+
annotations = input.annotations,
|
|
66
|
+
_input$theme = input.theme,
|
|
67
|
+
theme = _input$theme === void 0 ? options.theme : _input$theme,
|
|
68
|
+
localStyle = input.style;
|
|
69
|
+
var appearance = getThemeObject('summary', theme, localStyle);
|
|
69
70
|
|
|
70
71
|
// Extract optional `theme <value>` line from syntax
|
|
71
|
-
var activeTheme = theme;
|
|
72
|
+
var activeTheme = appearance.theme;
|
|
72
73
|
var cleanedSyntax = syntax.replace(/^theme\s+(light|dark)\s*$/im, function (_, t) {
|
|
73
74
|
activeTheme = t;
|
|
74
75
|
return '';
|
|
@@ -93,7 +94,7 @@ export var Summary = function Summary(options) {
|
|
|
93
94
|
container: wrapper,
|
|
94
95
|
content: content,
|
|
95
96
|
annotations: annotations,
|
|
96
|
-
defaults: getAnnotationDefaults('summary', activeTheme === theme ?
|
|
97
|
+
defaults: getAnnotationDefaults('summary', activeTheme === appearance.theme ? theme : activeTheme, localStyle)
|
|
97
98
|
});
|
|
98
99
|
};
|
|
99
100
|
|