-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathnodes.ts
134 lines (130 loc) · 6.53 KB
/
nodes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* eslint-disable import/order */
import { AttrsProps, MiscNodeId } from './constants';
import { VirtualAttributes } from '../components/svgs/nodes/virtual';
import { ShmetroNumLineBadgeAttributes } from '../components/svgs/nodes/shmetro-num-line-badge';
import { ShmetroTextLineBadgeAttributes } from '../components/svgs/nodes/shmetro-text-line-badge';
import { GzmtrLineBadgeAttributes } from '../components/svgs/nodes/gzmtr-line-badge';
import { BjsubwayNumLineBadgeAttributes } from '../components/svgs/nodes/bjsubway-num-line-badge';
import { BjsubwayTextLineBadgeAttributes } from '../components/svgs/nodes/bjsubway-text-line-badge';
import { SuzhouRTNumLineBadgeAttributes } from '../components/svgs/nodes/suzhourt-num-line-badge';
import { BerlinUBahnLineBadgeAttributes } from '../components/svgs/nodes/berlin-u-bahn-line-badge';
import { BerlinSBahnLineBadgeAttributes } from '../components/svgs/nodes/berlin-s-bahn-line-badge';
import { ChongqingRTNumLineBadgeAttributes } from '../components/svgs/nodes/chongqingrt-num-line-badge';
import { ChongqingRTTextLineBadgeAttributes } from '../components/svgs/nodes/chongqingrt-text-line-badge';
import { ShenzhenMetroNumLineBadgeAttributes } from '../components/svgs/nodes/shenzhenmetro-num-line-badge';
import { MRTDestinationNumbersAttributes } from '../components/svgs/nodes/mrt-dest-num';
import { JREastLineBadgeAttributes } from '../components/svgs/nodes/jr-east-line-badge';
import { QingdaoMetroNumLineBadgeAttributes } from '../components/svgs/nodes/qingdao-metro-num-line-badge';
import { MRTLineBadgeAttributes } from '../components/svgs/nodes/mrt-line-badge';
import { GuangdongIntercityRailwayLineBadgeAttributes } from '../components/svgs/nodes/guangdong-intercity-railway-line-badge';
import { LondonArrowAttributes } from '../components/svgs/nodes/london-arrow';
import { FacilitiesAttributes } from '../components/svgs/nodes/facilities';
import { TextAttributes } from '../components/svgs/nodes/text';
import { I18nTextAttributes } from '../components/svgs/nodes/i18n-text';
import { MasterAttributes } from '../components/svgs/nodes/master';
export enum MiscNodeType {
Virtual = 'virtual',
ShmetroNumLineBadge = 'shmetro-num-line-badge',
ShmetroTextLineBadge = 'shmetro-text-line-badge',
GzmtrLineBadge = 'gzmtr-line-badge',
BjsubwayNumLineBadge = 'bjsubway-num-line-badge',
BjsubwayTextLineBadge = 'bjsubway-text-line-badge',
SuzhouRTNumLineBadge = 'suzhourt-num-line-badge',
BerlinSBahnLineBadge = 'berlin-s-bahn-line-badge',
BerlinUBahnLineBadge = 'berlin-u-bahn-line-badge',
ChongqingRTNumLineBadge = 'chongqingrt-num-line-badge',
ChongqingRTTextLineBadge = 'chongqingrt-text-line-badge',
ShenzhenMetroNumLineBadge = 'shenzhen-metro-num-line-badge',
MRTDestinationNumbers = 'mrt-num-line-badge',
JREastLineBadge = 'jr-east-line-badge',
QingdaoMetroNumLineBadge = 'qingdao-metro-num-line-badge',
MRTLineBadge = 'mrt-line-badge',
GuangdongIntercityRailwayLineBadge = 'gd-intercity-rwy-line-badge',
LondonArrow = 'london-arrow',
Facilities = 'facilities',
Text = 'text',
I18nText = 'i18n-text',
Master = 'master',
}
export interface MiscNodeAttributes {
[MiscNodeType.Virtual]?: VirtualAttributes;
[MiscNodeType.ShmetroNumLineBadge]?: ShmetroNumLineBadgeAttributes;
[MiscNodeType.ShmetroTextLineBadge]?: ShmetroTextLineBadgeAttributes;
[MiscNodeType.GzmtrLineBadge]?: GzmtrLineBadgeAttributes;
[MiscNodeType.BjsubwayNumLineBadge]?: BjsubwayNumLineBadgeAttributes;
[MiscNodeType.BjsubwayTextLineBadge]?: BjsubwayTextLineBadgeAttributes;
[MiscNodeType.SuzhouRTNumLineBadge]?: SuzhouRTNumLineBadgeAttributes;
[MiscNodeType.BerlinSBahnLineBadge]?: BerlinSBahnLineBadgeAttributes;
[MiscNodeType.BerlinUBahnLineBadge]?: BerlinUBahnLineBadgeAttributes;
[MiscNodeType.ChongqingRTNumLineBadge]?: ChongqingRTNumLineBadgeAttributes;
[MiscNodeType.ChongqingRTTextLineBadge]?: ChongqingRTTextLineBadgeAttributes;
[MiscNodeType.ShenzhenMetroNumLineBadge]?: ShenzhenMetroNumLineBadgeAttributes;
[MiscNodeType.MRTDestinationNumbers]?: MRTDestinationNumbersAttributes;
[MiscNodeType.JREastLineBadge]?: JREastLineBadgeAttributes;
[MiscNodeType.QingdaoMetroNumLineBadge]?: QingdaoMetroNumLineBadgeAttributes;
[MiscNodeType.MRTLineBadge]?: MRTLineBadgeAttributes;
[MiscNodeType.GuangdongIntercityRailwayLineBadge]?: GuangdongIntercityRailwayLineBadgeAttributes;
[MiscNodeType.LondonArrow]?: LondonArrowAttributes;
[MiscNodeType.Facilities]?: FacilitiesAttributes;
[MiscNodeType.Text]?: TextAttributes;
[MiscNodeType.I18nText]?: I18nTextAttributes;
[MiscNodeType.Master]?: MasterAttributes;
}
/* ----- Below are core types for all miscellaneous nodes, DO NOT TOUCH. ----- */
export interface NodeComponentProps<T> {
id: MiscNodeId;
attrs: T;
x: number;
y: number;
handlePointerDown: (node: MiscNodeId, e: React.PointerEvent<SVGElement>) => void;
handlePointerMove: (node: MiscNodeId, e: React.PointerEvent<SVGElement>) => void;
handlePointerUp: (node: MiscNodeId, e: React.PointerEvent<SVGElement>) => void;
}
export interface Node<T> {
/**
* The core node component.
*/
component: React.FC<NodeComponentProps<T>>;
/**
* This pre component will always be under the main component and other
* elements with the same zIndex.
* This is not mandatory but helpful if some of the elements need to be
* put before other stations/misc-nodes/lines.
* Note it will be above other elements that have a smaller zIndex.
*/
preComponent?: React.FC<NodeComponentProps<T>>;
/**
* This post component will always be above the main component and other
* elements with the same zIndex.
* This is not mandatory but helpful if some of the elements need to be
* put after other stations/misc-nodes/lines.
* Note it will be under other elements that have a bigger zIndex.
*/
postComponent?: React.FC<NodeComponentProps<T>>;
/**
* The icon displayed in the tools panel.
*/
icon: JSX.Element;
/**
* Default attributes for this component.
*/
defaultAttrs: T;
/**
* A React component that allows user to change the attributes.
* Will be displayed in the details panel.
*/
attrsComponent: React.FC<AttrsProps<T>>;
/**
* Metadata for this node.
*/
metadata: {
/**
* The name displayed in the tools panel. In react-i18next index format.
*/
displayName: string;
/**
* Tags of this station.
*/
tags: string[];
};
}