@fgv/ts-sudoku-ui 0.1.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/.rush/temp/chunked-rush-logs/ts-sudoku-ui.build.chunks.jsonl +14 -0
- package/.rush/temp/operation/build/log-chunks.jsonl +14 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +1086 -0
- package/.test-failures-catalog.md +470 -0
- package/CSS_MODULES_MIGRATION_SUMMARY.md +189 -0
- package/dist/ts-sudoku-ui.d.ts +668 -0
- package/etc/ts-sudoku-ui.api.md +481 -0
- package/lib/components/CageOverlay.d.ts +8 -0
- package/lib/components/CageOverlay.d.ts.map +1 -0
- package/lib/components/CageOverlay.js +133 -0
- package/lib/components/CageOverlay.js.map +1 -0
- package/lib/components/CageSumIndicator.d.ts +8 -0
- package/lib/components/CageSumIndicator.d.ts.map +1 -0
- package/lib/components/CageSumIndicator.js +66 -0
- package/lib/components/CageSumIndicator.js.map +1 -0
- package/lib/components/CombinationCard.d.ts +8 -0
- package/lib/components/CombinationCard.d.ts.map +1 -0
- package/lib/components/CombinationCard.js +64 -0
- package/lib/components/CombinationCard.js.map +1 -0
- package/lib/components/CombinationGrid.d.ts +8 -0
- package/lib/components/CombinationGrid.d.ts.map +1 -0
- package/lib/components/CombinationGrid.js +51 -0
- package/lib/components/CombinationGrid.js.map +1 -0
- package/lib/components/CompactControlRibbon.d.ts +45 -0
- package/lib/components/CompactControlRibbon.d.ts.map +1 -0
- package/lib/components/CompactControlRibbon.js +141 -0
- package/lib/components/CompactControlRibbon.js.map +1 -0
- package/lib/components/DualKeypad.d.ts +39 -0
- package/lib/components/DualKeypad.d.ts.map +1 -0
- package/lib/components/DualKeypad.js +137 -0
- package/lib/components/DualKeypad.js.map +1 -0
- package/lib/components/KillerCombinationsExplorer.d.ts +9 -0
- package/lib/components/KillerCombinationsExplorer.d.ts.map +1 -0
- package/lib/components/KillerCombinationsExplorer.js +69 -0
- package/lib/components/KillerCombinationsExplorer.js.map +1 -0
- package/lib/components/KillerCombinationsModal.d.ts +20 -0
- package/lib/components/KillerCombinationsModal.d.ts.map +1 -0
- package/lib/components/KillerCombinationsModal.js +135 -0
- package/lib/components/KillerCombinationsModal.js.map +1 -0
- package/lib/components/KillerCombinationsPanel.d.ts +20 -0
- package/lib/components/KillerCombinationsPanel.d.ts.map +1 -0
- package/lib/components/KillerCombinationsPanel.js +79 -0
- package/lib/components/KillerCombinationsPanel.js.map +1 -0
- package/lib/components/NumberKeypad.d.ts +30 -0
- package/lib/components/NumberKeypad.d.ts.map +1 -0
- package/lib/components/NumberKeypad.js +181 -0
- package/lib/components/NumberKeypad.js.map +1 -0
- package/lib/components/SudokuCell.d.ts +8 -0
- package/lib/components/SudokuCell.d.ts.map +1 -0
- package/lib/components/SudokuCell.js +240 -0
- package/lib/components/SudokuCell.js.map +1 -0
- package/lib/components/SudokuControls.d.ts +8 -0
- package/lib/components/SudokuControls.d.ts.map +1 -0
- package/lib/components/SudokuControls.js +140 -0
- package/lib/components/SudokuControls.js.map +1 -0
- package/lib/components/SudokuGrid.d.ts +8 -0
- package/lib/components/SudokuGrid.d.ts.map +1 -0
- package/lib/components/SudokuGrid.js +177 -0
- package/lib/components/SudokuGrid.js.map +1 -0
- package/lib/components/SudokuGridEntry.d.ts +8 -0
- package/lib/components/SudokuGridEntry.d.ts.map +1 -0
- package/lib/components/SudokuGridEntry.js +373 -0
- package/lib/components/SudokuGridEntry.js.map +1 -0
- package/lib/components/ValidationDisplay.d.ts +8 -0
- package/lib/components/ValidationDisplay.d.ts.map +1 -0
- package/lib/components/ValidationDisplay.js +95 -0
- package/lib/components/ValidationDisplay.js.map +1 -0
- package/lib/contexts/DiagnosticLoggerContext.d.ts +81 -0
- package/lib/contexts/DiagnosticLoggerContext.d.ts.map +1 -0
- package/lib/contexts/DiagnosticLoggerContext.js +98 -0
- package/lib/contexts/DiagnosticLoggerContext.js.map +1 -0
- package/lib/contexts/index.d.ts +3 -0
- package/lib/contexts/index.d.ts.map +1 -0
- package/lib/contexts/index.js +25 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/hooks/useCombinationElimination.d.ts +10 -0
- package/lib/hooks/useCombinationElimination.d.ts.map +1 -0
- package/lib/hooks/useCombinationElimination.js +123 -0
- package/lib/hooks/useCombinationElimination.js.map +1 -0
- package/lib/hooks/useKeyboardShortcut.d.ts +19 -0
- package/lib/hooks/useKeyboardShortcut.d.ts.map +1 -0
- package/lib/hooks/useKeyboardShortcut.js +55 -0
- package/lib/hooks/useKeyboardShortcut.js.map +1 -0
- package/lib/hooks/useKillerCombinations.d.ts +11 -0
- package/lib/hooks/useKillerCombinations.d.ts.map +1 -0
- package/lib/hooks/useKillerCombinations.js +65 -0
- package/lib/hooks/useKillerCombinations.js.map +1 -0
- package/lib/hooks/useLongPress.d.ts +31 -0
- package/lib/hooks/useLongPress.d.ts.map +1 -0
- package/lib/hooks/useLongPress.js +69 -0
- package/lib/hooks/useLongPress.js.map +1 -0
- package/lib/hooks/usePuzzleSession.d.ts +32 -0
- package/lib/hooks/usePuzzleSession.d.ts.map +1 -0
- package/lib/hooks/usePuzzleSession.js +398 -0
- package/lib/hooks/usePuzzleSession.js.map +1 -0
- package/lib/hooks/useResponsiveLayout.d.ts +44 -0
- package/lib/hooks/useResponsiveLayout.d.ts.map +1 -0
- package/lib/hooks/useResponsiveLayout.js +139 -0
- package/lib/hooks/useResponsiveLayout.js.map +1 -0
- package/lib/index.browser.d.ts +2 -0
- package/lib/index.browser.d.ts.map +1 -0
- package/lib/index.browser.js +26 -0
- package/lib/index.browser.js.map +1 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +49 -0
- package/lib/index.js.map +1 -0
- package/lib/test/fixtures/killerSudokuPuzzles.d.ts +36 -0
- package/lib/test/fixtures/killerSudokuPuzzles.d.ts.map +1 -0
- package/lib/test/fixtures/killerSudokuPuzzles.js +57 -0
- package/lib/test/fixtures/killerSudokuPuzzles.js.map +1 -0
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.d.ts +22 -0
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.d.ts.map +1 -0
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.js +116 -0
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/types/index.d.ts +234 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +25 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/CageLookupManager.d.ts +74 -0
- package/lib/utils/CageLookupManager.d.ts.map +1 -0
- package/lib/utils/CageLookupManager.js +283 -0
- package/lib/utils/CageLookupManager.js.map +1 -0
- package/lib/utils/CagePatternManager.d.ts +82 -0
- package/lib/utils/CagePatternManager.d.ts.map +1 -0
- package/lib/utils/CagePatternManager.js +139 -0
- package/lib/utils/CagePatternManager.js.map +1 -0
- package/lib/utils/puzzleDefinitionHelper.d.ts +25 -0
- package/lib/utils/puzzleDefinitionHelper.d.ts.map +1 -0
- package/lib/utils/puzzleDefinitionHelper.js +99 -0
- package/lib/utils/puzzleDefinitionHelper.js.map +1 -0
- package/lib-commonjs/components/CageOverlay.js +138 -0
- package/lib-commonjs/components/CageOverlay.js.map +1 -0
- package/lib-commonjs/components/CageSumIndicator.js +71 -0
- package/lib-commonjs/components/CageSumIndicator.js.map +1 -0
- package/lib-commonjs/components/CombinationCard.js +68 -0
- package/lib-commonjs/components/CombinationCard.js.map +1 -0
- package/lib-commonjs/components/CombinationGrid.js +56 -0
- package/lib-commonjs/components/CombinationGrid.js.map +1 -0
- package/lib-commonjs/components/CompactControlRibbon.js +146 -0
- package/lib-commonjs/components/CompactControlRibbon.js.map +1 -0
- package/lib-commonjs/components/DualKeypad.js +142 -0
- package/lib-commonjs/components/DualKeypad.js.map +1 -0
- package/lib-commonjs/components/KillerCombinationsExplorer.js +74 -0
- package/lib-commonjs/components/KillerCombinationsExplorer.js.map +1 -0
- package/lib-commonjs/components/KillerCombinationsModal.js +140 -0
- package/lib-commonjs/components/KillerCombinationsModal.js.map +1 -0
- package/lib-commonjs/components/KillerCombinationsPanel.js +84 -0
- package/lib-commonjs/components/KillerCombinationsPanel.js.map +1 -0
- package/lib-commonjs/components/NumberKeypad.js +186 -0
- package/lib-commonjs/components/NumberKeypad.js.map +1 -0
- package/lib-commonjs/components/SudokuCell.js +245 -0
- package/lib-commonjs/components/SudokuCell.js.map +1 -0
- package/lib-commonjs/components/SudokuControls.js +145 -0
- package/lib-commonjs/components/SudokuControls.js.map +1 -0
- package/lib-commonjs/components/SudokuGrid.js +182 -0
- package/lib-commonjs/components/SudokuGrid.js.map +1 -0
- package/lib-commonjs/components/SudokuGridEntry.js +378 -0
- package/lib-commonjs/components/SudokuGridEntry.js.map +1 -0
- package/lib-commonjs/components/ValidationDisplay.js +100 -0
- package/lib-commonjs/components/ValidationDisplay.js.map +1 -0
- package/lib-commonjs/contexts/DiagnosticLoggerContext.js +104 -0
- package/lib-commonjs/contexts/DiagnosticLoggerContext.js.map +1 -0
- package/lib-commonjs/contexts/index.js +32 -0
- package/lib-commonjs/contexts/index.js.map +1 -0
- package/lib-commonjs/hooks/useCombinationElimination.js +126 -0
- package/lib-commonjs/hooks/useCombinationElimination.js.map +1 -0
- package/lib-commonjs/hooks/useKeyboardShortcut.js +58 -0
- package/lib-commonjs/hooks/useKeyboardShortcut.js.map +1 -0
- package/lib-commonjs/hooks/useKillerCombinations.js +68 -0
- package/lib-commonjs/hooks/useKillerCombinations.js.map +1 -0
- package/lib-commonjs/hooks/useLongPress.js +72 -0
- package/lib-commonjs/hooks/useLongPress.js.map +1 -0
- package/lib-commonjs/hooks/usePuzzleSession.js +401 -0
- package/lib-commonjs/hooks/usePuzzleSession.js.map +1 -0
- package/lib-commonjs/hooks/useResponsiveLayout.js +142 -0
- package/lib-commonjs/hooks/useResponsiveLayout.js.map +1 -0
- package/lib-commonjs/index.browser.js +29 -0
- package/lib-commonjs/index.browser.js.map +1 -0
- package/lib-commonjs/index.js +73 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/test/fixtures/killerSudokuPuzzles.js +60 -0
- package/lib-commonjs/test/fixtures/killerSudokuPuzzles.js.map +1 -0
- package/lib-commonjs/test/unit/components/SudokuGridEntry.testHelpers.js +125 -0
- package/lib-commonjs/test/unit/components/SudokuGridEntry.testHelpers.js.map +1 -0
- package/lib-commonjs/types/index.js +26 -0
- package/lib-commonjs/types/index.js.map +1 -0
- package/lib-commonjs/utils/CageLookupManager.js +287 -0
- package/lib-commonjs/utils/CageLookupManager.js.map +1 -0
- package/lib-commonjs/utils/CagePatternManager.js +143 -0
- package/lib-commonjs/utils/CagePatternManager.js.map +1 -0
- package/lib-commonjs/utils/puzzleDefinitionHelper.js +103 -0
- package/lib-commonjs/utils/puzzleDefinitionHelper.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
25
|
+
import { NumberKeypad } from './NumberKeypad';
|
|
26
|
+
import { useResponsiveLayout } from '../hooks/useResponsiveLayout';
|
|
27
|
+
/**
|
|
28
|
+
* Dual keypad component with responsive layout for mobile and desktop sudoku input
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export const DualKeypad = ({ inputMode, onInputModeChange, onNotePress, onValuePress, onClearNotes, onClearValues, hasCellSelection, selectedCellCount, disabled = false, className, forceLayoutMode, showOverlayToggle = true }) => {
|
|
32
|
+
const responsiveLayout = useResponsiveLayout(forceLayoutMode);
|
|
33
|
+
const [isOverlayVisible, setIsOverlayVisible] = useState(false);
|
|
34
|
+
// Determine effective layout mode
|
|
35
|
+
const effectiveLayoutMode = forceLayoutMode || responsiveLayout.keypadLayoutMode;
|
|
36
|
+
// Should show the keypad based on layout mode and overlay state
|
|
37
|
+
const shouldShowKeypad = useMemo(() => {
|
|
38
|
+
if (effectiveLayoutMode === 'hidden')
|
|
39
|
+
return false;
|
|
40
|
+
if (effectiveLayoutMode === 'overlay')
|
|
41
|
+
return isOverlayVisible;
|
|
42
|
+
return true;
|
|
43
|
+
}, [effectiveLayoutMode, isOverlayVisible]);
|
|
44
|
+
// Handle note number press
|
|
45
|
+
const handleNotePress = useCallback((number) => {
|
|
46
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
47
|
+
if (disabled)
|
|
48
|
+
return;
|
|
49
|
+
onNotePress(number);
|
|
50
|
+
}, [disabled, onNotePress]);
|
|
51
|
+
// Handle value number press
|
|
52
|
+
const handleValuePress = useCallback((number) => {
|
|
53
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
54
|
+
if (disabled)
|
|
55
|
+
return;
|
|
56
|
+
onValuePress(number);
|
|
57
|
+
}, [disabled, onValuePress]);
|
|
58
|
+
// Handle clear notes
|
|
59
|
+
const handleClearNotes = useCallback(() => {
|
|
60
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
61
|
+
if (disabled)
|
|
62
|
+
return;
|
|
63
|
+
onClearNotes();
|
|
64
|
+
}, [disabled, onClearNotes]);
|
|
65
|
+
// Handle clear values
|
|
66
|
+
const handleClearValues = useCallback(() => {
|
|
67
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
68
|
+
if (disabled)
|
|
69
|
+
return;
|
|
70
|
+
onClearValues();
|
|
71
|
+
}, [disabled, onClearValues]);
|
|
72
|
+
// Toggle overlay visibility
|
|
73
|
+
const toggleOverlay = useCallback(() => {
|
|
74
|
+
setIsOverlayVisible((prev) => !prev);
|
|
75
|
+
}, []);
|
|
76
|
+
// Calculate whether to use compact mode
|
|
77
|
+
const useCompactMode = responsiveLayout.isSmallScreen || effectiveLayoutMode === 'overlay';
|
|
78
|
+
// Calculate container classes
|
|
79
|
+
const containerClasses = useMemo(() => {
|
|
80
|
+
const classes = ['flex gap-3 p-3'];
|
|
81
|
+
// Layout mode specific styles - FIXED: side-by-side should be flex-row
|
|
82
|
+
if (effectiveLayoutMode === 'side-by-side') {
|
|
83
|
+
classes.push('flex-row justify-center');
|
|
84
|
+
}
|
|
85
|
+
else if (effectiveLayoutMode === 'stacked') {
|
|
86
|
+
classes.push('flex-col');
|
|
87
|
+
}
|
|
88
|
+
else if (effectiveLayoutMode === 'overlay') {
|
|
89
|
+
classes.push('fixed bottom-4 left-1/2 transform -translate-x-1/2 z-50 bg-white rounded-lg shadow-lg border border-gray-200');
|
|
90
|
+
}
|
|
91
|
+
if (disabled)
|
|
92
|
+
classes.push('opacity-50 pointer-events-none');
|
|
93
|
+
if (useCompactMode)
|
|
94
|
+
classes.push('gap-2 p-2');
|
|
95
|
+
if (className)
|
|
96
|
+
classes.push(className);
|
|
97
|
+
return classes.join(' ');
|
|
98
|
+
}, [effectiveLayoutMode, disabled, useCompactMode, className]);
|
|
99
|
+
// Overlay backdrop
|
|
100
|
+
const overlayBackdrop = effectiveLayoutMode === 'overlay' && isOverlayVisible && (React.createElement("div", { className: "fixed inset-0 bg-black bg-opacity-30 z-40", onClick: toggleOverlay, "data-testid": "dual-keypad-overlay-backdrop" }));
|
|
101
|
+
// Show overlay toggle button for desktop/overlay mode
|
|
102
|
+
const overlayToggleButtonClasses = useMemo(() => {
|
|
103
|
+
const classes = [
|
|
104
|
+
'fixed bottom-4 right-4 z-50 w-12 h-12 rounded-full bg-blue-500 text-white flex items-center justify-center shadow-lg hover:bg-blue-600 transition-colors'
|
|
105
|
+
];
|
|
106
|
+
if (isOverlayVisible)
|
|
107
|
+
classes.push('bg-red-500 hover:bg-red-600');
|
|
108
|
+
if (disabled)
|
|
109
|
+
classes.push('opacity-50 cursor-not-allowed');
|
|
110
|
+
return classes.join(' ');
|
|
111
|
+
}, [isOverlayVisible, disabled]);
|
|
112
|
+
const overlayToggleButton = (effectiveLayoutMode === 'overlay' || effectiveLayoutMode === 'hidden') &&
|
|
113
|
+
showOverlayToggle && (React.createElement("button", { type: "button", onClick: toggleOverlay, disabled: disabled, className: overlayToggleButtonClasses, "aria-label": isOverlayVisible ? 'Hide number keypad' : 'Show number keypad', "data-testid": "dual-keypad-overlay-toggle" }, isOverlayVisible ? '✕' : '🔢'));
|
|
114
|
+
// Status text for multi-selection only (not single selection)
|
|
115
|
+
const statusText = useMemo(() => {
|
|
116
|
+
if (selectedCellCount > 1) {
|
|
117
|
+
return `${selectedCellCount} cells selected`;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}, [selectedCellCount]);
|
|
121
|
+
return (React.createElement(React.Fragment, null,
|
|
122
|
+
overlayBackdrop,
|
|
123
|
+
React.createElement("div", { className: containerClasses, style: { display: shouldShowKeypad ? 'flex' : 'none' }, "data-testid": "dual-keypad", role: "region", "aria-label": "Number input keypads" }, shouldShowKeypad && (React.createElement(React.Fragment, null,
|
|
124
|
+
statusText && (React.createElement("div", { className: `text-sm text-gray-600 text-center ${effectiveLayoutMode === 'stacked' ? 'mb-2' : 'mb-3'}` }, statusText)),
|
|
125
|
+
effectiveLayoutMode !== 'side-by-side' && effectiveLayoutMode !== 'stacked' && (React.createElement("div", { className: "flex justify-center gap-3 mb-3" },
|
|
126
|
+
React.createElement("button", { type: "button", onClick: () => onInputModeChange('notes'), disabled: disabled, className: `px-4 py-2 rounded-lg border-2 flex items-center gap-2 text-sm font-medium transition-colors ${inputMode === 'notes'
|
|
127
|
+
? 'bg-blue-500 text-white border-blue-600'
|
|
128
|
+
: 'bg-gray-100 border-gray-300 hover:bg-gray-200'} ${disabled ? 'opacity-50 cursor-not-allowed' : ''}` }, "\uD83D\uDCDD Notes"),
|
|
129
|
+
React.createElement("button", { type: "button", onClick: () => onInputModeChange('value'), disabled: disabled, className: `px-4 py-2 rounded-lg border-2 flex items-center gap-2 text-sm font-medium transition-colors ${inputMode === 'value'
|
|
130
|
+
? 'bg-blue-500 text-white border-blue-600'
|
|
131
|
+
: 'bg-gray-100 border-gray-300 hover:bg-gray-200'} ${disabled ? 'opacity-50 cursor-not-allowed' : ''}` }, "\u270F\uFE0F Values"))),
|
|
132
|
+
React.createElement(NumberKeypad, { keypadType: "notes", inputMode: inputMode, isActive: true, onNumberPress: handleNotePress, onClear: handleClearNotes, disabled: disabled || !hasCellSelection, compact: useCompactMode, className: "flex-1" }),
|
|
133
|
+
React.createElement(NumberKeypad, { keypadType: "values", inputMode: inputMode, isActive: true, onNumberPress: handleValuePress, onClear: handleClearValues, disabled: disabled || !hasCellSelection, compact: useCompactMode, className: "flex-1" }),
|
|
134
|
+
effectiveLayoutMode === 'overlay' && (React.createElement("button", { type: "button", onClick: toggleOverlay, className: "absolute top-2 right-2 w-8 h-8 rounded-full bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors", "aria-label": "Close keypad overlay", "data-testid": "dual-keypad-close" }, "\u2715"))))),
|
|
135
|
+
overlayToggleButton));
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=DualKeypad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DualKeypad.js","sourceRoot":"","sources":["../../src/components/DualKeypad.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAoB,MAAM,8BAA8B,CAAC;AA4CrF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAA+B,CAAC,EACrD,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,eAAe,EACf,iBAAiB,GAAG,IAAI,EACzB,EAAE,EAAE;IACH,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,kCAAkC;IAClC,MAAM,mBAAmB,GAAG,eAAe,IAAI,gBAAgB,CAAC,gBAAgB,CAAC;IAEjF,gEAAgE;IAChE,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,IAAI,mBAAmB,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACnD,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AmB,aAGxB,CACV,CACA,CACJ,CACG;QAEL,mBAAmB,CACnB,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { InputMode } from '../types';\nimport { NumberKeypad } from './NumberKeypad';\nimport { useResponsiveLayout, KeypadLayoutMode } from '../hooks/useResponsiveLayout';\n\n/**\n * Props for the DualKeypad component\n * @public\n */\nexport interface IDualKeypadProps {\n /** Current input mode */\n readonly inputMode: InputMode;\n\n /** Callback when input mode changes */\n readonly onInputModeChange: (mode: InputMode) => void;\n\n /** Callback when a number is pressed for notes */\n readonly onNotePress: (number: number) => void;\n\n /** Callback when a number is pressed for values */\n readonly onValuePress: (number: number) => void;\n\n /** Callback when clear notes is pressed */\n readonly onClearNotes: () => void;\n\n /** Callback when clear values is pressed */\n readonly onClearValues: () => void;\n\n /** Whether any cells are selected */\n readonly hasCellSelection: boolean;\n\n /** Number of selected cells */\n readonly selectedCellCount: number;\n\n /** Whether the keypad is disabled */\n readonly disabled?: boolean;\n\n /** Additional CSS class name */\n readonly className?: string;\n\n /** Force a specific layout mode (overrides responsive detection) */\n readonly forceLayoutMode?: KeypadLayoutMode;\n\n /** Whether to show the overlay toggle for desktop */\n readonly showOverlayToggle?: boolean;\n}\n\n/**\n * Dual keypad component with responsive layout for mobile and desktop sudoku input\n * @public\n */\nexport const DualKeypad: React.FC<IDualKeypadProps> = ({\n inputMode,\n onInputModeChange,\n onNotePress,\n onValuePress,\n onClearNotes,\n onClearValues,\n hasCellSelection,\n selectedCellCount,\n disabled = false,\n className,\n forceLayoutMode,\n showOverlayToggle = true\n}) => {\n const responsiveLayout = useResponsiveLayout(forceLayoutMode);\n const [isOverlayVisible, setIsOverlayVisible] = useState(false);\n\n // Determine effective layout mode\n const effectiveLayoutMode = forceLayoutMode || responsiveLayout.keypadLayoutMode;\n\n // Should show the keypad based on layout mode and overlay state\n const shouldShowKeypad = useMemo(() => {\n if (effectiveLayoutMode === 'hidden') return false;\n if (effectiveLayoutMode === 'overlay') return isOverlayVisible;\n return true;\n }, [effectiveLayoutMode, isOverlayVisible]);\n\n // Handle note number press\n const handleNotePress = useCallback(\n (number: number) => {\n /* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */\n if (disabled) return;\n onNotePress(number);\n },\n [disabled, onNotePress]\n );\n\n // Handle value number press\n const handleValuePress = useCallback(\n (number: number) => {\n /* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */\n if (disabled) return;\n onValuePress(number);\n },\n [disabled, onValuePress]\n );\n\n // Handle clear notes\n const handleClearNotes = useCallback(() => {\n /* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */\n if (disabled) return;\n onClearNotes();\n }, [disabled, onClearNotes]);\n\n // Handle clear values\n const handleClearValues = useCallback(() => {\n /* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */\n if (disabled) return;\n onClearValues();\n }, [disabled, onClearValues]);\n\n // Toggle overlay visibility\n const toggleOverlay = useCallback(() => {\n setIsOverlayVisible((prev) => !prev);\n }, []);\n\n // Calculate whether to use compact mode\n const useCompactMode = responsiveLayout.isSmallScreen || effectiveLayoutMode === 'overlay';\n\n // Calculate container classes\n const containerClasses = useMemo(() => {\n const classes = ['flex gap-3 p-3'];\n\n // Layout mode specific styles - FIXED: side-by-side should be flex-row\n if (effectiveLayoutMode === 'side-by-side') {\n classes.push('flex-row justify-center');\n } else if (effectiveLayoutMode === 'stacked') {\n classes.push('flex-col');\n } else if (effectiveLayoutMode === 'overlay') {\n classes.push(\n 'fixed bottom-4 left-1/2 transform -translate-x-1/2 z-50 bg-white rounded-lg shadow-lg border border-gray-200'\n );\n }\n\n if (disabled) classes.push('opacity-50 pointer-events-none');\n if (useCompactMode) classes.push('gap-2 p-2');\n if (className) classes.push(className);\n\n return classes.join(' ');\n }, [effectiveLayoutMode, disabled, useCompactMode, className]);\n\n // Overlay backdrop\n const overlayBackdrop = effectiveLayoutMode === 'overlay' && isOverlayVisible && (\n <div\n className=\"fixed inset-0 bg-black bg-opacity-30 z-40\"\n onClick={toggleOverlay}\n data-testid=\"dual-keypad-overlay-backdrop\"\n />\n );\n\n // Show overlay toggle button for desktop/overlay mode\n const overlayToggleButtonClasses = useMemo(() => {\n const classes = [\n 'fixed bottom-4 right-4 z-50 w-12 h-12 rounded-full bg-blue-500 text-white flex items-center justify-center shadow-lg hover:bg-blue-600 transition-colors'\n ];\n if (isOverlayVisible) classes.push('bg-red-500 hover:bg-red-600');\n if (disabled) classes.push('opacity-50 cursor-not-allowed');\n return classes.join(' ');\n }, [isOverlayVisible, disabled]);\n\n const overlayToggleButton = (effectiveLayoutMode === 'overlay' || effectiveLayoutMode === 'hidden') &&\n showOverlayToggle && (\n <button\n type=\"button\"\n onClick={toggleOverlay}\n disabled={disabled}\n className={overlayToggleButtonClasses}\n aria-label={isOverlayVisible ? 'Hide number keypad' : 'Show number keypad'}\n data-testid=\"dual-keypad-overlay-toggle\"\n >\n {isOverlayVisible ? '✕' : '🔢'}\n </button>\n );\n\n // Status text for multi-selection only (not single selection)\n const statusText = useMemo(() => {\n if (selectedCellCount > 1) {\n return `${selectedCellCount} cells selected`;\n }\n return null;\n }, [selectedCellCount]);\n\n return (\n <>\n {overlayBackdrop}\n\n <div\n className={containerClasses}\n style={{ display: shouldShowKeypad ? 'flex' : 'none' }}\n data-testid=\"dual-keypad\"\n role=\"region\"\n aria-label=\"Number input keypads\"\n >\n {shouldShowKeypad && (\n <>\n {/* Status text */}\n {statusText && (\n <div\n className={`text-sm text-gray-600 text-center ${\n effectiveLayoutMode === 'stacked' ? 'mb-2' : 'mb-3'\n }`}\n >\n {statusText}\n </div>\n )}\n\n {/* Mode Toggle - only show for overlay/hidden modes (no toggle needed for side-by-side) */}\n {effectiveLayoutMode !== 'side-by-side' && effectiveLayoutMode !== 'stacked' && (\n <div className=\"flex justify-center gap-3 mb-3\">\n {/* c8 ignore next 9 - functional code tested but coverage intermittently missed */}\n <button\n type=\"button\"\n onClick={() => onInputModeChange('notes')}\n disabled={disabled}\n className={`px-4 py-2 rounded-lg border-2 flex items-center gap-2 text-sm font-medium transition-colors ${\n inputMode === 'notes'\n ? 'bg-blue-500 text-white border-blue-600'\n : 'bg-gray-100 border-gray-300 hover:bg-gray-200'\n } ${disabled ? 'opacity-50 cursor-not-allowed' : ''}`}\n >\n 📝 Notes\n </button>\n {/* c8 ignore next 9 - functional code tested but coverage intermittently missed */}\n <button\n type=\"button\"\n onClick={() => onInputModeChange('value')}\n disabled={disabled}\n className={`px-4 py-2 rounded-lg border-2 flex items-center gap-2 text-sm font-medium transition-colors ${\n inputMode === 'value'\n ? 'bg-blue-500 text-white border-blue-600'\n : 'bg-gray-100 border-gray-300 hover:bg-gray-200'\n } ${disabled ? 'opacity-50 cursor-not-allowed' : ''}`}\n >\n ✏️ Values\n </button>\n </div>\n )}\n\n {/* Notes Keypad */}\n <NumberKeypad\n keypadType=\"notes\"\n inputMode={inputMode}\n isActive={true}\n onNumberPress={handleNotePress}\n onClear={handleClearNotes}\n disabled={disabled || !hasCellSelection}\n compact={useCompactMode}\n className=\"flex-1\"\n />\n\n {/* Values Keypad */}\n <NumberKeypad\n keypadType=\"values\"\n inputMode={inputMode}\n isActive={true}\n onNumberPress={handleValuePress}\n onClear={handleClearValues}\n disabled={disabled || !hasCellSelection}\n compact={useCompactMode}\n className=\"flex-1\"\n />\n\n {/* Close button for overlay */}\n {effectiveLayoutMode === 'overlay' && (\n <button\n type=\"button\"\n onClick={toggleOverlay}\n className=\"absolute top-2 right-2 w-8 h-8 rounded-full bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors\"\n aria-label=\"Close keypad overlay\"\n data-testid=\"dual-keypad-close\"\n >\n ✕\n </button>\n )}\n </>\n )}\n </div>\n\n {overlayToggleButton}\n </>\n );\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IKillerCombinationsExplorerProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Main killer combinations explorer container component
|
|
5
|
+
* Automatically switches between panel (desktop) and modal (mobile) based on screen size
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const KillerCombinationsExplorer: React.FC<IKillerCombinationsExplorerProps>;
|
|
9
|
+
//# sourceMappingURL=KillerCombinationsExplorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsExplorer.d.ts","sourceRoot":"","sources":["../../src/components/KillerCombinationsExplorer.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,gCAAgC,EAA2B,MAAM,UAAU,CAAC;AAOrF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,gCAAgC,CAoEjF,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { useMemo } from 'react';
|
|
25
|
+
import { useKillerCombinations } from '../hooks/useKillerCombinations';
|
|
26
|
+
import { useCombinationElimination } from '../hooks/useCombinationElimination';
|
|
27
|
+
import { useResponsiveLayout } from '../hooks/useResponsiveLayout';
|
|
28
|
+
import { KillerCombinationsPanel } from './KillerCombinationsPanel';
|
|
29
|
+
import { KillerCombinationsModal } from './KillerCombinationsModal';
|
|
30
|
+
/**
|
|
31
|
+
* Main killer combinations explorer container component
|
|
32
|
+
* Automatically switches between panel (desktop) and modal (mobile) based on screen size
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export const KillerCombinationsExplorer = ({ selectedCage, puzzleId, isOpen, onClose, mobileBreakpoint = 1024, className }) => {
|
|
36
|
+
const { screenWidth } = useResponsiveLayout();
|
|
37
|
+
// Determine display mode based on screen width
|
|
38
|
+
const mode = screenWidth >= mobileBreakpoint ? 'panel' : 'modal';
|
|
39
|
+
// Get combinations for the selected cage
|
|
40
|
+
const combinationsResult = useKillerCombinations(selectedCage);
|
|
41
|
+
// Get cage ID for storage
|
|
42
|
+
const cageId = selectedCage?.id;
|
|
43
|
+
// Get elimination state
|
|
44
|
+
const { eliminatedSignatures, toggleElimination } = useCombinationElimination(puzzleId, cageId);
|
|
45
|
+
// Merge combinations with elimination state
|
|
46
|
+
const displayCombinations = useMemo(() => {
|
|
47
|
+
if (combinationsResult.isFailure()) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return combinationsResult.value.map((combo) => ({
|
|
51
|
+
...combo,
|
|
52
|
+
isEliminated: eliminatedSignatures.has(combo.signature)
|
|
53
|
+
}));
|
|
54
|
+
}, [combinationsResult, eliminatedSignatures]);
|
|
55
|
+
// Don't render if not open or no cage selected
|
|
56
|
+
if (!isOpen || !selectedCage) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
// Don't render if combinations failed to load
|
|
60
|
+
if (combinationsResult.isFailure()) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
// Render panel or modal based on mode
|
|
64
|
+
if (mode === 'panel') {
|
|
65
|
+
return (React.createElement(KillerCombinationsPanel, { cage: selectedCage, combinations: displayCombinations, onToggle: toggleElimination, onClose: onClose, isOpen: isOpen, className: className }));
|
|
66
|
+
}
|
|
67
|
+
return (React.createElement(KillerCombinationsModal, { cage: selectedCage, combinations: displayCombinations, onToggle: toggleElimination, onClose: onClose, isOpen: isOpen, className: className }));
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=KillerCombinationsExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsExplorer.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsExplorer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA+C,CAAC,EACrF,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,gBAAgB,GAAG,IAAI,EACvB,SAAS,EACV,EAAE,EAAE;IACH,MAAM,EAAE,WAAW,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAE9C,+CAA+C;IAC/C,MAAM,IAAI,GAA4B,WAAW,IAAI,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAE1F,yCAAyC;IACzC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAE/D,0BAA0B;IAC1B,MAAM,MAAM,GAAG,YAAY,EAAE,EAAE,CAAC;IAEhC,wBAAwB;IACxB,MAAM,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,GAAG,yBAAyB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEhG,4CAA4C;IAC5C,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,EAAE;QACvC,IAAI,kBAAkB,CAAC,SAAS,EAAE,EAAE,CAAC;YACnC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC9C,GAAG,KAAK;YACR,YAAY,EAAE,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC;SACxD,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAE/C,+CAA+C;IAC/C,IAAI,CAAC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8CAA8C;IAC9C,IAAI,kBAAkB,CAAC,SAAS,EAAE,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sCAAsC;IACtC,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,OAAO,CACL,oBAAC,uBAAuB,IACtB,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,uBAAuB,IACtB,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport React, { useMemo } from 'react';\nimport { IKillerCombinationsExplorerProps, IKillerCombinationsMode } from '../types';\nimport { useKillerCombinations } from '../hooks/useKillerCombinations';\nimport { useCombinationElimination } from '../hooks/useCombinationElimination';\nimport { useResponsiveLayout } from '../hooks/useResponsiveLayout';\nimport { KillerCombinationsPanel } from './KillerCombinationsPanel';\nimport { KillerCombinationsModal } from './KillerCombinationsModal';\n\n/**\n * Main killer combinations explorer container component\n * Automatically switches between panel (desktop) and modal (mobile) based on screen size\n * @public\n */\nexport const KillerCombinationsExplorer: React.FC<IKillerCombinationsExplorerProps> = ({\n selectedCage,\n puzzleId,\n isOpen,\n onClose,\n mobileBreakpoint = 1024,\n className\n}) => {\n const { screenWidth } = useResponsiveLayout();\n\n // Determine display mode based on screen width\n const mode: IKillerCombinationsMode = screenWidth >= mobileBreakpoint ? 'panel' : 'modal';\n\n // Get combinations for the selected cage\n const combinationsResult = useKillerCombinations(selectedCage);\n\n // Get cage ID for storage\n const cageId = selectedCage?.id;\n\n // Get elimination state\n const { eliminatedSignatures, toggleElimination } = useCombinationElimination(puzzleId, cageId);\n\n // Merge combinations with elimination state\n const displayCombinations = useMemo(() => {\n if (combinationsResult.isFailure()) {\n return [];\n }\n\n return combinationsResult.value.map((combo) => ({\n ...combo,\n isEliminated: eliminatedSignatures.has(combo.signature)\n }));\n }, [combinationsResult, eliminatedSignatures]);\n\n // Don't render if not open or no cage selected\n if (!isOpen || !selectedCage) {\n return null;\n }\n\n // Don't render if combinations failed to load\n if (combinationsResult.isFailure()) {\n return null;\n }\n\n // Render panel or modal based on mode\n if (mode === 'panel') {\n return (\n <KillerCombinationsPanel\n cage={selectedCage}\n combinations={displayCombinations}\n onToggle={toggleElimination}\n onClose={onClose}\n isOpen={isOpen}\n className={className}\n />\n );\n }\n\n return (\n <KillerCombinationsModal\n cage={selectedCage}\n combinations={displayCombinations}\n onToggle={toggleElimination}\n onClose={onClose}\n isOpen={isOpen}\n className={className}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ICage } from '@fgv/ts-sudoku-lib';
|
|
3
|
+
import { ICombinationDisplayInfo } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the KillerCombinationsModal component
|
|
6
|
+
*/
|
|
7
|
+
export interface IKillerCombinationsModalProps {
|
|
8
|
+
readonly cage: ICage;
|
|
9
|
+
readonly combinations: ICombinationDisplayInfo[];
|
|
10
|
+
readonly onToggle: (signature: string) => void;
|
|
11
|
+
readonly onClose: () => void;
|
|
12
|
+
readonly isOpen: boolean;
|
|
13
|
+
readonly className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Mobile modal variant for killer combinations explorer
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare const KillerCombinationsModal: React.FC<IKillerCombinationsModalProps>;
|
|
20
|
+
//# sourceMappingURL=KillerCombinationsModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsModal.d.ts","sourceRoot":"","sources":["../../src/components/KillerCombinationsModal.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,EAAE,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CAuJ3E,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { useEffect, useRef } from 'react';
|
|
25
|
+
import { CombinationGrid } from './CombinationGrid';
|
|
26
|
+
/**
|
|
27
|
+
* Mobile modal variant for killer combinations explorer
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export const KillerCombinationsModal = ({ cage, combinations, onToggle, onClose, isOpen, className }) => {
|
|
31
|
+
const modalRef = useRef(null);
|
|
32
|
+
// Handle Escape key to close
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const handleEscape = (event) => {
|
|
35
|
+
if (event.key === 'Escape') {
|
|
36
|
+
onClose();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
if (isOpen) {
|
|
40
|
+
window.addEventListener('keydown', handleEscape);
|
|
41
|
+
return () => window.removeEventListener('keydown', handleEscape);
|
|
42
|
+
}
|
|
43
|
+
}, [isOpen, onClose]);
|
|
44
|
+
// Lock body scroll when modal is open
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (isOpen) {
|
|
47
|
+
const originalOverflow = document.body.style.overflow;
|
|
48
|
+
document.body.style.overflow = 'hidden';
|
|
49
|
+
return () => {
|
|
50
|
+
document.body.style.overflow = originalOverflow;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}, [isOpen]);
|
|
54
|
+
// Focus trap and initial focus
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (isOpen && modalRef.current) {
|
|
57
|
+
const focusableElements = modalRef.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
58
|
+
const firstElement = focusableElements[0];
|
|
59
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
60
|
+
firstElement?.focus();
|
|
61
|
+
const handleTab = (event) => {
|
|
62
|
+
if (event.key === 'Tab') {
|
|
63
|
+
if (event.shiftKey) {
|
|
64
|
+
if (document.activeElement === firstElement) {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
lastElement?.focus();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (document.activeElement === lastElement) {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
firstElement?.focus();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
window.addEventListener('keydown', handleTab);
|
|
78
|
+
return () => window.removeEventListener('keydown', handleTab);
|
|
79
|
+
}
|
|
80
|
+
}, [isOpen]);
|
|
81
|
+
if (!isOpen) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const activeCount = combinations.filter((c) => !c.isEliminated).length;
|
|
85
|
+
const totalCount = combinations.length;
|
|
86
|
+
/* c8 ignore next 1 - defense in depth */
|
|
87
|
+
const opacity = isOpen ? 'opacity-100' : 'opacity-0 pointer-events-none';
|
|
88
|
+
const overlayClasses = [
|
|
89
|
+
'fixed inset-0 z-[9999]',
|
|
90
|
+
'flex items-end sm:items-center justify-center',
|
|
91
|
+
'p-4',
|
|
92
|
+
'bg-black bg-opacity-40',
|
|
93
|
+
'transition-opacity duration-300',
|
|
94
|
+
opacity
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(' ');
|
|
98
|
+
/* c8 ignore next 1 - defense in depth */
|
|
99
|
+
const translation = isOpen ? 'translate-y-0' : 'translate-y-full';
|
|
100
|
+
const dialogClasses = [
|
|
101
|
+
'bg-white dark:bg-gray-900',
|
|
102
|
+
'rounded-t-2xl sm:rounded-2xl',
|
|
103
|
+
'w-full max-w-lg',
|
|
104
|
+
'max-h-[85vh]',
|
|
105
|
+
'overflow-hidden',
|
|
106
|
+
'flex flex-col',
|
|
107
|
+
'shadow-2xl',
|
|
108
|
+
'transform transition-transform duration-300',
|
|
109
|
+
translation,
|
|
110
|
+
className
|
|
111
|
+
]
|
|
112
|
+
.filter(Boolean)
|
|
113
|
+
.join(' ');
|
|
114
|
+
return (React.createElement("div", { className: overlayClasses, onClick: onClose, role: "presentation" },
|
|
115
|
+
React.createElement("div", { ref: modalRef, className: dialogClasses, onClick: (e) => e.stopPropagation(), role: "dialog", "aria-modal": "true", "aria-labelledby": "modal-title", "aria-describedby": "modal-description" },
|
|
116
|
+
React.createElement("div", { className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700" },
|
|
117
|
+
React.createElement("div", null,
|
|
118
|
+
React.createElement("h2", { id: "modal-title", className: "text-lg font-semibold text-gray-900 dark:text-gray-100" }, "Combinations"),
|
|
119
|
+
React.createElement("p", { id: "modal-description", className: "text-sm text-gray-500 dark:text-gray-400" },
|
|
120
|
+
cage.numCells,
|
|
121
|
+
" cells, sum ",
|
|
122
|
+
cage.total)),
|
|
123
|
+
React.createElement("button", { type: "button", onClick: onClose, className: "p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors", "aria-label": "Close combinations modal" },
|
|
124
|
+
React.createElement("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
125
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })))),
|
|
126
|
+
React.createElement("div", { className: "px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700" },
|
|
127
|
+
React.createElement("p", { className: "text-xs text-gray-600 dark:text-gray-400" },
|
|
128
|
+
activeCount,
|
|
129
|
+
" of ",
|
|
130
|
+
totalCount,
|
|
131
|
+
" combinations possible")),
|
|
132
|
+
React.createElement("div", { className: "flex-1 overflow-hidden" },
|
|
133
|
+
React.createElement(CombinationGrid, { combinations: combinations, onToggle: onToggle, mode: "modal" })))));
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=KillerCombinationsModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsModal.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsModal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAcpD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA4C,CAAC,EAC/E,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,SAAS,EACV,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAE9C,6BAA6B;IAC7B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAQ,EAAE;YAClD,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC3B,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YACjD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtB,sCAAsC;IACtC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YACtD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,Q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aAAa,EAAC,SAAS,EAAC,wDAAwD,mBAElF;oBACL,2BAAG,EAAE,EAAC,mBAAmB,EAAC,SAAS,EAAC,0CAA0C;wBAC3E,IAAI,CAAC,QAAQ;;wBAAc,IAAI,CAAC,KAAK,CACpC,CACA;gBACN,gCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,2EAA2E,gBAC1E,0BAA0B;oBAErC,6BAAK,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW;wBAC5E,8BAAM,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAC,sBAAsB,GAAG,CAC1F,CACC,CACL;YAGN,6BAAK,SAAS,EAAC,qFAAqF;gBAClG,2BAAG,SAAS,EAAC,0CAA0C;oBACpD,WAAW;;oBAAM,UAAU;6CAC1B,CACA;YAGN,6BAAK,SAAS,EAAC,wBAAwB;gBACrC,oBAAC,eAAe,IAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,CAC5E,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport React, { useEffect, useRef } from 'react';\nimport { ICage } from '@fgv/ts-sudoku-lib';\nimport { ICombinationDisplayInfo } from '../types';\nimport { CombinationGrid } from './CombinationGrid';\n\n/**\n * Props for the KillerCombinationsModal component\n */\nexport interface IKillerCombinationsModalProps {\n readonly cage: ICage;\n readonly combinations: ICombinationDisplayInfo[];\n readonly onToggle: (signature: string) => void;\n readonly onClose: () => void;\n readonly isOpen: boolean;\n readonly className?: string;\n}\n\n/**\n * Mobile modal variant for killer combinations explorer\n * @public\n */\nexport const KillerCombinationsModal: React.FC<IKillerCombinationsModalProps> = ({\n cage,\n combinations,\n onToggle,\n onClose,\n isOpen,\n className\n}) => {\n const modalRef = useRef<HTMLDivElement>(null);\n\n // Handle Escape key to close\n useEffect(() => {\n const handleEscape = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') {\n onClose();\n }\n };\n\n if (isOpen) {\n window.addEventListener('keydown', handleEscape);\n return () => window.removeEventListener('keydown', handleEscape);\n }\n }, [isOpen, onClose]);\n\n // Lock body scroll when modal is open\n useEffect(() => {\n if (isOpen) {\n const originalOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n return () => {\n document.body.style.overflow = originalOverflow;\n };\n }\n }, [isOpen]);\n\n // Focus trap and initial focus\n useEffect(() => {\n if (isOpen && modalRef.current) {\n const focusableElements = modalRef.current.querySelectorAll<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n );\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n firstElement?.focus();\n\n const handleTab = (event: KeyboardEvent): void => {\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n if (document.activeElement === firstElement) {\n event.preventDefault();\n lastElement?.focus();\n }\n } else {\n if (document.activeElement === lastElement) {\n event.preventDefault();\n firstElement?.focus();\n }\n }\n }\n };\n\n window.addEventListener('keydown', handleTab);\n return () => window.removeEventListener('keydown', handleTab);\n }\n }, [isOpen]);\n\n if (!isOpen) {\n return null;\n }\n\n const activeCount = combinations.filter((c) => !c.isEliminated).length;\n const totalCount = combinations.length;\n\n /* c8 ignore next 1 - defense in depth */\n const opacity = isOpen ? 'opacity-100' : 'opacity-0 pointer-events-none';\n const overlayClasses = [\n 'fixed inset-0 z-[9999]',\n 'flex items-end sm:items-center justify-center',\n 'p-4',\n 'bg-black bg-opacity-40',\n 'transition-opacity duration-300',\n opacity\n ]\n .filter(Boolean)\n .join(' ');\n\n /* c8 ignore next 1 - defense in depth */\n const translation = isOpen ? 'translate-y-0' : 'translate-y-full';\n const dialogClasses = [\n 'bg-white dark:bg-gray-900',\n 'rounded-t-2xl sm:rounded-2xl',\n 'w-full max-w-lg',\n 'max-h-[85vh]',\n 'overflow-hidden',\n 'flex flex-col',\n 'shadow-2xl',\n 'transform transition-transform duration-300',\n translation,\n className\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div className={overlayClasses} onClick={onClose} role=\"presentation\">\n <div\n ref={modalRef}\n className={dialogClasses}\n onClick={(e) => e.stopPropagation()}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"modal-title\"\n aria-describedby=\"modal-description\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700\">\n <div>\n <h2 id=\"modal-title\" className=\"text-lg font-semibold text-gray-900 dark:text-gray-100\">\n Combinations\n </h2>\n <p id=\"modal-description\" className=\"text-sm text-gray-500 dark:text-gray-400\">\n {cage.numCells} cells, sum {cage.total}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors\"\n aria-label=\"Close combinations modal\"\n >\n <svg className=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n </div>\n\n {/* Stats */}\n <div className=\"px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700\">\n <p className=\"text-xs text-gray-600 dark:text-gray-400\">\n {activeCount} of {totalCount} combinations possible\n </p>\n </div>\n\n {/* Combinations Grid */}\n <div className=\"flex-1 overflow-hidden\">\n <CombinationGrid combinations={combinations} onToggle={onToggle} mode=\"modal\" />\n </div>\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ICage } from '@fgv/ts-sudoku-lib';
|
|
3
|
+
import { ICombinationDisplayInfo } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the KillerCombinationsPanel component
|
|
6
|
+
*/
|
|
7
|
+
export interface IKillerCombinationsPanelProps {
|
|
8
|
+
readonly cage: ICage;
|
|
9
|
+
readonly combinations: ICombinationDisplayInfo[];
|
|
10
|
+
readonly onToggle: (signature: string) => void;
|
|
11
|
+
readonly onClose: () => void;
|
|
12
|
+
readonly isOpen: boolean;
|
|
13
|
+
readonly className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Desktop panel variant for killer combinations explorer
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare const KillerCombinationsPanel: React.FC<IKillerCombinationsPanelProps>;
|
|
20
|
+
//# sourceMappingURL=KillerCombinationsPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsPanel.d.ts","sourceRoot":"","sources":["../../src/components/KillerCombinationsPanel.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,EAAE,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CA2E3E,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { useEffect } from 'react';
|
|
25
|
+
import { CombinationGrid } from './CombinationGrid';
|
|
26
|
+
/**
|
|
27
|
+
* Desktop panel variant for killer combinations explorer
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export const KillerCombinationsPanel = ({ cage, combinations, onToggle, onClose, isOpen, className }) => {
|
|
31
|
+
// Handle Escape key to close
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const handleEscape = (event) => {
|
|
34
|
+
if (event.key === 'Escape') {
|
|
35
|
+
onClose();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (isOpen) {
|
|
39
|
+
window.addEventListener('keydown', handleEscape);
|
|
40
|
+
return () => window.removeEventListener('keydown', handleEscape);
|
|
41
|
+
}
|
|
42
|
+
}, [isOpen, onClose]);
|
|
43
|
+
const panelClasses = [
|
|
44
|
+
'fixed right-0 top-0 bottom-0',
|
|
45
|
+
'w-96 max-w-md',
|
|
46
|
+
'bg-white dark:bg-gray-900',
|
|
47
|
+
'border-l border-gray-200 dark:border-gray-700',
|
|
48
|
+
'shadow-2xl',
|
|
49
|
+
'transform transition-transform duration-300 ease-in-out',
|
|
50
|
+
isOpen ? 'translate-x-0' : 'translate-x-full',
|
|
51
|
+
'z-[9999]',
|
|
52
|
+
'flex flex-col',
|
|
53
|
+
className
|
|
54
|
+
]
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join(' ');
|
|
57
|
+
const activeCount = combinations.filter((c) => !c.isEliminated).length;
|
|
58
|
+
const totalCount = combinations.length;
|
|
59
|
+
return (React.createElement("aside", { className: panelClasses, role: "complementary", "aria-label": "Killer Sudoku Combinations Explorer" },
|
|
60
|
+
React.createElement("div", { className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700" },
|
|
61
|
+
React.createElement("div", null,
|
|
62
|
+
React.createElement("h2", { className: "text-lg font-semibold text-gray-900 dark:text-gray-100" }, "Combinations"),
|
|
63
|
+
React.createElement("p", { className: "text-sm text-gray-500 dark:text-gray-400" },
|
|
64
|
+
cage.numCells,
|
|
65
|
+
" cells, sum ",
|
|
66
|
+
cage.total)),
|
|
67
|
+
React.createElement("button", { type: "button", onClick: onClose, className: "p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors", "aria-label": "Close combinations panel" },
|
|
68
|
+
React.createElement("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
69
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })))),
|
|
70
|
+
React.createElement("div", { className: "px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700" },
|
|
71
|
+
React.createElement("p", { className: "text-xs text-gray-600 dark:text-gray-400" },
|
|
72
|
+
activeCount,
|
|
73
|
+
" of ",
|
|
74
|
+
totalCount,
|
|
75
|
+
" combinations possible")),
|
|
76
|
+
React.createElement("div", { className: "flex-1 overflow-hidden" },
|
|
77
|
+
React.createElement(CombinationGrid, { combinations: combinations, onToggle: onToggle, mode: "panel" }))));
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=KillerCombinationsPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsPanel.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;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BAAY,qCAAqC;QAEnG,6BAAK,SAAS,EAAC,qFAAqF;YAClG;gBACE,4BAAI,SAAS,EAAC,wDAAwD,mBAAkB;gBACxF,2BAAG,SAAS,EAAC,0CAA0C;oBACpD,IAAI,CAAC,QAAQ;;oBAAc,IAAI,CAAC,KAAK,CACpC,CACA;YACN,gCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,2EAA2E,gBAC1E,0BAA0B;gBAErC,6BAAK,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW;oBAC5E,8BAAM,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAC,sBAAsB,GAAG,CAC1F,CACC,CACL;QAGN,6BAAK,SAAS,EAAC,qFAAqF;YAClG,2BAAG,SAAS,EAAC,0CAA0C;gBACpD,WAAW;;gBAAM,UAAU;yCAC1B,CACA;QAGN,6BAAK,SAAS,EAAC,wBAAwB;YACrC,oBAAC,eAAe,IAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,CAC5E,CACA,CACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport React, { useEffect } from 'react';\nimport { ICage } from '@fgv/ts-sudoku-lib';\nimport { ICombinationDisplayInfo } from '../types';\nimport { CombinationGrid } from './CombinationGrid';\n\n/**\n * Props for the KillerCombinationsPanel component\n */\nexport interface IKillerCombinationsPanelProps {\n readonly cage: ICage;\n readonly combinations: ICombinationDisplayInfo[];\n readonly onToggle: (signature: string) => void;\n readonly onClose: () => void;\n readonly isOpen: boolean;\n readonly className?: string;\n}\n\n/**\n * Desktop panel variant for killer combinations explorer\n * @public\n */\nexport const KillerCombinationsPanel: React.FC<IKillerCombinationsPanelProps> = ({\n cage,\n combinations,\n onToggle,\n onClose,\n isOpen,\n className\n}) => {\n // Handle Escape key to close\n useEffect(() => {\n const handleEscape = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') {\n onClose();\n }\n };\n\n if (isOpen) {\n window.addEventListener('keydown', handleEscape);\n return () => window.removeEventListener('keydown', handleEscape);\n }\n }, [isOpen, onClose]);\n\n const panelClasses = [\n 'fixed right-0 top-0 bottom-0',\n 'w-96 max-w-md',\n 'bg-white dark:bg-gray-900',\n 'border-l border-gray-200 dark:border-gray-700',\n 'shadow-2xl',\n 'transform transition-transform duration-300 ease-in-out',\n isOpen ? 'translate-x-0' : 'translate-x-full',\n 'z-[9999]',\n 'flex flex-col',\n className\n ]\n .filter(Boolean)\n .join(' ');\n\n const activeCount = combinations.filter((c) => !c.isEliminated).length;\n const totalCount = combinations.length;\n\n return (\n <aside className={panelClasses} role=\"complementary\" aria-label=\"Killer Sudoku Combinations Explorer\">\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700\">\n <div>\n <h2 className=\"text-lg font-semibold text-gray-900 dark:text-gray-100\">Combinations</h2>\n <p className=\"text-sm text-gray-500 dark:text-gray-400\">\n {cage.numCells} cells, sum {cage.total}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors\"\n aria-label=\"Close combinations panel\"\n >\n <svg className=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n </div>\n\n {/* Stats */}\n <div className=\"px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700\">\n <p className=\"text-xs text-gray-600 dark:text-gray-400\">\n {activeCount} of {totalCount} combinations possible\n </p>\n </div>\n\n {/* Combinations Grid */}\n <div className=\"flex-1 overflow-hidden\">\n <CombinationGrid combinations={combinations} onToggle={onToggle} mode=\"panel\" />\n </div>\n </aside>\n );\n};\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputMode } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the NumberKeypad component
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface INumberKeypadProps {
|
|
8
|
+
/** Type of keypad - affects styling and behavior */
|
|
9
|
+
readonly keypadType: 'notes' | 'values';
|
|
10
|
+
/** Current input mode */
|
|
11
|
+
readonly inputMode: InputMode;
|
|
12
|
+
/** Whether this keypad is currently active */
|
|
13
|
+
readonly isActive: boolean;
|
|
14
|
+
/** Callback when a number is pressed */
|
|
15
|
+
readonly onNumberPress: (number: number) => void;
|
|
16
|
+
/** Callback when clear is pressed */
|
|
17
|
+
readonly onClear: () => void;
|
|
18
|
+
/** Whether the keypad is disabled */
|
|
19
|
+
readonly disabled?: boolean;
|
|
20
|
+
/** Additional CSS class name */
|
|
21
|
+
readonly className?: string;
|
|
22
|
+
/** Compact mode for smaller screens */
|
|
23
|
+
readonly compact?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Reusable number keypad component for sudoku input
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare const NumberKeypad: React.FC<INumberKeypadProps>;
|
|
30
|
+
//# sourceMappingURL=NumberKeypad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberKeypad.d.ts","sourceRoot":"","sources":["../../src/components/NumberKeypad.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC;IAExC,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,wCAAwC;IACxC,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjD,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAE7B,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA0NrD,CAAC"}
|