@alepot55/chessboardjs 2.2.0 → 2.2.2

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 (80) hide show
  1. package/.eslintrc.json +227 -0
  2. package/README.md +127 -403
  3. package/assets/themes/alepot/theme.json +42 -0
  4. package/assets/themes/default/theme.json +42 -0
  5. package/chessboard.bundle.js +782 -119
  6. package/config/jest.config.js +15 -0
  7. package/config/rollup.config.js +36 -0
  8. package/dist/chessboard.cjs.js +10690 -0
  9. package/dist/chessboard.css +228 -0
  10. package/dist/chessboard.esm.js +10621 -0
  11. package/dist/chessboard.iife.js +10696 -0
  12. package/dist/chessboard.umd.js +10696 -0
  13. package/jest.config.js +2 -7
  14. package/package.json +18 -3
  15. package/rollup.config.js +2 -11
  16. package/{chessboard.move.js → src/components/Move.js} +3 -3
  17. package/src/components/Piece.js +288 -0
  18. package/{chessboard.square.js → src/components/Square.js} +60 -7
  19. package/src/constants/index.js +15 -0
  20. package/src/constants/positions.js +62 -0
  21. package/src/core/Chessboard.js +1939 -0
  22. package/src/core/ChessboardConfig.js +458 -0
  23. package/src/core/ChessboardFactory.js +385 -0
  24. package/src/core/index.js +141 -0
  25. package/src/errors/ChessboardError.js +133 -0
  26. package/src/errors/index.js +15 -0
  27. package/src/errors/messages.js +189 -0
  28. package/src/index.js +103 -0
  29. package/src/services/AnimationService.js +180 -0
  30. package/src/services/BoardService.js +156 -0
  31. package/src/services/CoordinateService.js +355 -0
  32. package/src/services/EventService.js +955 -0
  33. package/src/services/MoveService.js +629 -0
  34. package/src/services/PieceService.js +312 -0
  35. package/src/services/PositionService.js +237 -0
  36. package/src/services/ValidationService.js +673 -0
  37. package/src/services/index.js +14 -0
  38. package/src/styles/animations.css +46 -0
  39. package/{chessboard.css → src/styles/board.css} +8 -4
  40. package/src/styles/index.css +4 -0
  41. package/src/styles/pieces.css +70 -0
  42. package/src/utils/animations.js +37 -0
  43. package/{chess.js → src/utils/chess.js} +16 -16
  44. package/src/utils/coordinates.js +62 -0
  45. package/src/utils/cross-browser.js +150 -0
  46. package/src/utils/logger.js +422 -0
  47. package/src/utils/performance.js +311 -0
  48. package/src/utils/validation.js +458 -0
  49. package/tests/unit/chessboard-config-animations.test.js +106 -0
  50. package/tests/unit/chessboard-robust.test.js +163 -0
  51. package/tests/unit/chessboard.test.js +183 -0
  52. package/chessboard.config.js +0 -147
  53. package/chessboard.js +0 -981
  54. package/chessboard.piece.js +0 -115
  55. package/test/chessboard.test.js +0 -128
  56. /package/{alepot_theme → assets/themes/alepot}/bb.svg +0 -0
  57. /package/{alepot_theme → assets/themes/alepot}/bw.svg +0 -0
  58. /package/{alepot_theme → assets/themes/alepot}/kb.svg +0 -0
  59. /package/{alepot_theme → assets/themes/alepot}/kw.svg +0 -0
  60. /package/{alepot_theme → assets/themes/alepot}/nb.svg +0 -0
  61. /package/{alepot_theme → assets/themes/alepot}/nw.svg +0 -0
  62. /package/{alepot_theme → assets/themes/alepot}/pb.svg +0 -0
  63. /package/{alepot_theme → assets/themes/alepot}/pw.svg +0 -0
  64. /package/{alepot_theme → assets/themes/alepot}/qb.svg +0 -0
  65. /package/{alepot_theme → assets/themes/alepot}/qw.svg +0 -0
  66. /package/{alepot_theme → assets/themes/alepot}/rb.svg +0 -0
  67. /package/{alepot_theme → assets/themes/alepot}/rw.svg +0 -0
  68. /package/{default_pieces → assets/themes/default}/bb.svg +0 -0
  69. /package/{default_pieces → assets/themes/default}/bw.svg +0 -0
  70. /package/{default_pieces → assets/themes/default}/kb.svg +0 -0
  71. /package/{default_pieces → assets/themes/default}/kw.svg +0 -0
  72. /package/{default_pieces → assets/themes/default}/nb.svg +0 -0
  73. /package/{default_pieces → assets/themes/default}/nw.svg +0 -0
  74. /package/{default_pieces → assets/themes/default}/pb.svg +0 -0
  75. /package/{default_pieces → assets/themes/default}/pw.svg +0 -0
  76. /package/{default_pieces → assets/themes/default}/qb.svg +0 -0
  77. /package/{default_pieces → assets/themes/default}/qw.svg +0 -0
  78. /package/{default_pieces → assets/themes/default}/rb.svg +0 -0
  79. /package/{default_pieces → assets/themes/default}/rw.svg +0 -0
  80. /package/{.babelrc → config/.babelrc} +0 -0
