@kanaries/graphic-walker 0.4.5 → 0.4.6
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.
- package/dist/App.d.ts +1 -0
- package/dist/graphic-walker.es.js +7891 -7884
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +115 -115
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/renderer/index.d.ts +1 -0
- package/dist/renderer/pureRenderer.d.ts +1 -0
- package/dist/renderer/specRenderer.d.ts +1 -0
- package/dist/utils/useTheme.d.ts +6 -0
- package/package.json +1 -1
- package/src/App.tsx +3 -1
- package/src/hooks/service.ts +2 -2
- package/src/renderer/index.tsx +3 -1
- package/src/renderer/pureRenderer.tsx +1 -1
- package/src/renderer/specRenderer.tsx +8 -2
- package/src/utils/useTheme.ts +8 -0
package/dist/renderer/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IDarkMode, IThemeKey, IComputationFunction } from '../interfaces';
|
|
|
3
3
|
import { IReactVegaHandler } from '../vis/react-vega';
|
|
4
4
|
interface RendererProps {
|
|
5
5
|
themeKey?: IThemeKey;
|
|
6
|
+
themeConfig?: any;
|
|
6
7
|
dark?: IDarkMode;
|
|
7
8
|
computationFunction: IComputationFunction;
|
|
8
9
|
}
|
|
@@ -3,6 +3,7 @@ import type { IDarkMode, IRow, IThemeKey, DraggableFieldState, IVisualConfig, IC
|
|
|
3
3
|
declare const _default: ((props: {
|
|
4
4
|
name?: string | undefined;
|
|
5
5
|
themeKey?: IThemeKey | undefined;
|
|
6
|
+
themeConfig?: any;
|
|
6
7
|
dark?: IDarkMode | undefined;
|
|
7
8
|
visualState: DraggableFieldState;
|
|
8
9
|
visualConfig: IVisualConfig;
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -38,6 +38,7 @@ export interface IGWProps {
|
|
|
38
38
|
fieldKeyGuard?: boolean;
|
|
39
39
|
/** @default "vega" */
|
|
40
40
|
themeKey?: IThemeKey;
|
|
41
|
+
themeConfig?: any;
|
|
41
42
|
dark?: IDarkMode;
|
|
42
43
|
storeRef?: React.MutableRefObject<IGlobalStore | null>;
|
|
43
44
|
computation?: IComputationFunction;
|
|
@@ -67,6 +68,7 @@ const App = observer<IGWProps>(function App(props) {
|
|
|
67
68
|
hideDataSourceConfig,
|
|
68
69
|
fieldKeyGuard = true,
|
|
69
70
|
themeKey = 'vega',
|
|
71
|
+
themeConfig,
|
|
70
72
|
dark = 'media',
|
|
71
73
|
computation,
|
|
72
74
|
toolbar,
|
|
@@ -209,7 +211,7 @@ const App = observer<IGWProps>(function App(props) {
|
|
|
209
211
|
// }}
|
|
210
212
|
>
|
|
211
213
|
{datasets.length > 0 && (
|
|
212
|
-
<ReactiveRenderer ref={rendererRef} themeKey={themeKey} dark={dark} computationFunction={vizStore.computationFunction} />
|
|
214
|
+
<ReactiveRenderer ref={rendererRef} themeKey={themeKey} themeConfig={themeConfig} dark={dark} computationFunction={vizStore.computationFunction} />
|
|
213
215
|
)}
|
|
214
216
|
{/* {vizEmbededMenu.show && (
|
|
215
217
|
<ClickMenu x={vizEmbededMenu.position[0]} y={vizEmbededMenu.position[1]}>
|
package/src/hooks/service.ts
CHANGED
|
@@ -18,9 +18,9 @@ export function useGeoJSON(geojson?: FeatureCollection, url?: IGeoUrl) {
|
|
|
18
18
|
.then((json) => {
|
|
19
19
|
if (timestamp !== lastFetchedRef.current) return;
|
|
20
20
|
if (url.type === 'GeoJSON') {
|
|
21
|
-
|
|
21
|
+
GeoJSONDict[key] = json;
|
|
22
22
|
} else {
|
|
23
|
-
|
|
23
|
+
GeoJSONDict[key] = feature(json, Object.keys(json.objects)[0]) as unknown as FeatureCollection;
|
|
24
24
|
}
|
|
25
25
|
setLastFetched(timestamp);
|
|
26
26
|
});
|
package/src/renderer/index.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import { initVisualConfig } from '../utils/save';
|
|
|
15
15
|
|
|
16
16
|
interface RendererProps {
|
|
17
17
|
themeKey?: IThemeKey;
|
|
18
|
+
themeConfig?: any;
|
|
18
19
|
dark?: IDarkMode;
|
|
19
20
|
computationFunction: IComputationFunction;
|
|
20
21
|
}
|
|
@@ -23,7 +24,7 @@ interface RendererProps {
|
|
|
23
24
|
* Depending on global store.
|
|
24
25
|
*/
|
|
25
26
|
const Renderer = forwardRef<IReactVegaHandler, RendererProps>(function (props, ref) {
|
|
26
|
-
const { themeKey, dark, computationFunction } = props;
|
|
27
|
+
const { themeKey, dark, computationFunction, themeConfig } = props;
|
|
27
28
|
const { vizStore, commonStore } = useGlobalStore();
|
|
28
29
|
const {
|
|
29
30
|
allFields,
|
|
@@ -131,6 +132,7 @@ const Renderer = forwardRef<IReactVegaHandler, RendererProps>(function (props, r
|
|
|
131
132
|
data={viewData}
|
|
132
133
|
ref={ref}
|
|
133
134
|
themeKey={themeKey}
|
|
135
|
+
themeConfig={themeConfig}
|
|
134
136
|
dark={dark}
|
|
135
137
|
locale={i18n.language}
|
|
136
138
|
draggableFieldState={encodings}
|
|
@@ -23,6 +23,7 @@ type IPureRendererProps =
|
|
|
23
23
|
| {
|
|
24
24
|
name?: string;
|
|
25
25
|
themeKey?: IThemeKey;
|
|
26
|
+
themeConfig?: any;
|
|
26
27
|
dark?: IDarkMode;
|
|
27
28
|
visualState: DraggableFieldState;
|
|
28
29
|
visualConfig: IVisualConfig;
|
|
@@ -86,7 +87,6 @@ const PureRenderer = forwardRef<IReactVegaHandler, IPureRendererProps>(function
|
|
|
86
87
|
limit: limit ?? -1,
|
|
87
88
|
computationFunction: computation,
|
|
88
89
|
});
|
|
89
|
-
console.log(computation)
|
|
90
90
|
// Dependencies that should not trigger effect individually
|
|
91
91
|
const latestFromRef = useRef({ data });
|
|
92
92
|
latestFromRef.current = { data };
|
|
@@ -9,6 +9,7 @@ import { DeepReadonly, DraggableFieldState, IDarkMode, IRow, IThemeKey, IVisualC
|
|
|
9
9
|
import LoadingLayer from '../components/loadingLayer';
|
|
10
10
|
import { useCurrentMediaTheme } from '../utils/media';
|
|
11
11
|
import { builtInThemes } from '../vis/theme';
|
|
12
|
+
import { useTheme } from '../utils/useTheme';
|
|
12
13
|
|
|
13
14
|
interface SpecRendererProps {
|
|
14
15
|
name?: string;
|
|
@@ -22,13 +23,14 @@ interface SpecRendererProps {
|
|
|
22
23
|
onChartResize?: ((width: number, height: number) => void) | undefined;
|
|
23
24
|
locale?: string;
|
|
24
25
|
computationFunction: IComputationFunction;
|
|
26
|
+
themeConfig?: any;
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Sans-store renderer of GraphicWalker.
|
|
28
30
|
* This is a pure component, which means it will not depend on any global state.
|
|
29
31
|
*/
|
|
30
32
|
const SpecRenderer = forwardRef<IReactVegaHandler, SpecRendererProps>(function (
|
|
31
|
-
{ name, themeKey, dark, data, loading, draggableFieldState, visualConfig, onGeomClick, onChartResize, locale, computationFunction
|
|
33
|
+
{ name, themeKey, dark, data, loading, draggableFieldState, visualConfig, onGeomClick, onChartResize, locale, computationFunction, themeConfig: customizedThemeConfig },
|
|
32
34
|
ref
|
|
33
35
|
) {
|
|
34
36
|
// const { draggableFieldState, visualConfig } = vizStore;
|
|
@@ -58,7 +60,11 @@ const SpecRenderer = forwardRef<IReactVegaHandler, SpecRendererProps>(function (
|
|
|
58
60
|
|
|
59
61
|
const enableResize = size.mode === 'fixed' && !hasFacet && Boolean(onChartResize);
|
|
60
62
|
const mediaTheme = useCurrentMediaTheme(dark);
|
|
61
|
-
const themeConfig =
|
|
63
|
+
const themeConfig = useTheme({
|
|
64
|
+
themeKey,
|
|
65
|
+
mediaTheme,
|
|
66
|
+
themeConfig: customizedThemeConfig
|
|
67
|
+
})
|
|
62
68
|
|
|
63
69
|
const vegaConfig = useMemo<VegaGlobalConfig>(() => {
|
|
64
70
|
const config: VegaGlobalConfig = {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IThemeKey } from "../interfaces";
|
|
2
|
+
import { builtInThemes } from "../vis/theme";
|
|
3
|
+
|
|
4
|
+
export function useTheme (props: { themeKey?: IThemeKey; themeConfig?: any; mediaTheme: 'dark' | 'light' }) {
|
|
5
|
+
const { themeConfig, themeKey, mediaTheme } = props;
|
|
6
|
+
const config = (themeConfig ?? builtInThemes[themeKey ?? 'vega'])?.[mediaTheme];
|
|
7
|
+
return config
|
|
8
|
+
}
|