@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,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2023 Erik Fortune
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.KillerCombinationsExplorer = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
const useKillerCombinations_1 = require("../hooks/useKillerCombinations");
|
|
30
|
+
const useCombinationElimination_1 = require("../hooks/useCombinationElimination");
|
|
31
|
+
const useResponsiveLayout_1 = require("../hooks/useResponsiveLayout");
|
|
32
|
+
const KillerCombinationsPanel_1 = require("./KillerCombinationsPanel");
|
|
33
|
+
const KillerCombinationsModal_1 = require("./KillerCombinationsModal");
|
|
34
|
+
/**
|
|
35
|
+
* Main killer combinations explorer container component
|
|
36
|
+
* Automatically switches between panel (desktop) and modal (mobile) based on screen size
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
const KillerCombinationsExplorer = ({ selectedCage, puzzleId, isOpen, onClose, mobileBreakpoint = 1024, className }) => {
|
|
40
|
+
const { screenWidth } = (0, useResponsiveLayout_1.useResponsiveLayout)();
|
|
41
|
+
// Determine display mode based on screen width
|
|
42
|
+
const mode = screenWidth >= mobileBreakpoint ? 'panel' : 'modal';
|
|
43
|
+
// Get combinations for the selected cage
|
|
44
|
+
const combinationsResult = (0, useKillerCombinations_1.useKillerCombinations)(selectedCage);
|
|
45
|
+
// Get cage ID for storage
|
|
46
|
+
const cageId = selectedCage?.id;
|
|
47
|
+
// Get elimination state
|
|
48
|
+
const { eliminatedSignatures, toggleElimination } = (0, useCombinationElimination_1.useCombinationElimination)(puzzleId, cageId);
|
|
49
|
+
// Merge combinations with elimination state
|
|
50
|
+
const displayCombinations = (0, react_1.useMemo)(() => {
|
|
51
|
+
if (combinationsResult.isFailure()) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
return combinationsResult.value.map((combo) => ({
|
|
55
|
+
...combo,
|
|
56
|
+
isEliminated: eliminatedSignatures.has(combo.signature)
|
|
57
|
+
}));
|
|
58
|
+
}, [combinationsResult, eliminatedSignatures]);
|
|
59
|
+
// Don't render if not open or no cage selected
|
|
60
|
+
if (!isOpen || !selectedCage) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
// Don't render if combinations failed to load
|
|
64
|
+
if (combinationsResult.isFailure()) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Render panel or modal based on mode
|
|
68
|
+
if (mode === 'panel') {
|
|
69
|
+
return (react_1.default.createElement(KillerCombinationsPanel_1.KillerCombinationsPanel, { cage: selectedCage, combinations: displayCombinations, onToggle: toggleElimination, onClose: onClose, isOpen: isOpen, className: className }));
|
|
70
|
+
}
|
|
71
|
+
return (react_1.default.createElement(KillerCombinationsModal_1.KillerCombinationsModal, { cage: selectedCage, combinations: displayCombinations, onToggle: toggleElimination, onClose: onClose, isOpen: isOpen, className: className }));
|
|
72
|
+
};
|
|
73
|
+
exports.KillerCombinationsExplorer = KillerCombinationsExplorer;
|
|
74
|
+
//# sourceMappingURL=KillerCombinationsExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsExplorer.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsExplorer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAAuC;AAEvC,0EAAuE;AACvE,kFAA+E;AAC/E,sEAAmE;AACnE,uEAAoE;AACpE,uEAAoE;AAEpE;;;;GAIG;AACI,MAAM,0B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O,EAAE,CAAC;QACrB,OAAO,CACL,8BAAC,iDAAuB,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,8BAAC,iDAAuB,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;AApEW,QAAA,0BAA0B,8BAoErC","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,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2023 Erik Fortune
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.KillerCombinationsModal = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
const CombinationGrid_1 = require("./CombinationGrid");
|
|
30
|
+
/**
|
|
31
|
+
* Mobile modal variant for killer combinations explorer
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
const KillerCombinationsModal = ({ cage, combinations, onToggle, onClose, isOpen, className }) => {
|
|
35
|
+
const modalRef = (0, react_1.useRef)(null);
|
|
36
|
+
// Handle Escape key to close
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
const handleEscape = (event) => {
|
|
39
|
+
if (event.key === 'Escape') {
|
|
40
|
+
onClose();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
if (isOpen) {
|
|
44
|
+
window.addEventListener('keydown', handleEscape);
|
|
45
|
+
return () => window.removeEventListener('keydown', handleEscape);
|
|
46
|
+
}
|
|
47
|
+
}, [isOpen, onClose]);
|
|
48
|
+
// Lock body scroll when modal is open
|
|
49
|
+
(0, react_1.useEffect)(() => {
|
|
50
|
+
if (isOpen) {
|
|
51
|
+
const originalOverflow = document.body.style.overflow;
|
|
52
|
+
document.body.style.overflow = 'hidden';
|
|
53
|
+
return () => {
|
|
54
|
+
document.body.style.overflow = originalOverflow;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}, [isOpen]);
|
|
58
|
+
// Focus trap and initial focus
|
|
59
|
+
(0, react_1.useEffect)(() => {
|
|
60
|
+
if (isOpen && modalRef.current) {
|
|
61
|
+
const focusableElements = modalRef.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
62
|
+
const firstElement = focusableElements[0];
|
|
63
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
64
|
+
firstElement?.focus();
|
|
65
|
+
const handleTab = (event) => {
|
|
66
|
+
if (event.key === 'Tab') {
|
|
67
|
+
if (event.shiftKey) {
|
|
68
|
+
if (document.activeElement === firstElement) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
lastElement?.focus();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
if (document.activeElement === lastElement) {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
firstElement?.focus();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
window.addEventListener('keydown', handleTab);
|
|
82
|
+
return () => window.removeEventListener('keydown', handleTab);
|
|
83
|
+
}
|
|
84
|
+
}, [isOpen]);
|
|
85
|
+
if (!isOpen) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const activeCount = combinations.filter((c) => !c.isEliminated).length;
|
|
89
|
+
const totalCount = combinations.length;
|
|
90
|
+
/* c8 ignore next 1 - defense in depth */
|
|
91
|
+
const opacity = isOpen ? 'opacity-100' : 'opacity-0 pointer-events-none';
|
|
92
|
+
const overlayClasses = [
|
|
93
|
+
'fixed inset-0 z-[9999]',
|
|
94
|
+
'flex items-end sm:items-center justify-center',
|
|
95
|
+
'p-4',
|
|
96
|
+
'bg-black bg-opacity-40',
|
|
97
|
+
'transition-opacity duration-300',
|
|
98
|
+
opacity
|
|
99
|
+
]
|
|
100
|
+
.filter(Boolean)
|
|
101
|
+
.join(' ');
|
|
102
|
+
/* c8 ignore next 1 - defense in depth */
|
|
103
|
+
const translation = isOpen ? 'translate-y-0' : 'translate-y-full';
|
|
104
|
+
const dialogClasses = [
|
|
105
|
+
'bg-white dark:bg-gray-900',
|
|
106
|
+
'rounded-t-2xl sm:rounded-2xl',
|
|
107
|
+
'w-full max-w-lg',
|
|
108
|
+
'max-h-[85vh]',
|
|
109
|
+
'overflow-hidden',
|
|
110
|
+
'flex flex-col',
|
|
111
|
+
'shadow-2xl',
|
|
112
|
+
'transform transition-transform duration-300',
|
|
113
|
+
translation,
|
|
114
|
+
className
|
|
115
|
+
]
|
|
116
|
+
.filter(Boolean)
|
|
117
|
+
.join(' ');
|
|
118
|
+
return (react_1.default.createElement("div", { className: overlayClasses, onClick: onClose, role: "presentation" },
|
|
119
|
+
react_1.default.createElement("div", { ref: modalRef, className: dialogClasses, onClick: (e) => e.stopPropagation(), role: "dialog", "aria-modal": "true", "aria-labelledby": "modal-title", "aria-describedby": "modal-description" },
|
|
120
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700" },
|
|
121
|
+
react_1.default.createElement("div", null,
|
|
122
|
+
react_1.default.createElement("h2", { id: "modal-title", className: "text-lg font-semibold text-gray-900 dark:text-gray-100" }, "Combinations"),
|
|
123
|
+
react_1.default.createElement("p", { id: "modal-description", className: "text-sm text-gray-500 dark:text-gray-400" },
|
|
124
|
+
cage.numCells,
|
|
125
|
+
" cells, sum ",
|
|
126
|
+
cage.total)),
|
|
127
|
+
react_1.default.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" },
|
|
128
|
+
react_1.default.createElement("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
129
|
+
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })))),
|
|
130
|
+
react_1.default.createElement("div", { className: "px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700" },
|
|
131
|
+
react_1.default.createElement("p", { className: "text-xs text-gray-600 dark:text-gray-400" },
|
|
132
|
+
activeCount,
|
|
133
|
+
" of ",
|
|
134
|
+
totalCount,
|
|
135
|
+
" combinations possible")),
|
|
136
|
+
react_1.default.createElement("div", { className: "flex-1 overflow-hidden" },
|
|
137
|
+
react_1.default.createElement(CombinationGrid_1.CombinationGrid, { combinations: combinations, onToggle: onToggle, mode: "modal" })))));
|
|
138
|
+
};
|
|
139
|
+
exports.KillerCombinationsModal = KillerCombinationsModal;
|
|
140
|
+
//# sourceMappingURL=KillerCombinationsModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsModal.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsModal.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAAiD;AAGjD,uDAAoD;AAcpD;;;GAGG;AACI,MAAM,uBAAuB,GAA4C,CAAC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AAO,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAC,sBAAsB,GAAG,CAC1F,CACC,CACL;YAGN,uCAAK,SAAS,EAAC,qFAAqF;gBAClG,qCAAG,SAAS,EAAC,0CAA0C;oBACpD,WAAW;;oBAAM,UAAU;6CAC1B,CACA;YAGN,uCAAK,SAAS,EAAC,wBAAwB;gBACrC,8BAAC,iCAAe,IAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,CAC5E,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAvJW,QAAA,uBAAuB,2BAuJlC","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,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2023 Erik Fortune
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.KillerCombinationsPanel = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
const CombinationGrid_1 = require("./CombinationGrid");
|
|
30
|
+
/**
|
|
31
|
+
* Desktop panel variant for killer combinations explorer
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
const KillerCombinationsPanel = ({ cage, combinations, onToggle, onClose, isOpen, className }) => {
|
|
35
|
+
// Handle Escape key to close
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
37
|
+
const handleEscape = (event) => {
|
|
38
|
+
if (event.key === 'Escape') {
|
|
39
|
+
onClose();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
if (isOpen) {
|
|
43
|
+
window.addEventListener('keydown', handleEscape);
|
|
44
|
+
return () => window.removeEventListener('keydown', handleEscape);
|
|
45
|
+
}
|
|
46
|
+
}, [isOpen, onClose]);
|
|
47
|
+
const panelClasses = [
|
|
48
|
+
'fixed right-0 top-0 bottom-0',
|
|
49
|
+
'w-96 max-w-md',
|
|
50
|
+
'bg-white dark:bg-gray-900',
|
|
51
|
+
'border-l border-gray-200 dark:border-gray-700',
|
|
52
|
+
'shadow-2xl',
|
|
53
|
+
'transform transition-transform duration-300 ease-in-out',
|
|
54
|
+
isOpen ? 'translate-x-0' : 'translate-x-full',
|
|
55
|
+
'z-[9999]',
|
|
56
|
+
'flex flex-col',
|
|
57
|
+
className
|
|
58
|
+
]
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.join(' ');
|
|
61
|
+
const activeCount = combinations.filter((c) => !c.isEliminated).length;
|
|
62
|
+
const totalCount = combinations.length;
|
|
63
|
+
return (react_1.default.createElement("aside", { className: panelClasses, role: "complementary", "aria-label": "Killer Sudoku Combinations Explorer" },
|
|
64
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700" },
|
|
65
|
+
react_1.default.createElement("div", null,
|
|
66
|
+
react_1.default.createElement("h2", { className: "text-lg font-semibold text-gray-900 dark:text-gray-100" }, "Combinations"),
|
|
67
|
+
react_1.default.createElement("p", { className: "text-sm text-gray-500 dark:text-gray-400" },
|
|
68
|
+
cage.numCells,
|
|
69
|
+
" cells, sum ",
|
|
70
|
+
cage.total)),
|
|
71
|
+
react_1.default.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" },
|
|
72
|
+
react_1.default.createElement("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
73
|
+
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })))),
|
|
74
|
+
react_1.default.createElement("div", { className: "px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700" },
|
|
75
|
+
react_1.default.createElement("p", { className: "text-xs text-gray-600 dark:text-gray-400" },
|
|
76
|
+
activeCount,
|
|
77
|
+
" of ",
|
|
78
|
+
totalCount,
|
|
79
|
+
" combinations possible")),
|
|
80
|
+
react_1.default.createElement("div", { className: "flex-1 overflow-hidden" },
|
|
81
|
+
react_1.default.createElement(CombinationGrid_1.CombinationGrid, { combinations: combinations, onToggle: onToggle, mode: "panel" }))));
|
|
82
|
+
};
|
|
83
|
+
exports.KillerCombinationsPanel = KillerCombinationsPanel;
|
|
84
|
+
//# sourceMappingURL=KillerCombinationsPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillerCombinationsPanel.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsPanel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAAyC;AAGzC,uDAAoD;AAcpD;;;GAGG;AACI,MAAM,uBAAuB,GAA4C,CAAC,EAC/E,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,SAAS,EACV,EAAE,EAAE;IACH,6BAA6B;IAC7B,IAAA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AC1E,0BAA0B;gBAErC,uCAAK,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW;oBAC5E,wCAAM,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAC,sBAAsB,GAAG,CAC1F,CACC,CACL;QAGN,uCAAK,SAAS,EAAC,qFAAqF;YAClG,qCAAG,SAAS,EAAC,0CAA0C;gBACpD,WAAW;;gBAAM,UAAU;yCAC1B,CACA;QAGN,uCAAK,SAAS,EAAC,wBAAwB;YACrC,8BAAC,iCAAe,IAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,CAC5E,CACA,CACT,CAAC;AACJ,CAAC,CAAC;AA3EW,QAAA,uBAAuB,2BA2ElC","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,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2023 Erik Fortune
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.NumberKeypad = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
/**
|
|
30
|
+
* Reusable number keypad component for sudoku input
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
const NumberKeypad = ({ keypadType, inputMode, isActive, onNumberPress, onClear, disabled = false, className, compact = false }) => {
|
|
34
|
+
// Handle number button press with haptic feedback if available
|
|
35
|
+
const handleNumberPress = (0, react_1.useCallback)((number) => {
|
|
36
|
+
/* c8 ignore next 1 - not reachable in practice */
|
|
37
|
+
if (disabled)
|
|
38
|
+
return;
|
|
39
|
+
// Trigger haptic feedback on touch devices
|
|
40
|
+
if ('vibrate' in navigator) {
|
|
41
|
+
navigator.vibrate(10); // 10ms vibration
|
|
42
|
+
}
|
|
43
|
+
onNumberPress(number);
|
|
44
|
+
}, [disabled, onNumberPress]);
|
|
45
|
+
// Handle clear button press
|
|
46
|
+
const handleClear = (0, react_1.useCallback)(() => {
|
|
47
|
+
/* c8 ignore next 1 - not reachable in practice */
|
|
48
|
+
if (disabled)
|
|
49
|
+
return;
|
|
50
|
+
// Trigger haptic feedback on touch devices
|
|
51
|
+
if ('vibrate' in navigator) {
|
|
52
|
+
navigator.vibrate(15); // 15ms vibration for clear
|
|
53
|
+
}
|
|
54
|
+
onClear();
|
|
55
|
+
}, [disabled, onClear]);
|
|
56
|
+
// Calculate keypad classes
|
|
57
|
+
const keypadClasses = (0, react_1.useMemo)(() => {
|
|
58
|
+
const classes = ['bg-white border border-gray-300 rounded-lg p-3 flex flex-col gap-3'];
|
|
59
|
+
// Keypad type specific styles
|
|
60
|
+
if (keypadType === 'notes') {
|
|
61
|
+
classes.push('border-blue-500');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
classes.push('border-green-500');
|
|
65
|
+
}
|
|
66
|
+
// Active/inactive styles
|
|
67
|
+
if (isActive) {
|
|
68
|
+
classes.push('shadow-md');
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
classes.push('opacity-75');
|
|
72
|
+
}
|
|
73
|
+
// Compact mode
|
|
74
|
+
if (compact) {
|
|
75
|
+
classes.push('p-2 gap-2');
|
|
76
|
+
}
|
|
77
|
+
// Disabled state
|
|
78
|
+
if (disabled) {
|
|
79
|
+
classes.push('opacity-50 pointer-events-none');
|
|
80
|
+
}
|
|
81
|
+
if (className)
|
|
82
|
+
classes.push(className);
|
|
83
|
+
return classes.join(' ');
|
|
84
|
+
}, [keypadType, isActive, disabled, className, compact]);
|
|
85
|
+
// Calculate title and button classes
|
|
86
|
+
const titleClasses = (0, react_1.useMemo)(() => {
|
|
87
|
+
const classes = ['text-center font-semibold text-gray-800'];
|
|
88
|
+
if (isActive) {
|
|
89
|
+
classes.push('text-gray-900');
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
classes.push('text-gray-600');
|
|
93
|
+
}
|
|
94
|
+
if (compact) {
|
|
95
|
+
classes.push('text-sm');
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
classes.push('text-base');
|
|
99
|
+
}
|
|
100
|
+
return classes.join(' ');
|
|
101
|
+
}, [isActive, compact]);
|
|
102
|
+
const buttonClasses = (0, react_1.useMemo)(() => {
|
|
103
|
+
const classes = [
|
|
104
|
+
'border-2',
|
|
105
|
+
'rounded-lg',
|
|
106
|
+
'font-bold',
|
|
107
|
+
'transition-all',
|
|
108
|
+
'duration-150',
|
|
109
|
+
'flex',
|
|
110
|
+
'items-center',
|
|
111
|
+
'justify-center',
|
|
112
|
+
'touch-manipulation'
|
|
113
|
+
];
|
|
114
|
+
if (compact) {
|
|
115
|
+
classes.push('w-8', 'h-8', 'text-sm');
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
classes.push('w-12', 'h-12', 'text-lg');
|
|
119
|
+
}
|
|
120
|
+
if (isActive) {
|
|
121
|
+
classes.push('bg-blue-500', 'text-white', 'border-blue-600', 'hover:bg-blue-600', 'active:bg-blue-700');
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
classes.push('bg-gray-100', 'text-gray-700', 'border-gray-300', 'hover:bg-gray-200');
|
|
125
|
+
}
|
|
126
|
+
if (disabled) {
|
|
127
|
+
classes.push('opacity-50', 'cursor-not-allowed');
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
classes.push('cursor-pointer');
|
|
131
|
+
}
|
|
132
|
+
return classes.join(' ');
|
|
133
|
+
}, [compact, isActive, disabled]);
|
|
134
|
+
const clearButtonClasses = (0, react_1.useMemo)(() => {
|
|
135
|
+
const classes = [
|
|
136
|
+
'border-2',
|
|
137
|
+
'rounded-lg',
|
|
138
|
+
'font-bold',
|
|
139
|
+
'transition-all',
|
|
140
|
+
'duration-150',
|
|
141
|
+
'flex',
|
|
142
|
+
'items-center',
|
|
143
|
+
'justify-center',
|
|
144
|
+
'touch-manipulation',
|
|
145
|
+
'col-span-2'
|
|
146
|
+
];
|
|
147
|
+
if (compact) {
|
|
148
|
+
classes.push('h-8', 'text-sm');
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
classes.push('h-12', 'text-lg');
|
|
152
|
+
}
|
|
153
|
+
if (isActive) {
|
|
154
|
+
classes.push('bg-red-500', 'text-white', 'border-red-600', 'hover:bg-red-600', 'active:bg-red-700');
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
classes.push('bg-gray-100', 'text-gray-700', 'border-gray-300', 'hover:bg-gray-200');
|
|
158
|
+
}
|
|
159
|
+
if (disabled) {
|
|
160
|
+
classes.push('opacity-50', 'cursor-not-allowed');
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
classes.push('cursor-pointer');
|
|
164
|
+
}
|
|
165
|
+
return classes.join(' ');
|
|
166
|
+
}, [compact, isActive, disabled]);
|
|
167
|
+
const gridClasses = (0, react_1.useMemo)(() => {
|
|
168
|
+
const classes = ['grid grid-cols-3 auto-rows-fr'];
|
|
169
|
+
if (compact) {
|
|
170
|
+
classes.push('gap-1');
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
classes.push('gap-2');
|
|
174
|
+
}
|
|
175
|
+
return classes.join(' ');
|
|
176
|
+
}, [compact]);
|
|
177
|
+
// Keypad title
|
|
178
|
+
const title = keypadType === 'notes' ? '📝 Notes' : '✏️ Values';
|
|
179
|
+
return (react_1.default.createElement("div", { className: keypadClasses, role: "grid", "aria-label": `${keypadType} number keypad`, "data-testid": `number-keypad-${keypadType}` },
|
|
180
|
+
react_1.default.createElement("div", { className: titleClasses }, title),
|
|
181
|
+
react_1.default.createElement("div", { className: gridClasses, role: "grid" },
|
|
182
|
+
[1, 2, 3, 4, 5, 6, 7, 8, 9].map((number) => (react_1.default.createElement("button", { key: number, type: "button", onClick: () => handleNumberPress(number), disabled: disabled, className: buttonClasses, "aria-label": `Enter ${number} ${keypadType === 'notes' ? 'as note' : 'as value'}`, "data-testid": `keypad-${keypadType}-${number}`, onMouseDown: (e) => e.preventDefault() }, number))),
|
|
183
|
+
react_1.default.createElement("button", { type: "button", onClick: handleClear, disabled: disabled, className: clearButtonClasses, "aria-label": `Clear ${keypadType}`, "data-testid": `keypad-${keypadType}-clear`, onMouseDown: (e) => e.preventDefault() }, "Clear"))));
|
|
184
|
+
};
|
|
185
|
+
exports.NumberKeypad = NumberKeypad;
|
|
186
|
+
//# sourceMappingURL=NumberKeypad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberKeypad.js","sourceRoot":"","sources":["../../src/components/NumberKeypad.tsx"],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BAC5B,iBAAiB,UAAU,EAAE;QAG1C,uCAAK,SAAS,EAAE,YAAY,IAAG,KAAK,CAAO;QAG3C,uCAAK,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,MAAM;YAErC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC3C,0CACE,GAAG,EAAE,MAAM,EACX,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,EACxC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,aAAa,gBACZ,SAAS,MAAM,IAAI,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,iBACnE,UAAU,UAAU,IAAI,MAAM,EAAE,EAC7C,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,IAErC,MAAM,CACA,CACV,CAAC;YAGF,0CACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,kBAAkB,gBACjB,SAAS,UAAU,EAAE,iBACpB,UAAU,UAAU,QAAQ,EACzC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,YAG/B,CACL,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AA1NW,QAAA,YAAY,gBA0NvB","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 } from 'react';\nimport { InputMode } from '../types';\n\n/**\n * Props for the NumberKeypad component\n * @public\n */\nexport interface INumberKeypadProps {\n /** Type of keypad - affects styling and behavior */\n readonly keypadType: 'notes' | 'values';\n\n /** Current input mode */\n readonly inputMode: InputMode;\n\n /** Whether this keypad is currently active */\n readonly isActive: boolean;\n\n /** Callback when a number is pressed */\n readonly onNumberPress: (number: number) => void;\n\n /** Callback when clear is pressed */\n readonly onClear: () => void;\n\n /** Whether the keypad is disabled */\n readonly disabled?: boolean;\n\n /** Additional CSS class name */\n readonly className?: string;\n\n /** Compact mode for smaller screens */\n readonly compact?: boolean;\n}\n\n/**\n * Reusable number keypad component for sudoku input\n * @public\n */\nexport const NumberKeypad: React.FC<INumberKeypadProps> = ({\n keypadType,\n inputMode,\n isActive,\n onNumberPress,\n onClear,\n disabled = false,\n className,\n compact = false\n}) => {\n // Handle number button press with haptic feedback if available\n const handleNumberPress = useCallback(\n (number: number) => {\n /* c8 ignore next 1 - not reachable in practice */\n if (disabled) return;\n\n // Trigger haptic feedback on touch devices\n if ('vibrate' in navigator) {\n navigator.vibrate(10); // 10ms vibration\n }\n\n onNumberPress(number);\n },\n [disabled, onNumberPress]\n );\n\n // Handle clear button press\n const handleClear = useCallback(() => {\n /* c8 ignore next 1 - not reachable in practice */\n if (disabled) return;\n\n // Trigger haptic feedback on touch devices\n if ('vibrate' in navigator) {\n navigator.vibrate(15); // 15ms vibration for clear\n }\n\n onClear();\n }, [disabled, onClear]);\n\n // Calculate keypad classes\n const keypadClasses = useMemo(() => {\n const classes = ['bg-white border border-gray-300 rounded-lg p-3 flex flex-col gap-3'];\n\n // Keypad type specific styles\n if (keypadType === 'notes') {\n classes.push('border-blue-500');\n } else {\n classes.push('border-green-500');\n }\n\n // Active/inactive styles\n if (isActive) {\n classes.push('shadow-md');\n } else {\n classes.push('opacity-75');\n }\n\n // Compact mode\n if (compact) {\n classes.push('p-2 gap-2');\n }\n\n // Disabled state\n if (disabled) {\n classes.push('opacity-50 pointer-events-none');\n }\n\n if (className) classes.push(className);\n\n return classes.join(' ');\n }, [keypadType, isActive, disabled, className, compact]);\n\n // Calculate title and button classes\n const titleClasses = useMemo(() => {\n const classes = ['text-center font-semibold text-gray-800'];\n\n if (isActive) {\n classes.push('text-gray-900');\n } else {\n classes.push('text-gray-600');\n }\n\n if (compact) {\n classes.push('text-sm');\n } else {\n classes.push('text-base');\n }\n\n return classes.join(' ');\n }, [isActive, compact]);\n\n const buttonClasses = useMemo(() => {\n const classes = [\n 'border-2',\n 'rounded-lg',\n 'font-bold',\n 'transition-all',\n 'duration-150',\n 'flex',\n 'items-center',\n 'justify-center',\n 'touch-manipulation'\n ];\n\n if (compact) {\n classes.push('w-8', 'h-8', 'text-sm');\n } else {\n classes.push('w-12', 'h-12', 'text-lg');\n }\n\n if (isActive) {\n classes.push('bg-blue-500', 'text-white', 'border-blue-600', 'hover:bg-blue-600', 'active:bg-blue-700');\n } else {\n classes.push('bg-gray-100', 'text-gray-700', 'border-gray-300', 'hover:bg-gray-200');\n }\n\n if (disabled) {\n classes.push('opacity-50', 'cursor-not-allowed');\n } else {\n classes.push('cursor-pointer');\n }\n\n return classes.join(' ');\n }, [compact, isActive, disabled]);\n\n const clearButtonClasses = useMemo(() => {\n const classes = [\n 'border-2',\n 'rounded-lg',\n 'font-bold',\n 'transition-all',\n 'duration-150',\n 'flex',\n 'items-center',\n 'justify-center',\n 'touch-manipulation',\n 'col-span-2'\n ];\n\n if (compact) {\n classes.push('h-8', 'text-sm');\n } else {\n classes.push('h-12', 'text-lg');\n }\n\n if (isActive) {\n classes.push('bg-red-500', 'text-white', 'border-red-600', 'hover:bg-red-600', 'active:bg-red-700');\n } else {\n classes.push('bg-gray-100', 'text-gray-700', 'border-gray-300', 'hover:bg-gray-200');\n }\n\n if (disabled) {\n classes.push('opacity-50', 'cursor-not-allowed');\n } else {\n classes.push('cursor-pointer');\n }\n\n return classes.join(' ');\n }, [compact, isActive, disabled]);\n\n const gridClasses = useMemo(() => {\n const classes = ['grid grid-cols-3 auto-rows-fr'];\n\n if (compact) {\n classes.push('gap-1');\n } else {\n classes.push('gap-2');\n }\n\n return classes.join(' ');\n }, [compact]);\n\n // Keypad title\n const title = keypadType === 'notes' ? '📝 Notes' : '✏️ Values';\n\n return (\n <div\n className={keypadClasses}\n role=\"grid\"\n aria-label={`${keypadType} number keypad`}\n data-testid={`number-keypad-${keypadType}`}\n >\n {/* Keypad title */}\n <div className={titleClasses}>{title}</div>\n\n {/* Number grid */}\n <div className={gridClasses} role=\"grid\">\n {/* Numbers 1-9 */}\n {[1, 2, 3, 4, 5, 6, 7, 8, 9].map((number) => (\n <button\n key={number}\n type=\"button\"\n onClick={() => handleNumberPress(number)}\n disabled={disabled}\n className={buttonClasses}\n aria-label={`Enter ${number} ${keypadType === 'notes' ? 'as note' : 'as value'}`}\n data-testid={`keypad-${keypadType}-${number}`}\n onMouseDown={(e) => e.preventDefault()} // Prevent focus on click\n >\n {number}\n </button>\n ))}\n\n {/* Clear button spanning 2 columns */}\n <button\n type=\"button\"\n onClick={handleClear}\n disabled={disabled}\n className={clearButtonClasses}\n aria-label={`Clear ${keypadType}`}\n data-testid={`keypad-${keypadType}-clear`}\n onMouseDown={(e) => e.preventDefault()} // Prevent focus on click\n >\n Clear\n </button>\n </div>\n </div>\n );\n};\n"]}
|