@@ -0,0 +1,228 @@
1
+ /* Main stylesheet for Chessboard.js */
2
+ @import './board.css';
3
+ @import './pieces.css';
4
+ @import './animations.css';
5
+ :root {
6
+ --dimBoard: 600px;
7
+ --pieceRatio: 0.9;
8
+ --square-size: calc(var(--dimBoard) / 8);
9
+
10
+ --blackSquare: #b58863;
11
+ --whiteSquare: #f0d9b5;
12
+ --highlightSquare: yellow;
13
+ --selectedSquareWhite: #ababaa;
14
+ --selectedSquareBlack: #ababaa;
15
+ --movedSquareBlack: #e9e981;
16
+ --movedSquareWhite: #f1f1a0;
17
+ --choiceSquare: white;
18
+ --coverSquare: black;
19
+ --hintColor: #ababaa;
20
+ }
21
+
22
+ .board {
23
+ display: grid;
24
+ grid-template: repeat(8, 1fr) / repeat(8, 1fr);
25
+ width: var(--dimBoard);
26
+ height: var(--dimBoard);
27
+ /* Enable hardware acceleration for better performance */
28
+ transform: translateZ(0);
29
+ will-change: auto;
30
+ }
31
+
32
+ .square {
33
+ width: var(--square-size);
34
+ height: var(--square-size);
35
+ display: flex;
36
+ justify-content: center;
37
+ align-items: center;
38
+ }
39
+
40
+ .piece {
41
+ position: absolute;
42
+ z-index: 10;
43
+ width: calc(var(--square-size) * var(--pieceRatio));
44
+ height: calc(var(--square-size) * var(--pieceRatio));
45
+
46
+ /* No selection */
47
+ -webkit-user-select: none;
48
+ /* Safari */
49
+ -moz-user-select: none;
50
+ /* Firefox */
51
+ -ms-user-select: none;
52
+ /* IE10+/Edge */
53
+ user-select: none;
54
+ /* Standard */
55
+ }
56
+
57
+ .choicable {
58
+ z-index: 50;
59
+ }
60
+
61
+ .hint {
62
+ background: var(--hintColor);
63
+ width: calc(calc(var(--dimBoard) / 8) / 3.5);
64
+ height: calc(calc(var(--dimBoard) / 8) / 3.5);
65
+ position: absolute;
66
+ z-index: 5;
67
+ border-radius: 50%;
68
+ opacity: 0.8;
69
+ }
70
+
71
+ .catchable {
72
+ width: calc(calc(var(--dimBoard) / 8) * 0.9);
73
+ height: calc(calc(var(--dimBoard) / 8) * 0.9);
74
+ }
75
+
76
+ .blackSquare {
77
+ background: var(--blackSquare);
78
+ }
79
+
80
+ .whiteSquare {
81
+ background: var(--whiteSquare);
82
+ }
83
+
84
+ .selectedSquareWhite {
85
+ background: var(--selectedSquareWhite);
86
+ }
87
+
88
+ .selectedSquareBlack {
89
+ background: var(--selectedSquareBlack);
90
+ }
91
+
92
+ .movedSquareBlack {
93
+ background: var(--movedSquareBlack);
94
+ }
95
+
96
+ .movedSquareWhite {
97
+ background: var(--movedSquareWhite);
98
+ }
99
+
100
+ .choice {
101
+ background: var(--choiceSquare);
102
+ z-index: 30;
103
+ }
104
+
105
+ .cover {
106
+ background: var(--coverSquare);
107
+ opacity: 0.5;
108
+ z-index: 25;
109
+ }
110
+
111
+ .highlighted {
112
+ box-shadow: inset 0 0 10px var(--highlightSquare);
113
+ }/* Piece-specific styles */
114
+ .piece {
115
+ position: absolute;
116
+ cursor: pointer;
117
+ /* Solo transizioni specifiche, non "all" */
118
+ transition: opacity var(--fade-time, 150ms) var(--fade-animation, ease);
119
+ z-index: 10;
120
+ /* Hint al browser per ottimizzazioni */
121
+ will-change: auto;
122
+ }
123
+
124
+ .piece.dragging {
125
+ z-index: 100;
126
+ /* Disabilita completamente le transizioni durante il drag */
127
+ transition: none !important;
128
+ /* Hint per ottimizzazione durante drag */
129
+ will-change: left, top, transform;
130
+ /* Mantiene le dimensioni originali del pezzo durante il drag */
131
+ width: calc(var(--square-size) * var(--pieceRatio)) !important;
132
+ height: calc(var(--square-size) * var(--pieceRatio)) !important;
133
+ /* Assicura che il pezzo mantenga le proporzioni corrette */
134
+ box-sizing: border-box;
135
+ }
136
+
137
+ .piece.fading {
138
+ opacity: 0;
139
+ transition: opacity var(--fade-time, 150ms) var(--fade-animation, ease);
140
+ }
141
+
142
+ .piece.moving {
143
+ /* Solo transizione per transform, non position */
144
+ transition: transform var(--move-time, 200ms) var(--move-animation, ease);
145
+ }
146
+
147
+ /* Piece replacement during promotion - no transitions to avoid flickering */
148
+ .piece.replacing {
149
+ transition: none !important;
150
+ opacity: 1;
151
+ transform: none;
152
+ }
153
+
154
+ /* Piece transformation during promotion - smooth scaling animation */
155
+ .piece.transforming {
156
+ transition: none !important;
157
+ transform-origin: center center;
158
+ will-change: transform, opacity;
159
+ z-index: 50;
160
+ }
161
+
162
+ /* Subtle bounce effect after transformation */
163
+ .piece.transform-complete {
164
+ animation: transformBounce 0.4s ease-out;
165
+ }
166
+
167
+ @keyframes transformBounce {
168
+ 0% { transform: scale(1); }
169
+ 50% { transform: scale(1.1); }
170
+ 100% { transform: scale(1); }
171
+ }
172
+
173
+ /* Piece sizing */
174
+ .piece img {
175
+ width: 100%;
176
+ height: 100%;
177
+ object-fit: contain;
178
+ /* Previene conflitti di drag dell'immagine */
179
+ pointer-events: none;
180
+ /* Migliore rendering */
181
+ image-rendering: crisp-edges;
182
+ }
183
+ /* Animation styles */
184
+ @keyframes fadeIn {
185
+ from { opacity: 0; }
186
+ to { opacity: 1; }
187
+ }
188
+
189
+ @keyframes fadeOut {
190
+ from { opacity: 1; }
191
+ to { opacity: 0; }
192
+ }
193
+
194
+ @keyframes slideIn {
195
+ from { transform: translateY(-10px); opacity: 0; }
196
+ to { transform: translateY(0); opacity: 1; }
197
+ }
198
+
199
+ @keyframes bounce {
200
+ 0%, 20%, 53%, 80%, 100% {
201
+ transform: translate3d(0, 0, 0);
202
+ }
203
+ 40%, 43% {
204
+ transform: translate3d(0, -5px, 0);
205
+ }
206
+ 70% {
207
+ transform: translate3d(0, -3px, 0);
208
+ }
209
+ 90% {
210
+ transform: translate3d(0, -1px, 0);
211
+ }
212
+ }
213
+
214
+ .fade-in {
215
+ animation: fadeIn var(--fade-time, 150ms) var(--fade-animation, ease);
216
+ }
217
+
218
+ .fade-out {
219
+ animation: fadeOut var(--fade-time, 150ms) var(--fade-animation, ease);
220
+ }
221
+
222
+ .slide-in {
223
+ animation: slideIn var(--fade-time, 150ms) var(--fade-animation, ease);
224
+ }
225
+
226
+ .bounce {
227
+ animation: bounce 1s ease;
228
+ }