poker-irongrid 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/README.md ADDED
@@ -0,0 +1,413 @@
1
+ # Poker Grid Component
2
+
3
+ A comprehensive Svelte 5 component for visualizing and managing poker hand ranges with an interactive 13x13 grid interface.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install poker-irongrid
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ - `svelte`: ^5.0.0
14
+ - `poker-bitvaljs`: ^1.0.1 (for equity evaluation)
15
+ - `poker-extval`: ^3.2.0 (for hand evaluation)
16
+ - `poker-rangeman`: ^3.3.2 (for range parsing and filtering)
17
+
18
+ ## Quick Start
19
+
20
+ ```svelte
21
+ <script>
22
+ import PokerGridPanel from 'poker-irongrid';
23
+
24
+ let hands = {};
25
+ let visibleHands = {};
26
+ let deadCards = [];
27
+ let boardCards = [];
28
+ let heroCards = [];
29
+
30
+ const ranges = [
31
+ { name: 'Tight', abbreviation: '22+,A2s+,K9s+,Q9s+,J9s+,T9s,98s,87s,76s,65s,54s,AJo+,KQo' },
32
+ { name: 'Loose', abbreviation: '22+,A2+,K2+,Q2+,J2+,T2+,92+,82+,72+,62+,52+,42+,32+' }
33
+ ];
34
+
35
+ const colors = [
36
+ 'hsl(60, 100%, 70%)',
37
+ 'hsl(120, 100%, 70%)',
38
+ 'hsl(240, 100%, 85%)'
39
+ ];
40
+ </script>
41
+
42
+ <PokerGridPanel
43
+ bind:hands
44
+ bind:visibleHands
45
+ bind:deadCards
46
+ bind:boardCards
47
+ bind:heroCards
48
+ {ranges}
49
+ {colors}
50
+ />
51
+ ```
52
+
53
+ ## API Reference
54
+
55
+ ### Props
56
+
57
+ #### Core Data Props (Two-way Bound)
58
+
59
+ | Prop | Type | Default | Description |
60
+ |------|------|---------|-------------|
61
+ | `hands` | `Object` or `Array<string>` | `{}` | Raw hands map (combos/abstracts) or array of hand strings. Format: `{ "AcKd": ["selected", "hsl(60, 100%, 70%)"], "AA": ["selected"] }` |
62
+ | `visibleHands` | `Object` | `{}` | Visible hands after filtering by dead cards (read-only, automatically computed) |
63
+ | `deadCards` | `Array<string>` | `[]` | Dead cards as two-character codes (e.g., `["Ac", "Kd"]`) |
64
+ | `boardCards` | `Array<string>` | `[]` | Board cards as two-character codes (e.g., `["As", "Kh", "Qc"]`) |
65
+ | `heroCards` | `Array<string>` | `[]` | Hero cards as two-character codes (e.g., `["Ac", "Kd"]`) |
66
+
67
+ #### Visibility Props
68
+
69
+ | Prop | Type | Default | Description |
70
+ |------|------|---------|-------------|
71
+ | `interactive` | `boolean` | `true` | Whether the panel is interactive (shows inputs/controls and allows grid interaction) |
72
+ | `showDeadInputs` | `boolean` | `true` | Show dead cards input fields |
73
+ | `showRangeSelect` | `boolean` | `true` | Show range selection dropdown |
74
+ | `showControls` | `boolean` | `true` | Show hand selector controls (filters, colors, etc.) |
75
+ | `showSummary` | `boolean` | `true` | Show selection summary at bottom |
76
+ | `showTips` | `boolean` | `false` | Show tooltips on click when non-interactive |
77
+ | `enableDetailsPanel` | `boolean` | `false` | Enable double-click details panel |
78
+
79
+ #### Configuration Props
80
+
81
+ | Prop | Type | Default | Description |
82
+ |------|------|---------|-------------|
83
+ | `ranges` | `Array<{name: string, abbreviation: string}>` | `[]` | Predefined ranges for range selection dropdown |
84
+ | `colors` | `Array<string>` | `[]` | Color palette for highlighting hands (HSL format recommended) |
85
+ | `defaultColor` | `string` | `'hsl(0, 0%, 100%)'` | Default background color for uncolored hands |
86
+ | `defaultSelectedColor` | `string` | `'hsl(0, 0%, 85%)'` | Default color for selected hands without explicit color |
87
+ | `evaluator` | `boolean` | `false` | Enable equity evaluation feature (requires hero cards and hands on grid) |
88
+
89
+ #### Initial State Props
90
+
91
+ | Prop | Type | Default | Description |
92
+ |------|------|---------|-------------|
93
+ | `initialHands` | `Object` | `undefined` | Initial hands state (only applied if hands is empty) |
94
+ | `initialBoard` | `Array<string>` | `undefined` | Initial board cards (only applied if boardCards is empty) |
95
+ | `initialDead` | `Array<string>` | `undefined` | Initial dead cards (only applied if deadCards is empty) |
96
+
97
+ ### Events
98
+
99
+ | Event | Payload | Description |
100
+ |-------|---------|-------------|
101
+ | `selectionChange` | `{ hands: Object, visibleHands: Object }` | Fired when hands selection changes |
102
+ | `rangeSelected` | `{ name: string, hands: Object }` | Fired when a range is selected from dropdown |
103
+ | `deadCardsChange` | `{ deadCards: Array<string>, boardCards: Array<string> }` | Fired when dead cards or board cards change |
104
+ | `cellClick` | `{ cellInfo: Object }` | Fired when a grid cell is clicked (when `showTips` is true) |
105
+ | `cellDetails` | `{ cellInfo: Object }` | Fired when a grid cell is double-clicked (when `enableDetailsPanel` is true) |
106
+
107
+ ## Data Structures
108
+
109
+ ### Hand Format
110
+
111
+ Hands are represented as objects where keys are hand strings and values are arrays of metadata:
112
+
113
+ ```javascript
114
+ {
115
+ "AcKd": ["selected", "hsl(60, 100%, 70%)"], // Combo with selection and color
116
+ "AA": ["selected"], // Abstract hand (all AA combos)
117
+ "AKs": ["hsl(120, 100%, 70%)"] // Suited hand with color
118
+ }
119
+ ```
120
+
121
+ **Hand String Formats:**
122
+ - **Combos**: `"AcKd"` (specific cards)
123
+ - **Pairs**: `"AA"` (pocket pair)
124
+ - **Suited**: `"AKs"` (suited hand)
125
+ - **Offsuit**: `"AKo"` (offsuit hand)
126
+
127
+ **Metadata Array Values:**
128
+ - `"selected"` - Hand is selected
129
+ - `"hsl(...)"` - HSL color string for highlighting
130
+
131
+ ### Card Format
132
+
133
+ Cards are represented as two-character strings:
134
+ - First character: Rank (`A`, `K`, `Q`, `J`, `T`, `9`, `8`, `7`, `6`, `5`, `4`, `3`, `2`)
135
+ - Second character: Suit (`c` = clubs, `d` = diamonds, `h` = hearts, `s` = spades)
136
+
137
+ Examples: `"Ac"`, `"Kd"`, `"Qh"`, `"Js"`
138
+
139
+ ### Range Format
140
+
141
+ Ranges are arrays of objects with `name` and `abbreviation` properties:
142
+
143
+ ```javascript
144
+ [
145
+ {
146
+ name: 'Tight',
147
+ abbreviation: '22+,A2s+,K9s+,Q9s+,J9s+,T9s,98s,87s,76s,65s,54s,AJo+,KQo'
148
+ }
149
+ ]
150
+ ```
151
+
152
+ The `abbreviation` uses standard poker range notation (e.g., `22+` = all pairs, `A2s+` = all suited aces, `AJo+` = all offsuit aces).
153
+
154
+ ## Features
155
+
156
+ ### Interactive Grid
157
+
158
+ - **13x13 Grid**: Visual representation of all 169 possible starting hands
159
+ - **Click Selection**: Click cells to select/deselect hands
160
+ - **Drag Selection**: Click and drag to select multiple hands
161
+ - **Modifier Keys**:
162
+ - **Ctrl/Cmd + Click**: Add to selection
163
+ - **Shift + Click**: Remove from selection
164
+ - **Normal Click**: Replace selection
165
+
166
+ ### Dead Card Filtering
167
+
168
+ - Automatically filters out hands containing dead cards
169
+ - Supports hero cards, board cards, and additional dead cards
170
+ - Real-time filtering as cards are added/removed
171
+
172
+ ### Range Selection
173
+
174
+ - Apply predefined ranges from dropdown
175
+ - Ranges use standard poker notation
176
+ - Automatically selects all hands in the range
177
+
178
+ ### Hand Filtering
179
+
180
+ The component includes comprehensive filtering options:
181
+
182
+ **Made Hands:**
183
+ - One Pair
184
+ - Two Pair
185
+ - Three of a Kind
186
+ - Four of a Kind
187
+ - Straight
188
+ - Flush
189
+ - Full House
190
+
191
+ **Draws:**
192
+ - Straight Draw
193
+ - Flush Draw
194
+ - Combo Draw
195
+ - Backdoor Flush Draw
196
+
197
+ **Card Filters:**
198
+ - By Rank (A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2)
199
+ - By Suit (Clubs, Diamonds, Hearts, Spades)
200
+ - Paired hands
201
+ - Suited hands
202
+ - Offsuit hands
203
+
204
+ **Selection Actions:**
205
+ - Clear All
206
+ - Inverse Selection
207
+ - Unselect All
208
+ - Remove Selected
209
+
210
+ ### Color Highlighting
211
+
212
+ - Assign colors to selected hands
213
+ - Multiple colors supported
214
+ - Visual distinction between colored and uncolored hands
215
+ - Color statistics display
216
+
217
+ ### Equity Evaluation
218
+
219
+ When `evaluator={true}`:
220
+ - Calculate hero equity vs. villain range
221
+ - Requires: 2 hero cards and hands on grid
222
+ - Uses Monte Carlo simulation (10,000 iterations)
223
+ - Displays results as percentages
224
+ - Progress indicator during evaluation
225
+
226
+ ### Responsive Design
227
+
228
+ - Mobile-friendly layout
229
+ - Touch support for drag selection
230
+ - Adaptive grid sizing
231
+ - Optimized for various screen sizes
232
+
233
+ ## Usage Examples
234
+
235
+ ### Basic Usage
236
+
237
+ ```svelte
238
+ <script>
239
+ import PokerGridPanel from 'poker-irongrid';
240
+
241
+ let hands = {};
242
+ let deadCards = [];
243
+ let boardCards = [];
244
+ </script>
245
+
246
+ <PokerGridPanel
247
+ bind:hands
248
+ bind:deadCards
249
+ bind:boardCards
250
+ />
251
+ ```
252
+
253
+ ### With Ranges
254
+
255
+ ```svelte
256
+ <script>
257
+ import PokerGridPanel from 'poker-irongrid';
258
+
259
+ const ranges = [
260
+ { name: 'UTG', abbreviation: '22+,A2s+,K9s+,Q9s+,J9s+,T9s,98s,87s,76s,65s,54s,AJo+,KQo' },
261
+ { name: 'Button', abbreviation: '22+,A2+,K2+,Q2+,J2+,T2+,92+,82+,72+,62+,52+,42+,32+' }
262
+ ];
263
+
264
+ let hands = {};
265
+ </script>
266
+
267
+ <PokerGridPanel
268
+ bind:hands
269
+ {ranges}
270
+ showRangeSelect={true}
271
+ />
272
+ ```
273
+
274
+ ### With Colors
275
+
276
+ ```svelte
277
+ <script>
278
+ import PokerGridPanel from 'poker-irongrid';
279
+
280
+ const colors = [
281
+ 'hsl(60, 100%, 70%)', // Yellow
282
+ 'hsl(120, 100%, 70%)', // Green
283
+ 'hsl(240, 100%, 85%)', // Blue
284
+ 'hsl(300, 100%, 70%)', // Magenta
285
+ 'hsl(30, 100%, 70%)', // Orange
286
+ 'hsl(0, 100%, 85%)' // Red
287
+ ];
288
+
289
+ let hands = {};
290
+ </script>
291
+
292
+ <PokerGridPanel
293
+ bind:hands
294
+ {colors}
295
+ showControls={true}
296
+ />
297
+ ```
298
+
299
+ ### With Equity Evaluation
300
+
301
+ ```svelte
302
+ <script>
303
+ import PokerGridPanel from 'poker-irongrid';
304
+
305
+ let hands = {};
306
+ let heroCards = ['Ac', 'Kd'];
307
+ let boardCards = ['As', 'Kh', 'Qc'];
308
+ let deadCards = [];
309
+ </script>
310
+
311
+ <PokerGridPanel
312
+ bind:hands
313
+ bind:heroCards
314
+ bind:boardCards
315
+ bind:deadCards
316
+ evaluator={true}
317
+ showSummary={true}
318
+ />
319
+ ```
320
+
321
+ ### Read-Only Display
322
+
323
+ ```svelte
324
+ <script>
325
+ import PokerGridPanel from 'poker-irongrid';
326
+
327
+ const hands = {
328
+ "AA": ["selected"],
329
+ "KK": ["selected"],
330
+ "QQ": ["hsl(60, 100%, 70%)"]
331
+ };
332
+ </script>
333
+
334
+ <PokerGridPanel
335
+ hands={hands}
336
+ interactive={false}
337
+ showTips={true}
338
+ />
339
+ ```
340
+
341
+ ### Handling Events
342
+
343
+ ```svelte
344
+ <script>
345
+ import PokerGridPanel from 'poker-irongrid';
346
+
347
+ let hands = {};
348
+
349
+ function handleSelectionChange(event) {
350
+ console.log('Selection changed:', event.detail.hands);
351
+ // Update your application state
352
+ }
353
+
354
+ function handleRangeSelected(event) {
355
+ console.log('Range selected:', event.detail.name);
356
+ console.log('Hands:', event.detail.hands);
357
+ }
358
+ </script>
359
+
360
+ <PokerGridPanel
361
+ bind:hands
362
+ on:selectionChange={handleSelectionChange}
363
+ on:rangeSelected={handleRangeSelected}
364
+ />
365
+ ```
366
+
367
+ ## Styling
368
+
369
+ The component uses Tailwind CSS classes and CSS custom properties. You can customize the appearance by defining CSS variables:
370
+
371
+ ```css
372
+ :root {
373
+ --poker-accent: #dc2626;
374
+ --poker-border: #e5e7eb;
375
+ --poker-border-light: #d1d5db;
376
+ --poker-text-primary: #111827;
377
+ --poker-text-secondary: #6b7280;
378
+ --poker-white: #ffffff;
379
+ }
380
+ ```
381
+
382
+ ## Component Structure
383
+
384
+ ```
385
+ poker-grid/
386
+ ├── components/
387
+ │ ├── Grid.svelte # Main 13x13 grid display
388
+ │ ├── HandSelector.svelte # Filter and color controls
389
+ │ ├── DeadCardsInput.svelte # Dead cards input fields
390
+ │ ├── RangeSelect.svelte # Range selection dropdown
391
+ │ ├── SelectionSummary.svelte # Summary and evaluation
392
+ │ ├── DetailsPanel.svelte # Cell details panel
393
+ │ └── PokerGridPanel.svelte # Main component
394
+ ├── utils/
395
+ │ ├── constants.js # Constants (RANKS, SUITS, etc.)
396
+ │ └── index.js # Utility exports
397
+ ├── PokerGridManager.js # Business logic manager
398
+ └── index.js # Main entry point
399
+ ```
400
+
401
+ ## Browser Support
402
+
403
+ - Modern browsers with ES6+ support
404
+ - Touch devices (iOS Safari, Chrome Mobile)
405
+ - Desktop browsers (Chrome, Firefox, Safari, Edge)
406
+
407
+ ## License
408
+
409
+ [Add your license here]
410
+
411
+ ## Contributing
412
+
413
+ [Add contribution guidelines here]
@@ -0,0 +1,2 @@
1
+ export * from "./poker-grid/index.js";
2
+ export { default } from "./poker-grid/index.js";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // Reexport poker-grid components
2
+ export * from './poker-grid/index.js';
3
+ export { default } from './poker-grid/index.js';