react-native-chess-kit 0.4.2 → 0.5.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.
Files changed (82) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +168 -168
  3. package/lib/commonjs/board-annotations.js +8 -8
  4. package/lib/commonjs/board-arrows.js +7 -7
  5. package/lib/commonjs/board-background.js +5 -5
  6. package/lib/commonjs/board-coordinates.js +78 -11
  7. package/lib/commonjs/board-coordinates.js.map +1 -1
  8. package/lib/commonjs/board-drag-ghost.js +10 -10
  9. package/lib/commonjs/board-highlights.js +15 -15
  10. package/lib/commonjs/board-legal-dots.js +5 -5
  11. package/lib/commonjs/board-piece.js +25 -25
  12. package/lib/commonjs/board-pieces.js +6 -6
  13. package/lib/commonjs/board.js +76 -35
  14. package/lib/commonjs/board.js.map +1 -1
  15. package/lib/commonjs/constants.js +4 -1
  16. package/lib/commonjs/constants.js.map +1 -1
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/promotion-picker.js +8 -8
  19. package/lib/commonjs/static-board.js +51 -16
  20. package/lib/commonjs/static-board.js.map +1 -1
  21. package/lib/commonjs/use-board-gesture.js +52 -33
  22. package/lib/commonjs/use-board-gesture.js.map +1 -1
  23. package/lib/commonjs/use-board-pieces.js +15 -15
  24. package/lib/commonjs/use-board-state.js +8 -8
  25. package/lib/commonjs/use-premove.js +12 -12
  26. package/lib/module/board-annotations.js +8 -8
  27. package/lib/module/board-arrows.js +7 -7
  28. package/lib/module/board-background.js +5 -5
  29. package/lib/module/board-coordinates.js +79 -12
  30. package/lib/module/board-coordinates.js.map +1 -1
  31. package/lib/module/board-drag-ghost.js +10 -10
  32. package/lib/module/board-highlights.js +15 -15
  33. package/lib/module/board-legal-dots.js +5 -5
  34. package/lib/module/board-piece.js +25 -25
  35. package/lib/module/board-pieces.js +6 -6
  36. package/lib/module/board.js +77 -36
  37. package/lib/module/board.js.map +1 -1
  38. package/lib/module/constants.js +3 -0
  39. package/lib/module/constants.js.map +1 -1
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/module/promotion-picker.js +8 -8
  42. package/lib/module/static-board.js +52 -17
  43. package/lib/module/static-board.js.map +1 -1
  44. package/lib/module/use-board-gesture.js +52 -33
  45. package/lib/module/use-board-gesture.js.map +1 -1
  46. package/lib/module/use-board-pieces.js +15 -15
  47. package/lib/module/use-board-state.js +8 -8
  48. package/lib/module/use-premove.js +12 -12
  49. package/lib/typescript/board-coordinates.d.ts +10 -4
  50. package/lib/typescript/board-coordinates.d.ts.map +1 -1
  51. package/lib/typescript/board.d.ts.map +1 -1
  52. package/lib/typescript/constants.d.ts +2 -0
  53. package/lib/typescript/constants.d.ts.map +1 -1
  54. package/lib/typescript/index.d.ts +1 -1
  55. package/lib/typescript/index.d.ts.map +1 -1
  56. package/lib/typescript/static-board.d.ts.map +1 -1
  57. package/lib/typescript/types.d.ts +23 -3
  58. package/lib/typescript/types.d.ts.map +1 -1
  59. package/lib/typescript/use-board-gesture.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/src/board-annotations.tsx +147 -147
  62. package/src/board-arrows.tsx +197 -197
  63. package/src/board-background.tsx +46 -46
  64. package/src/board-coordinates.tsx +192 -98
  65. package/src/board-drag-ghost.tsx +132 -132
  66. package/src/board-highlights.tsx +226 -226
  67. package/src/board-legal-dots.tsx +73 -73
  68. package/src/board-piece.tsx +160 -160
  69. package/src/board-pieces.tsx +63 -63
  70. package/src/board.tsx +685 -641
  71. package/src/constants.ts +103 -100
  72. package/src/index.ts +101 -100
  73. package/src/pieces/default-pieces.tsx +383 -383
  74. package/src/pieces/index.ts +1 -1
  75. package/src/promotion-picker.tsx +147 -147
  76. package/src/static-board.tsx +187 -150
  77. package/src/themes.ts +129 -129
  78. package/src/types.ts +373 -352
  79. package/src/use-board-gesture.ts +429 -412
  80. package/src/use-board-pieces.ts +158 -158
  81. package/src/use-board-state.ts +111 -111
  82. package/src/use-premove.ts +59 -59
