Skip to content

Commit

Permalink
fix: ssr render err for map
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Dec 1, 2024
1 parent a3f150c commit eb79e54
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .fatherrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
},
platform: 'browser',
targets: {
chrome: 51,
chrome: 80,
},
externals: {
lodash: '_',
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"typings": "dist/esm/index.d.ts",
"jsdelivr": "dist/umd/index.min.js",
"unpkg": "dist/umd/index.min.js",
"browser": {
"./src/export-map.ts": "./src/export-map.browser.ts",
"./dist/esm/export-map.js": "./dist/esm/export-map.browser.js"
},
"files": [
"dist",
"README.md",
Expand Down
5 changes: 5 additions & 0 deletions src/export-map.browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// organize-imports-ignore
export { default as Map, type MapProps } from './Map';
export { default as PinMap, type PinMapProps } from './PinMap';
export { default as HeatMap, type HeatMapProps } from './HeatMap';
export { default as PathMap, type PathMapProps } from './PathMap';
18 changes: 18 additions & 0 deletions src/export-map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Map Components mock for use in environments without `document` / `window`, like ssr pre render
import type { FC } from 'react';

function MockMap() {
return null;
}

import { type HeatMapProps } from './HeatMap';
import { type MapProps } from './Map';
import { type PathMapProps } from './PathMap';
import { type PinMapProps } from './PinMap';

export const Map: FC<MapProps> = MockMap;
export const HeatMap: FC<HeatMapProps> = MockMap;
export const PathMap: FC<PathMapProps> = MockMap;
export const PinMap: FC<PinMapProps> = MockMap;

export type { HeatMapProps, MapProps, PathMapProps, PinMapProps };
16 changes: 10 additions & 6 deletions src/export.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// organize-imports-ignore
import { ChartType } from './types';

/********** plot chart **********/
import { default as Area, type AreaProps } from './Area';
import { default as Bar, type BarProps } from './Bar';
import { default as Column, type ColumnProps } from './Column';
import { default as DualAxes, type DualAxesProps } from './DualAxes';
import { default as HeatMap, type HeatMapProps } from './HeatMap';
import { default as Histogram, type HistogramProps } from './Histogram';
import { default as Line, type LineProps } from './Line';
import { default as Pie, type PieProps } from './Pie';
Expand All @@ -20,12 +20,18 @@ import { default as FlowDiagram, type FlowDiagramProps } from './FlowDiagram';
import { default as MindMap, type MindMapProps } from './MindMap';
import { default as NetworkGraph, type NetworkGraphProps } from './NetworkGraph';
export { default as IndentedTree, type IndentedTreeProps } from './IndentedTree';
export { default as Map, type MapProps } from './Map';
export { default as OrganizationChart, type OrganizationChartProps } from './OrganizationChart';

/********** map chart **********/
import { default as PathMap, type PathMapProps } from './PathMap';
import { default as PinMap, type PinMapProps } from './PinMap';
export { Map, type MapProps } from './export-map';
import {
PinMap,
type PinMapProps,
HeatMap,
type HeatMapProps,
PathMap,
type PathMapProps,
} from './export-map';

/********** NTV **********/
export { VisText, type VisTextProps } from './Text';
Expand Down Expand Up @@ -77,10 +83,8 @@ export const DEFAULT_CHART_COMPONENTS: Record<string, React.FC<any>> = {
[ChartType.Area]: Area,
[ChartType.Scatter]: Scatter,
[ChartType.PinMap]: PinMap,
[ChartType.PathMap]: PathMap,
[ChartType.HeatMap]: HeatMap,
[ChartType.MindMap]: MindMap,
[ChartType.FlowDiagram]: FlowDiagram,
[ChartType.NetworkGraph]: NetworkGraph,
[ChartType.FishboneDiagram]: FishboneDiagram,
};

0 comments on commit eb79e54

Please sign in to comment.