react-native-football-formation 1.0.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.
- package/LICENSE +21 -0
- package/README.md +447 -0
- package/dist/assets/index.d.ts +13 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/index.js +15 -0
- package/dist/components/FormationField.d.ts +5 -0
- package/dist/components/FormationField.d.ts.map +1 -0
- package/dist/components/FormationField.js +147 -0
- package/dist/components/PlayerCard.d.ts +5 -0
- package/dist/components/PlayerCard.d.ts.map +1 -0
- package/dist/components/PlayerCard.js +365 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +10 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/theme/defaultTheme.d.ts +12 -0
- package/dist/theme/defaultTheme.d.ts.map +1 -0
- package/dist/theme/defaultTheme.js +70 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +17 -0
- package/dist/types/component.types.d.ts +48 -0
- package/dist/types/component.types.d.ts.map +1 -0
- package/dist/types/component.types.js +2 -0
- package/dist/types/formation.types.d.ts +59 -0
- package/dist/types/formation.types.d.ts.map +1 -0
- package/dist/types/formation.types.js +5 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/theme.types.d.ts +44 -0
- package/dist/types/theme.types.d.ts.map +1 -0
- package/dist/types/theme.types.js +5 -0
- package/dist/utils/formationCoordinates.d.ts +10 -0
- package/dist/utils/formationCoordinates.d.ts.map +1 -0
- package/dist/utils/formationCoordinates.js +311 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/transformLineup.d.ts +21 -0
- package/dist/utils/transformLineup.d.ts.map +1 -0
- package/dist/utils/transformLineup.js +126 -0
- package/package.json +60 -0
- package/src/assets/images/field.png +0 -0
- package/src/assets/images/football.png +0 -0
- package/src/assets/images/kicker.png +0 -0
- package/src/assets/images/ownGoals.png +0 -0
- package/src/assets/images/playerPlaceholder.png +0 -0
- package/src/assets/images/renewal.png +0 -0
- package/src/assets/index.ts +12 -0
- package/src/components/FormationField.tsx +182 -0
- package/src/components/PlayerCard.tsx +452 -0
- package/src/components/index.ts +2 -0
- package/src/index.ts +20 -0
- package/src/theme/defaultTheme.ts +74 -0
- package/src/theme/index.ts +1 -0
- package/src/types/component.types.ts +72 -0
- package/src/types/formation.types.ts +88 -0
- package/src/types/index.ts +3 -0
- package/src/types/theme.types.ts +48 -0
- package/src/utils/formationCoordinates.ts +335 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/transformLineup.ts +158 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./formation.types"), exports);
|
|
18
|
+
__exportStar(require("./theme.types"), exports);
|
|
19
|
+
__exportStar(require("./component.types"), exports);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme configuration types for the formation component
|
|
3
|
+
*/
|
|
4
|
+
export interface FormationThemeColors {
|
|
5
|
+
primary: string;
|
|
6
|
+
blue: string;
|
|
7
|
+
white: string;
|
|
8
|
+
text: string;
|
|
9
|
+
border: string;
|
|
10
|
+
warning: string;
|
|
11
|
+
success: string;
|
|
12
|
+
error: string;
|
|
13
|
+
newError: string;
|
|
14
|
+
formationBadge: string;
|
|
15
|
+
}
|
|
16
|
+
export interface FormationThemeSpacing {
|
|
17
|
+
playerCardWidth: number;
|
|
18
|
+
playerCardHeight: number;
|
|
19
|
+
playerImageSize: number;
|
|
20
|
+
jerseyNumberSize: number;
|
|
21
|
+
iconSize: number;
|
|
22
|
+
badgeMinWidth: number;
|
|
23
|
+
badgeHeight: number;
|
|
24
|
+
}
|
|
25
|
+
export interface FormationThemeTypography {
|
|
26
|
+
playerNameSize: number;
|
|
27
|
+
formationSize: number;
|
|
28
|
+
jerseyNumberSize: number;
|
|
29
|
+
goalCountSize: number;
|
|
30
|
+
fontFamily?: string;
|
|
31
|
+
fontFamilyBold?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface FormationThemeBorderRadius {
|
|
34
|
+
playerImage: number;
|
|
35
|
+
badge: number;
|
|
36
|
+
card: number;
|
|
37
|
+
}
|
|
38
|
+
export interface FormationTheme {
|
|
39
|
+
colors: FormationThemeColors;
|
|
40
|
+
spacing: FormationThemeSpacing;
|
|
41
|
+
typography: FormationThemeTypography;
|
|
42
|
+
borderRadius: FormationThemeBorderRadius;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=theme.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.types.d.ts","sourceRoot":"","sources":["../../src/types/theme.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,UAAU,EAAE,wBAAwB,CAAC;IACrC,YAAY,EAAE,0BAA0B,CAAC;CAC1C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormationCoordinates, FormationType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Formation coordinates based on formationPlace (1-11)
|
|
4
|
+
* Each formation maps player positions (1-11) to x,y coordinates on the field (0-100 scale)
|
|
5
|
+
*
|
|
6
|
+
* Position 1 is always the goalkeeper
|
|
7
|
+
* Positions 2-11 vary based on the tactical formation
|
|
8
|
+
*/
|
|
9
|
+
export declare const FORMATION_COORDINATES_BY_PLACE: Record<FormationType, FormationCoordinates>;
|
|
10
|
+
//# sourceMappingURL=formationCoordinates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formationCoordinates.d.ts","sourceRoot":"","sources":["../../src/utils/formationCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CACjD,aAAa,EACb,oBAAoB,CAmUrB,CAAC"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FORMATION_COORDINATES_BY_PLACE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Formation coordinates based on formationPlace (1-11)
|
|
6
|
+
* Each formation maps player positions (1-11) to x,y coordinates on the field (0-100 scale)
|
|
7
|
+
*
|
|
8
|
+
* Position 1 is always the goalkeeper
|
|
9
|
+
* Positions 2-11 vary based on the tactical formation
|
|
10
|
+
*/
|
|
11
|
+
exports.FORMATION_COORDINATES_BY_PLACE = {
|
|
12
|
+
'4-4-2': {
|
|
13
|
+
'1': { x: 49, y: 80 }, // GK
|
|
14
|
+
'2': { x: 82, y: 58 }, // RB
|
|
15
|
+
'3': { x: 16, y: 58 }, // LB
|
|
16
|
+
'4': { x: 58, y: 30 }, // LCB
|
|
17
|
+
'5': { x: 62, y: 58 }, // CB
|
|
18
|
+
'6': { x: 36, y: 58 }, // RCB
|
|
19
|
+
'7': { x: 76, y: 30 }, // RCM
|
|
20
|
+
'8': { x: 40, y: 30 }, // LCM
|
|
21
|
+
'9': { x: 38, y: 8 }, // ST
|
|
22
|
+
'10': { x: 60, y: 8 }, // RAM/RW
|
|
23
|
+
'11': { x: 22, y: 30 }, // LAM/LW
|
|
24
|
+
},
|
|
25
|
+
'4-1-2-1-2': {
|
|
26
|
+
'1': { x: 49, y: 80 }, // GK
|
|
27
|
+
'2': { x: 88, y: 61 }, // RB
|
|
28
|
+
'3': { x: 10, y: 61 }, // LB
|
|
29
|
+
'4': { x: 36, y: 61 }, // LCB
|
|
30
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
31
|
+
'6': { x: 49, y: 50 }, // CDM
|
|
32
|
+
'7': { x: 68, y: 35 }, // RCM
|
|
33
|
+
'8': { x: 28, y: 35 }, // LCM
|
|
34
|
+
'9': { x: 36, y: 8 }, // LST
|
|
35
|
+
'10': { x: 62, y: 8 }, // RST
|
|
36
|
+
'11': { x: 49, y: 25 }, // CAM
|
|
37
|
+
},
|
|
38
|
+
'4-3-3': {
|
|
39
|
+
'1': { x: 49, y: 80 }, // GK
|
|
40
|
+
'2': { x: 80, y: 59 }, // RB
|
|
41
|
+
'3': { x: 18, y: 59 }, // LB
|
|
42
|
+
'4': { x: 49, y: 32 }, // LCB
|
|
43
|
+
'5': { x: 60, y: 59 }, // RCB
|
|
44
|
+
'6': { x: 38, y: 59 }, // CDM
|
|
45
|
+
'7': { x: 68, y: 32 }, // RCM
|
|
46
|
+
'8': { x: 28, y: 32 }, // LCM
|
|
47
|
+
'9': { x: 49, y: 8 }, // ST
|
|
48
|
+
'10': { x: 70, y: 8 }, // RW
|
|
49
|
+
'11': { x: 26, y: 8 }, // LW
|
|
50
|
+
},
|
|
51
|
+
'4-5-1': {
|
|
52
|
+
'1': { x: 49, y: 80 }, // GK
|
|
53
|
+
'2': { x: 88, y: 61 }, // RB
|
|
54
|
+
'3': { x: 10, y: 61 }, // LB
|
|
55
|
+
'4': { x: 36, y: 61 }, // LCB
|
|
56
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
57
|
+
'6': { x: 49, y: 35 }, // CM
|
|
58
|
+
'7': { x: 68, y: 35 }, // RCM
|
|
59
|
+
'8': { x: 28, y: 35 }, // LCM
|
|
60
|
+
'9': { x: 49, y: 8 }, // ST
|
|
61
|
+
'10': { x: 88, y: 35 }, // RM
|
|
62
|
+
'11': { x: 10, y: 35 }, // LM
|
|
63
|
+
},
|
|
64
|
+
'4-4-1-1': {
|
|
65
|
+
'1': { x: 49, y: 80 }, // GK
|
|
66
|
+
'2': { x: 82, y: 61 }, // RB
|
|
67
|
+
'3': { x: 15, y: 61 }, // LB
|
|
68
|
+
'4': { x: 60, y: 40 }, // LCB
|
|
69
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
70
|
+
'6': { x: 36, y: 61 }, // RCM
|
|
71
|
+
'7': { x: 80, y: 40 }, // LCM
|
|
72
|
+
'8': { x: 40, y: 40 }, // CM
|
|
73
|
+
'9': { x: 49, y: 8 }, // ST
|
|
74
|
+
'10': { x: 49, y: 25 }, // CAM
|
|
75
|
+
'11': { x: 20, y: 40 }, // RM
|
|
76
|
+
},
|
|
77
|
+
'4-1-4-1': {
|
|
78
|
+
'1': { x: 49, y: 80 }, // GK
|
|
79
|
+
'2': { x: 84, y: 61 }, // RB
|
|
80
|
+
'3': { x: 14, y: 61 }, // LB
|
|
81
|
+
'4': { x: 49, y: 44 }, // LCB
|
|
82
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
83
|
+
'6': { x: 36, y: 61 }, // CDM
|
|
84
|
+
'7': { x: 60, y: 26 }, // RCAM
|
|
85
|
+
'8': { x: 40, y: 26 }, // LCAM
|
|
86
|
+
'9': { x: 49, y: 8 }, // ST
|
|
87
|
+
'10': { x: 77, y: 26 }, // RM
|
|
88
|
+
'11': { x: 20, y: 26 }, // LM
|
|
89
|
+
},
|
|
90
|
+
'4-2-3-1': {
|
|
91
|
+
'1': { x: 49, y: 80 }, // GK
|
|
92
|
+
'2': { x: 88, y: 61 }, // RB
|
|
93
|
+
'3': { x: 10, y: 61 }, // LB
|
|
94
|
+
'4': { x: 28, y: 40 }, // LCB
|
|
95
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
96
|
+
'6': { x: 36, y: 61 }, // RCDM
|
|
97
|
+
'7': { x: 80, y: 24 }, // LCDM
|
|
98
|
+
'8': { x: 68, y: 40 }, // CAM
|
|
99
|
+
'9': { x: 49, y: 6 }, // ST
|
|
100
|
+
'10': { x: 49, y: 24 }, // RW
|
|
101
|
+
'11': { x: 15, y: 24 }, // LW
|
|
102
|
+
},
|
|
103
|
+
'4-3-2-1': {
|
|
104
|
+
'1': { x: 49, y: 80 }, // GK
|
|
105
|
+
'2': { x: 88, y: 61 }, // RB
|
|
106
|
+
'3': { x: 10, y: 61 }, // LB
|
|
107
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
108
|
+
'6': { x: 36, y: 61 }, // CM
|
|
109
|
+
'4': { x: 49, y: 40 }, // LCB
|
|
110
|
+
'7': { x: 28, y: 40 }, // RCM
|
|
111
|
+
'8': { x: 68, y: 40 }, // LCM
|
|
112
|
+
'9': { x: 49, y: 8 }, // ST
|
|
113
|
+
'10': { x: 62, y: 22 }, // RCAM
|
|
114
|
+
'11': { x: 36, y: 22 }, // LCAM
|
|
115
|
+
},
|
|
116
|
+
'5-3-2': {
|
|
117
|
+
'1': { x: 49, y: 80 }, // GK
|
|
118
|
+
'2': { x: 82, y: 59 }, // RB
|
|
119
|
+
'3': { x: 14, y: 59 }, // LB
|
|
120
|
+
'4': { x: 32, y: 59 }, // LCB
|
|
121
|
+
'5': { x: 49, y: 59 }, // CB
|
|
122
|
+
'6': { x: 66, y: 59 }, // RCB
|
|
123
|
+
'7': { x: 68, y: 32 }, // RCM
|
|
124
|
+
'8': { x: 28, y: 32 }, // LCM
|
|
125
|
+
'9': { x: 36, y: 8 }, // LST
|
|
126
|
+
'10': { x: 62, y: 8 }, // RST
|
|
127
|
+
'11': { x: 49, y: 32 }, // CM
|
|
128
|
+
},
|
|
129
|
+
'5-4-1': {
|
|
130
|
+
'1': { x: 49, y: 80 }, // GK
|
|
131
|
+
'2': { x: 84, y: 58 }, // RB
|
|
132
|
+
'3': { x: 15, y: 58 }, // LB
|
|
133
|
+
'4': { x: 32, y: 58 }, // LCB
|
|
134
|
+
'5': { x: 49, y: 58 }, // CB
|
|
135
|
+
'6': { x: 67, y: 58 }, // RCB
|
|
136
|
+
'7': { x: 76, y: 30 }, // RCM
|
|
137
|
+
'8': { x: 58, y: 30 }, // LCM
|
|
138
|
+
'9': { x: 49, y: 8 }, // ST
|
|
139
|
+
'10': { x: 40, y: 30 }, // RM
|
|
140
|
+
'11': { x: 22, y: 30 }, // LM
|
|
141
|
+
},
|
|
142
|
+
'3-5-2': {
|
|
143
|
+
'1': { x: 49, y: 80 }, // GK
|
|
144
|
+
'2': { x: 86, y: 35 }, // RM
|
|
145
|
+
'3': { x: 16, y: 35 }, // LM
|
|
146
|
+
'4': { x: 28, y: 61 }, // LCB
|
|
147
|
+
'5': { x: 49, y: 61 }, // CB
|
|
148
|
+
'6': { x: 70, y: 61 }, // RCB
|
|
149
|
+
'7': { x: 68, y: 35 }, // RCM
|
|
150
|
+
'8': { x: 32, y: 35 }, // LCM
|
|
151
|
+
'9': { x: 40, y: 8 }, // LST
|
|
152
|
+
'10': { x: 60, y: 8 }, // RST
|
|
153
|
+
'11': { x: 49, y: 35 }, // CM
|
|
154
|
+
},
|
|
155
|
+
'3-4-3': {
|
|
156
|
+
'1': { x: 49, y: 80 }, // GK
|
|
157
|
+
'2': { x: 77, y: 33 }, // RM
|
|
158
|
+
'3': { x: 20, y: 33 }, // LM
|
|
159
|
+
'4': { x: 25, y: 59 }, // LCB
|
|
160
|
+
'5': { x: 49, y: 59 }, // CB
|
|
161
|
+
'6': { x: 72, y: 59 }, // RCB
|
|
162
|
+
'7': { x: 58, y: 33 }, // RCM
|
|
163
|
+
'8': { x: 38, y: 33 }, // LCM
|
|
164
|
+
'9': { x: 49, y: 8 }, // ST
|
|
165
|
+
'10': { x: 70, y: 8 }, // RW
|
|
166
|
+
'11': { x: 28, y: 8 }, // LW
|
|
167
|
+
},
|
|
168
|
+
'4-2-2-2': {
|
|
169
|
+
'1': { x: 49, y: 80 }, // GK
|
|
170
|
+
'2': { x: 87, y: 58 }, // RB
|
|
171
|
+
'3': { x: 10, y: 58 }, // LB
|
|
172
|
+
'4': { x: 34, y: 58 }, // LCB
|
|
173
|
+
'5': { x: 62, y: 58 }, // RCB
|
|
174
|
+
'6': { x: 62, y: 35 }, // RCDM
|
|
175
|
+
'7': { x: 35, y: 35 }, // LCDM
|
|
176
|
+
'8': { x: 76, y: 20 }, // RCAM
|
|
177
|
+
'9': { x: 36, y: 8 }, // LST
|
|
178
|
+
'10': { x: 60, y: 8 }, // RST
|
|
179
|
+
'11': { x: 22, y: 20 }, // LCAM
|
|
180
|
+
},
|
|
181
|
+
'3-5-1-1': {
|
|
182
|
+
'1': { x: 49, y: 80 }, // GK
|
|
183
|
+
'2': { x: 82, y: 40 }, // RWB
|
|
184
|
+
'3': { x: 16, y: 40 }, // LWB
|
|
185
|
+
'4': { x: 28, y: 61 }, // LCB
|
|
186
|
+
'5': { x: 49, y: 61 }, // CB
|
|
187
|
+
'6': { x: 68, y: 61 }, // RCB
|
|
188
|
+
'7': { x: 66, y: 40 }, // RCM
|
|
189
|
+
'8': { x: 31, y: 40 }, // LCM
|
|
190
|
+
'9': { x: 49, y: 8 }, // ST
|
|
191
|
+
'10': { x: 49, y: 25 }, // CAM
|
|
192
|
+
'11': { x: 49, y: 40 }, // CM
|
|
193
|
+
},
|
|
194
|
+
'3-4-2-1': {
|
|
195
|
+
'1': { x: 49, y: 80 }, // GK
|
|
196
|
+
'2': { x: 78, y: 40 }, // RM
|
|
197
|
+
'3': { x: 20, y: 40 }, // LM
|
|
198
|
+
'4': { x: 25, y: 61 }, // LCB
|
|
199
|
+
'5': { x: 49, y: 61 }, // CB
|
|
200
|
+
'6': { x: 70, y: 61 }, // RCB
|
|
201
|
+
'7': { x: 60, y: 40 }, // RCM
|
|
202
|
+
'8': { x: 40, y: 40 }, // LCM
|
|
203
|
+
'9': { x: 49, y: 8 }, // ST
|
|
204
|
+
'10': { x: 62, y: 22 }, // RCAM
|
|
205
|
+
'11': { x: 36, y: 22 }, // LCAM
|
|
206
|
+
},
|
|
207
|
+
'3-4-1-2': {
|
|
208
|
+
'1': { x: 49, y: 80 }, // GK
|
|
209
|
+
'2': { x: 80, y: 40 }, // RM
|
|
210
|
+
'3': { x: 18, y: 40 }, // LM
|
|
211
|
+
'4': { x: 28, y: 61 }, // LCB
|
|
212
|
+
'5': { x: 49, y: 61 }, // CB
|
|
213
|
+
'6': { x: 70, y: 61 }, // RCB
|
|
214
|
+
'7': { x: 62, y: 40 }, // RCM
|
|
215
|
+
'8': { x: 36, y: 40 }, // LCM
|
|
216
|
+
'9': { x: 49, y: 25 }, // LST
|
|
217
|
+
'10': { x: 62, y: 8 }, // RST
|
|
218
|
+
'11': { x: 36, y: 8 }, // CAM
|
|
219
|
+
},
|
|
220
|
+
'3-1-4-2': {
|
|
221
|
+
'1': { x: 49, y: 80 }, // GK
|
|
222
|
+
'2': { x: 80, y: 25 }, // RM
|
|
223
|
+
'3': { x: 15, y: 25 }, // LM
|
|
224
|
+
'4': { x: 49, y: 61 }, // LCB
|
|
225
|
+
'5': { x: 76, y: 61 }, // CB
|
|
226
|
+
'6': { x: 20, y: 61 }, // RCB
|
|
227
|
+
'7': { x: 49, y: 40 }, // RCAM
|
|
228
|
+
'8': { x: 62, y: 25 }, // LCAM
|
|
229
|
+
'9': { x: 62, y: 8 }, // LST
|
|
230
|
+
'10': { x: 36, y: 8 }, // RST
|
|
231
|
+
'11': { x: 36, y: 25 }, // CDM
|
|
232
|
+
},
|
|
233
|
+
'3-4-3d': {
|
|
234
|
+
'1': { x: 49, y: 80 }, // GK
|
|
235
|
+
'2': { x: 74, y: 35 }, // RWB (deeper)
|
|
236
|
+
'3': { x: 22, y: 35 }, // LWB (deeper)
|
|
237
|
+
'4': { x: 26, y: 61 }, // LCB
|
|
238
|
+
'5': { x: 50, y: 61 }, // CB
|
|
239
|
+
'6': { x: 72, y: 61 }, // RCB
|
|
240
|
+
'7': { x: 50, y: 45 }, // RCM
|
|
241
|
+
'8': { x: 50, y: 25 }, // LCM
|
|
242
|
+
'9': { x: 50, y: 8 }, // ST
|
|
243
|
+
'10': { x: 76, y: 15 }, // RW
|
|
244
|
+
'11': { x: 22, y: 15 }, // LW
|
|
245
|
+
},
|
|
246
|
+
'4-1-3-2': {
|
|
247
|
+
'1': { x: 49, y: 80 }, // GK
|
|
248
|
+
'2': { x: 86, y: 61 }, // RB
|
|
249
|
+
'3': { x: 12, y: 61 }, // LB
|
|
250
|
+
'4': { x: 36, y: 61 }, // LCB
|
|
251
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
252
|
+
'6': { x: 49, y: 44 }, // CDM
|
|
253
|
+
'7': { x: 77, y: 25 }, // RCAM
|
|
254
|
+
'8': { x: 20, y: 25 }, // LCAM
|
|
255
|
+
'9': { x: 35, y: 6 }, // LST
|
|
256
|
+
'10': { x: 62, y: 6 }, // RST
|
|
257
|
+
'11': { x: 49, y: 25 }, // CAM
|
|
258
|
+
},
|
|
259
|
+
'4-2-4-0': {
|
|
260
|
+
'1': { x: 49, y: 80 }, // GK
|
|
261
|
+
'2': { x: 88, y: 55 }, // RB
|
|
262
|
+
'3': { x: 10, y: 55 }, // LB
|
|
263
|
+
'4': { x: 36, y: 55 }, // LCB
|
|
264
|
+
'5': { x: 62, y: 55 }, // RCB
|
|
265
|
+
'6': { x: 62, y: 30 }, // RCDM
|
|
266
|
+
'7': { x: 36, y: 30 }, // LCDM
|
|
267
|
+
'8': { x: 62, y: 8 }, // RCAM
|
|
268
|
+
'9': { x: 78, y: 16 }, // RW
|
|
269
|
+
'10': { x: 36, y: 8 }, // LCAM
|
|
270
|
+
'11': { x: 18, y: 16 }, // LW
|
|
271
|
+
},
|
|
272
|
+
'4-3-1-2': {
|
|
273
|
+
'1': { x: 49, y: 80 }, // GK
|
|
274
|
+
'2': { x: 84, y: 61 }, // RB
|
|
275
|
+
'3': { x: 14, y: 61 }, // LB
|
|
276
|
+
'4': { x: 36, y: 61 }, // LCB
|
|
277
|
+
'5': { x: 62, y: 61 }, // RCB
|
|
278
|
+
'6': { x: 49, y: 40 }, // CM
|
|
279
|
+
'7': { x: 68, y: 40 }, // RCM
|
|
280
|
+
'8': { x: 28, y: 40 }, // LCM
|
|
281
|
+
'9': { x: 36, y: 6 }, // LST
|
|
282
|
+
'10': { x: 62, y: 6 }, // RST
|
|
283
|
+
'11': { x: 49, y: 23 }, // CAM
|
|
284
|
+
},
|
|
285
|
+
'3-2-4-1': {
|
|
286
|
+
'1': { x: 49, y: 80 }, // GK
|
|
287
|
+
'2': { x: 76, y: 25 }, // RM
|
|
288
|
+
'3': { x: 22, y: 25 }, // LM
|
|
289
|
+
'4': { x: 20, y: 61 }, // LCB
|
|
290
|
+
'5': { x: 49, y: 61 }, // CB
|
|
291
|
+
'6': { x: 76, y: 61 }, // RCB
|
|
292
|
+
'7': { x: 62, y: 45 }, // RCM
|
|
293
|
+
'8': { x: 36, y: 45 }, // LCM
|
|
294
|
+
'9': { x: 49, y: 8 }, // ST
|
|
295
|
+
'10': { x: 58, y: 25 }, // RCAM
|
|
296
|
+
'11': { x: 40, y: 25 }, // LCAM
|
|
297
|
+
},
|
|
298
|
+
'3-3-3-1': {
|
|
299
|
+
'1': { x: 49, y: 80 }, // GK
|
|
300
|
+
'2': { x: 78, y: 40 }, // RCM
|
|
301
|
+
'3': { x: 20, y: 40 }, // LCM
|
|
302
|
+
'4': { x: 20, y: 61 }, // LCB
|
|
303
|
+
'5': { x: 49, y: 61 }, // CB
|
|
304
|
+
'6': { x: 76, y: 61 }, // RCB
|
|
305
|
+
'7': { x: 49, y: 40 }, // CM
|
|
306
|
+
'8': { x: 76, y: 20 }, // RW
|
|
307
|
+
'9': { x: 49, y: 8 }, // ST
|
|
308
|
+
'10': { x: 49, y: 20 }, // CAM
|
|
309
|
+
'11': { x: 24, y: 20 }, // LW
|
|
310
|
+
},
|
|
311
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./formationCoordinates"), exports);
|
|
18
|
+
__exportStar(require("./transformLineup"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TeamLineup, PlayerStats, LineupFormationPlayer } from '../types';
|
|
2
|
+
type Stats = (PlayerStats | null)[];
|
|
3
|
+
/**
|
|
4
|
+
* Check if a player has a specific stat type
|
|
5
|
+
*/
|
|
6
|
+
export declare const hasStat: (stats: Stats | undefined, statType: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Get the value of a specific stat type for a player
|
|
9
|
+
*/
|
|
10
|
+
export declare const getStatValue: (stats: Stats | undefined, statType: string) => number | string;
|
|
11
|
+
/**
|
|
12
|
+
* Transform lineup data by formation place into positioned players
|
|
13
|
+
*
|
|
14
|
+
* @param data - TeamLineup data with players and formation
|
|
15
|
+
* @param formation - Formation string (e.g., "4-3-3", "4-2-3-1")
|
|
16
|
+
* @param getPlayerPhotoUrl - Optional function to generate photo URLs
|
|
17
|
+
* @returns Array of positioned players with stats
|
|
18
|
+
*/
|
|
19
|
+
export declare const transformLineupByFormationPlace: (data: TeamLineup, formation?: string, getPlayerPhotoUrl?: (playerId: string) => string) => LineupFormationPlayer[];
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=transformLineup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformLineup.d.ts","sourceRoot":"","sources":["../../src/utils/transformLineup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,WAAW,EACX,qBAAqB,EAEtB,MAAM,UAAU,CAAC;AAGlB,KAAK,KAAK,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,KAAK,GAAG,SAAS,EAAE,UAAU,MAAM,KAAG,OAEpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,KAAK,GAAG,SAAS,EACxB,UAAU,MAAM,KACf,MAAM,GAAG,MAEX,CAAC;AAgEF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAC1C,MAAM,UAAU,EAChB,YAAW,MAAkB,EAC7B,oBAAoB,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,KAC/C,qBAAqB,EAuDvB,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformLineupByFormationPlace = exports.getStatValue = exports.hasStat = void 0;
|
|
4
|
+
const formationCoordinates_1 = require("./formationCoordinates");
|
|
5
|
+
/**
|
|
6
|
+
* Check if a player has a specific stat type
|
|
7
|
+
*/
|
|
8
|
+
const hasStat = (stats, statType) => {
|
|
9
|
+
return stats?.some(stat => stat?.type === statType) ?? false;
|
|
10
|
+
};
|
|
11
|
+
exports.hasStat = hasStat;
|
|
12
|
+
/**
|
|
13
|
+
* Get the value of a specific stat type for a player
|
|
14
|
+
*/
|
|
15
|
+
const getStatValue = (stats, statType) => {
|
|
16
|
+
return stats?.find(stat => stat?.type === statType)?.value ?? 0;
|
|
17
|
+
};
|
|
18
|
+
exports.getStatValue = getStatValue;
|
|
19
|
+
/**
|
|
20
|
+
* Get formation coordinates by formation place (1-11)
|
|
21
|
+
*/
|
|
22
|
+
const getCoordinatesByFormationPlace = (formation, formationPlace) => {
|
|
23
|
+
const formationCoords = formationCoordinates_1.FORMATION_COORDINATES_BY_PLACE[formation];
|
|
24
|
+
if (!formationCoords) {
|
|
25
|
+
return { x: 49, y: 40 }; // Default position (center field)
|
|
26
|
+
}
|
|
27
|
+
return formationCoords[formationPlace] || { x: 49, y: 40 };
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Determine position type based on formationPlace and formation
|
|
31
|
+
*/
|
|
32
|
+
const getPositionTypeByFormationPlace = (formation, formationPlace) => {
|
|
33
|
+
const placeInt = parseInt(formationPlace);
|
|
34
|
+
// Common position mappings based on formationPlace
|
|
35
|
+
if (placeInt === 1)
|
|
36
|
+
return 'GK';
|
|
37
|
+
// For most formations, places 2-6 are defenders
|
|
38
|
+
if (placeInt >= 2 && placeInt <= 6) {
|
|
39
|
+
if (formation?.startsWith('3-')) {
|
|
40
|
+
// 3-back formations: 4,5,6 are CBs, 2,3 might be wing-backs
|
|
41
|
+
if (placeInt >= 4 && placeInt <= 6)
|
|
42
|
+
return 'CB';
|
|
43
|
+
if (placeInt === 2)
|
|
44
|
+
return 'RB';
|
|
45
|
+
if (placeInt === 3)
|
|
46
|
+
return 'LB';
|
|
47
|
+
}
|
|
48
|
+
else if (formation?.startsWith('5-')) {
|
|
49
|
+
// 5-back formations: all are defenders
|
|
50
|
+
return placeInt === 2 || placeInt === 3 ? 'LB' : 'CB';
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// 4-back formations
|
|
54
|
+
if (placeInt === 2)
|
|
55
|
+
return 'RB';
|
|
56
|
+
if (placeInt === 3)
|
|
57
|
+
return 'LB';
|
|
58
|
+
return 'CB';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Places 7-8 are usually midfielders
|
|
62
|
+
if (placeInt >= 7 && placeInt <= 8)
|
|
63
|
+
return 'CM';
|
|
64
|
+
// Place 9 is usually striker
|
|
65
|
+
if (placeInt === 9)
|
|
66
|
+
return 'ST';
|
|
67
|
+
// Places 10-11 vary by formation
|
|
68
|
+
if (placeInt >= 10 && placeInt <= 11) {
|
|
69
|
+
if (formation.includes('-3-') && formation.endsWith('3')) {
|
|
70
|
+
return placeInt === 10 ? 'RW' : 'LW'; // 4-3-3, 3-4-3 etc.
|
|
71
|
+
}
|
|
72
|
+
return 'CAM'; // Default to attacking midfielder
|
|
73
|
+
}
|
|
74
|
+
return 'CM'; // Default fallback
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Transform lineup data by formation place into positioned players
|
|
78
|
+
*
|
|
79
|
+
* @param data - TeamLineup data with players and formation
|
|
80
|
+
* @param formation - Formation string (e.g., "4-3-3", "4-2-3-1")
|
|
81
|
+
* @param getPlayerPhotoUrl - Optional function to generate photo URLs
|
|
82
|
+
* @returns Array of positioned players with stats
|
|
83
|
+
*/
|
|
84
|
+
const transformLineupByFormationPlace = (data, formation = '4-2-3-1', getPlayerPhotoUrl) => {
|
|
85
|
+
// Filter starters (players with formationPlace 1-11)
|
|
86
|
+
const starters = data?.players?.filter((p) => p?.formationPlace &&
|
|
87
|
+
parseInt(p?.formationPlace) >= 1 &&
|
|
88
|
+
parseInt(p?.formationPlace) <= 11 &&
|
|
89
|
+
p?.position !== 'Substitute') || [];
|
|
90
|
+
if (starters?.length < 11) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const transformedPlayers = starters?.map(player => {
|
|
94
|
+
const coordinates = getCoordinatesByFormationPlace(formation, player?.formationPlace);
|
|
95
|
+
const positionType = getPositionTypeByFormationPlace(formation, player?.formationPlace);
|
|
96
|
+
// Generate photo URL using custom function or empty string
|
|
97
|
+
const photoUrl = getPlayerPhotoUrl
|
|
98
|
+
? getPlayerPhotoUrl(player?.playerId)
|
|
99
|
+
: '';
|
|
100
|
+
return {
|
|
101
|
+
playerId: player?.playerId,
|
|
102
|
+
matchName: player?.matchName || '',
|
|
103
|
+
position: positionType,
|
|
104
|
+
formationPlace: player?.formationPlace,
|
|
105
|
+
rating: player?.rating,
|
|
106
|
+
isScorer: player?.stats && player?.stats?.length ? (0, exports.hasStat)(player?.stats, 'goals') : false,
|
|
107
|
+
isSubstitute: player?.stats && player?.stats?.length ? (0, exports.hasStat)(player?.stats, 'totalSubOff') : false,
|
|
108
|
+
isYellowCard: player?.stats && player?.stats?.length ? (0, exports.hasStat)(player?.stats, 'yellowCard') : false,
|
|
109
|
+
isRedCard: player?.stats && player?.stats?.length ? (0, exports.hasStat)(player?.stats, 'redCard') : false,
|
|
110
|
+
isGoalAssist: player?.stats && player?.stats?.length ? (0, exports.hasStat)(player?.stats, 'goalAssist') : false,
|
|
111
|
+
isOwnGoal: player?.stats && player?.stats?.length ? (0, exports.hasStat)(player?.stats, 'ownGoals') : false,
|
|
112
|
+
goals: Number((0, exports.getStatValue)(player?.stats, 'goals')),
|
|
113
|
+
ownGoals: Number((0, exports.getStatValue)(player?.stats, 'ownGoals')),
|
|
114
|
+
shirtNumber: player?.shirtNumber,
|
|
115
|
+
photo: photoUrl,
|
|
116
|
+
x: coordinates?.x,
|
|
117
|
+
y: coordinates?.y,
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
// Sort by formationPlace to maintain consistent ordering
|
|
121
|
+
transformedPlayers.sort((a, b) => {
|
|
122
|
+
return parseInt(a.formationPlace) - parseInt(b.formationPlace);
|
|
123
|
+
});
|
|
124
|
+
return transformedPlayers;
|
|
125
|
+
};
|
|
126
|
+
exports.transformLineupByFormationPlace = transformLineupByFormationPlace;
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-football-formation",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A highly customizable React Native component for displaying football/soccer team formations with player positions and match statistics",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"src",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"prepare": "npm run build",
|
|
16
|
+
"test": "jest",
|
|
17
|
+
"lint": "eslint src/ --ext .ts,.tsx",
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"react-native",
|
|
22
|
+
"football",
|
|
23
|
+
"soccer",
|
|
24
|
+
"formation",
|
|
25
|
+
"lineup",
|
|
26
|
+
"sports",
|
|
27
|
+
"match",
|
|
28
|
+
"team",
|
|
29
|
+
"tactical",
|
|
30
|
+
"field",
|
|
31
|
+
"pitch"
|
|
32
|
+
],
|
|
33
|
+
"author": "Arbab Rafiq",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": ">=18.0.0",
|
|
37
|
+
"react-native": ">=0.74.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^19.2.7",
|
|
41
|
+
"typescript": "^5.7.0",
|
|
42
|
+
"react": "^19.2.0",
|
|
43
|
+
"react-native": "^0.83.1",
|
|
44
|
+
"@react-native/typescript-config": "^0.76.0",
|
|
45
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
46
|
+
"eslint": "^9.0.0",
|
|
47
|
+
"jest": "^29.7.0",
|
|
48
|
+
"@testing-library/react-native": "^12.9.0",
|
|
49
|
+
"@types/jest": "^29.5.0",
|
|
50
|
+
"prettier": "^3.4.0"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/yourusername/react-native-football-formation"
|
|
55
|
+
},
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/yourusername/react-native-football-formation/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/yourusername/react-native-football-formation#readme"
|
|
60
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|