@@ -1,147 +1,147 @@
1
- import React from 'react';
2
- import { View, Text } from 'react-native';
3
-
4
- import type { ChessColor, AnnotationData } from './types';
5
- import { squareToXY } from './use-board-pieces';
6
- import { DEFAULT_ANNOTATION_BG, DEFAULT_ANNOTATION_TEXT, ANNOTATION_SCALE } from './constants';
7
-
8
- // ---------------------------------------------------------------------------
9
- // Props
10
- // ---------------------------------------------------------------------------
11
-
12
- type BoardAnnotationsProps = {
13
- boardSize: number;
14
- orientation: ChessColor;
15
- squareSize: number;
16
- annotations: AnnotationData[];
17
- };
18
-
19
- // ---------------------------------------------------------------------------
20
- // Annotations layer
21
- // ---------------------------------------------------------------------------
22
-
23
- /**
24
- * Text annotation badges on chess squares (!, ?, !!, ??, etc.).
25
- *
26
- * Each annotation appears as a small colored badge at the top-right
27
- * corner of the target square. Positioned absolutely, pointer-events none.
28
- */
29
- export const BoardAnnotations = React.memo(function BoardAnnotations({
30
- boardSize,
31
- orientation,
32
- squareSize,
33
- annotations,
34
- }: BoardAnnotationsProps) {
35
- if (annotations.length === 0) return null;
36
-
37
- const badgeSize = squareSize * ANNOTATION_SCALE;
38
- const fontSize = badgeSize * 0.65;
39
-
40
- return (
41
- <View
42
- style={{ position: 'absolute', width: boardSize, height: boardSize }}
43
- pointerEvents="none"
44
- >
45
- {annotations.map((ann, i) => {
46
- const { x, y } = squareToXY(ann.square, squareSize, orientation);
47
- const bgColor = ann.backgroundColor ?? DEFAULT_ANNOTATION_BG;
48
- const textColor = ann.color ?? DEFAULT_ANNOTATION_TEXT;
49
-
50
- return (
51
- <View
52
- key={`ann-${ann.square}-${i}`}
53
- style={{
54
- position: 'absolute',
55
- // Position at top-right corner of the square
56
- left: x + squareSize - badgeSize - 1,
57
- top: y + 1,
58
- minWidth: badgeSize,
59
- height: badgeSize,
60
- borderRadius: badgeSize / 2,
61
- backgroundColor: bgColor,
62
- alignItems: 'center',
63
- justifyContent: 'center',
64
- paddingHorizontal: 2,
65
- }}
66
- >
67
- <Text
68
- style={{
69
- color: textColor,
70
- fontSize,
71
- fontWeight: '700',
72
- lineHeight: badgeSize * 0.85,
73
- textAlign: 'center',
74
- }}
75
- numberOfLines={1}
76
- >
77
- {ann.text}
78
- </Text>
79
- </View>
80
- );
81
- })}
82
- </View>
83
- );
84
- });
85
-
86
- // ---------------------------------------------------------------------------
87
- // Standalone export for advanced consumers
88
- // ---------------------------------------------------------------------------
89
-
90
- type AnnotationBadgeProps = {
91
- square: string;
92
- text: string;
93
- squareSize: number;
94
- orientation: ChessColor;
95
- color?: string;
96
- backgroundColor?: string;
97
- };
98
-
99
- /**
100
- * Single annotation badge component.
101
- * Exported for consumers who build their own overlay layers.
102
- */
103
- export const Annotation = React.memo(function Annotation({
104
- square,
105
- text,
106
- squareSize,
107
- orientation,
108
- color,
109
- backgroundColor,
110
- }: AnnotationBadgeProps) {
111
- const { x, y } = squareToXY(square, squareSize, orientation);
112
- const badgeSize = squareSize * ANNOTATION_SCALE;
113
- const fontSize = badgeSize * 0.65;
114
- const bgColor = backgroundColor ?? DEFAULT_ANNOTATION_BG;
115
- const textColor = color ?? DEFAULT_ANNOTATION_TEXT;
116
-
117
- return (
118
- <View
119
- style={{
120
- position: 'absolute',
121
- left: x + squareSize - badgeSize - 1,
122
- top: y + 1,
123
- minWidth: badgeSize,
124
- height: badgeSize,
125
- borderRadius: badgeSize / 2,
126
- backgroundColor: bgColor,
127
- alignItems: 'center',
128
- justifyContent: 'center',
129
- paddingHorizontal: 2,
130
- }}
131
- pointerEvents="none"
132
- >
133
- <Text
134
- style={{
135
- color: textColor,
136
- fontSize,
137
- fontWeight: '700',
138
- lineHeight: badgeSize * 0.85,
139
- textAlign: 'center',
140
- }}
141
- numberOfLines={1}
142
- >
143
- {text}
144
- </Text>
145
- </View>
146
- );
147
- });
1
+ import React from 'react';
2
+ import { View, Text } from 'react-native';
3
+
4
+ import type { ChessColor, AnnotationData } from './types';
5
+ import { squareToXY } from './use-board-pieces';
6
+ import { DEFAULT_ANNOTATION_BG, DEFAULT_ANNOTATION_TEXT, ANNOTATION_SCALE } from './constants';
7
+
8
+ // ---------------------------------------------------------------------------
9
+ // Props
10
+ // ---------------------------------------------------------------------------
11
+
12
+ type BoardAnnotationsProps = {
13
+ boardSize: number;
14
+ orientation: ChessColor;
15
+ squareSize: number;
16
+ annotations: AnnotationData[];
17
+ };
18
+
19
+ // ---------------------------------------------------------------------------
20
+ // Annotations layer
21
+ // ---------------------------------------------------------------------------
22
+
23
+ /**
24
+ * Text annotation badges on chess squares (!, ?, !!, ??, etc.).
25
+ *
26
+ * Each annotation appears as a small colored badge at the top-right
27
+ * corner of the target square. Positioned absolutely, pointer-events none.
28
+ */
29
+ export const BoardAnnotations = React.memo(function BoardAnnotations({
30
+ boardSize,
31
+ orientation,
32
+ squareSize,
33
+ annotations,
34
+ }: BoardAnnotationsProps) {
35
+ if (annotations.length === 0) return null;
36
+
37
+ const badgeSize = squareSize * ANNOTATION_SCALE;
38
+ const fontSize = badgeSize * 0.65;
39
+
40
+ return (
41
+ <View
42
+ style={{ position: 'absolute', width: boardSize, height: boardSize }}
43
+ pointerEvents="none"
44
+ >
45
+ {annotations.map((ann, i) => {
46
+ const { x, y } = squareToXY(ann.square, squareSize, orientation);
47
+ const bgColor = ann.backgroundColor ?? DEFAULT_ANNOTATION_BG;
48
+ const textColor = ann.color ?? DEFAULT_ANNOTATION_TEXT;
49
+
50
+ return (
51
+ <View
52
+ key={`ann-${ann.square}-${i}`}
53
+ style={{
54
+ position: 'absolute',
55
+ // Position at top-right corner of the square
56
+ left: x + squareSize - badgeSize - 1,
57
+ top: y + 1,
58
+ minWidth: badgeSize,
59
+ height: badgeSize,
60
+ borderRadius: badgeSize / 2,
61
+ backgroundColor: bgColor,
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ paddingHorizontal: 2,
65
+ }}
66
+ >
67
+ <Text
68
+ style={{
69
+ color: textColor,
70
+ fontSize,
71
+ fontWeight: '700',
72
+ lineHeight: badgeSize * 0.85,
73
+ textAlign: 'center',
74
+ }}
75
+ numberOfLines={1}
76
+ >
77
+ {ann.text}
78
+ </Text>
79
+ </View>
80
+ );
81
+ })}
82
+ </View>
83
+ );
84
+ });
85
+
86
+ // ---------------------------------------------------------------------------
87
+ // Standalone export for advanced consumers
88
+ // ---------------------------------------------------------------------------
89
+
90
+ type AnnotationBadgeProps = {
91
+ square: string;
92
+ text: string;
93
+ squareSize: number;
94
+ orientation: ChessColor;
95
+ color?: string;
96
+ backgroundColor?: string;
97
+ };
98
+
99
+ /**
100
+ * Single annotation badge component.
101
+ * Exported for consumers who build their own overlay layers.
102
+ */
103
+ export const Annotation = React.memo(function Annotation({
104
+ square,
105
+ text,
106
+ squareSize,
107
+ orientation,
108
+ color,
109
+ backgroundColor,
110
+ }: AnnotationBadgeProps) {
111
+ const { x, y } = squareToXY(square, squareSize, orientation);
112
+ const badgeSize = squareSize * ANNOTATION_SCALE;
113
+ const fontSize = badgeSize * 0.65;
114
+ const bgColor = backgroundColor ?? DEFAULT_ANNOTATION_BG;
115
+ const textColor = color ?? DEFAULT_ANNOTATION_TEXT;
116
+
117
+ return (
118
+ <View
119
+ style={{
120
+ position: 'absolute',
121
+ left: x + squareSize - badgeSize - 1,
122
+ top: y + 1,
123
+ minWidth: badgeSize,
124
+ height: badgeSize,
125
+ borderRadius: badgeSize / 2,
126
+ backgroundColor: bgColor,
127
+ alignItems: 'center',
128
+ justifyContent: 'center',
129
+ paddingHorizontal: 2,
130
+ }}
131
+ pointerEvents="none"
132
+ >
133
+ <Text
134
+ style={{
135
+ color: textColor,
136
+ fontSize,
137
+ fontWeight: '700',
138
+ lineHeight: badgeSize * 0.85,
139
+ textAlign: 'center',
140
+ }}
141
+ numberOfLines={1}
142
+ >
143
+ {text}
144
+ </Text>
145
+ </View>
146
+ );
147
+ });