@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,71 @@
|
|
|
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.CageSumIndicator = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
/**
|
|
30
|
+
* Component for displaying the target sum of a cage in Killer Sudoku
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
const CageSumIndicator = ({ cage, currentSum, isComplete, isValid, position, className }) => {
|
|
34
|
+
// Calculate display classes based on state
|
|
35
|
+
const displayClasses = (0, react_1.useMemo)(() => {
|
|
36
|
+
const classes = ['cage-sum-indicator'];
|
|
37
|
+
/* c8 ignore next 1 - defense in depth */
|
|
38
|
+
if (className)
|
|
39
|
+
classes.push(className);
|
|
40
|
+
if (!isValid) {
|
|
41
|
+
classes.push('cage-sum-indicator--invalid');
|
|
42
|
+
}
|
|
43
|
+
else if (isComplete) {
|
|
44
|
+
classes.push('cage-sum-indicator--complete');
|
|
45
|
+
}
|
|
46
|
+
else if (currentSum !== undefined) {
|
|
47
|
+
classes.push('cage-sum-indicator--partial');
|
|
48
|
+
}
|
|
49
|
+
return classes.join(' ');
|
|
50
|
+
}, [className, isValid, isComplete, currentSum]);
|
|
51
|
+
return (react_1.default.createElement("div", { className: `
|
|
52
|
+
${displayClasses}
|
|
53
|
+
absolute z-20 pointer-events-none
|
|
54
|
+
text-xs font-bold
|
|
55
|
+
bg-white border border-gray-400 rounded px-1
|
|
56
|
+
min-w-[20px] text-center
|
|
57
|
+
shadow-sm
|
|
58
|
+
`, style: {
|
|
59
|
+
top: `${position.top}%`,
|
|
60
|
+
left: `${position.left}%`,
|
|
61
|
+
fontSize: '10px',
|
|
62
|
+
lineHeight: '16px'
|
|
63
|
+
}, "data-testid": `cage-sum-${cage.id}` },
|
|
64
|
+
react_1.default.createElement("div", { className: "text-gray-700" }, cage.total),
|
|
65
|
+
currentSum !== undefined && (react_1.default.createElement("div", { className: `
|
|
66
|
+
text-xs
|
|
67
|
+
${isValid ? 'text-blue-600' : 'text-red-600'}
|
|
68
|
+
`, style: { fontSize: '8px', lineHeight: '10px' } }, currentSum))));
|
|
69
|
+
};
|
|
70
|
+
exports.CageSumIndicator = CageSumIndicator;
|
|
71
|
+
//# sourceMappingURL=CageSumIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CageSumIndicator.js","sourceRoot":"","sources":["../../src/components/CageSumIndicator.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAAuC;AAGvC;;;GAGG;AACI,MAAM,gBAAgB,GAAqC,CAAC,EACjE,IAAI,EACJ,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,EACV,EAAE,EAAE;IACH,2CAA2C;IAC3C,MAAM,cAAc,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAClC,MAAM,OAAO,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAEvC,yCAAyC;QACzC,IAAI,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC9C,CAAC;aAAM,IAAI,UAAU,EAAE,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC/C,CAAC;aAAM,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAEjD,OAAO,CACL,uCACE,SAAS,EAAE;UACP,cAAc;;;;;;OAMjB,EACD,KAAK,EAAE;YACL,GAAG,EAAE,GAAG,QAAQ,CAAC,GAAG,GAAG;YACvB,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,GAAG;YACzB,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,MAAM;SACnB,iBACY,YAAY,IAAI,CAAC,EAAE,EAAE;QAElC,uCAAK,SAAS,EAAC,eAAe,IAAE,IAAI,CAAC,KAAK,CAAO;QAChD,UAAU,KAAK,SAAS,IAAI,CAC3B,uCACE,SAAS,EAAE;;cAEP,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc;WAC7C,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,IAE7C,UAAU,CACP,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AA1DW,QAAA,gBAAgB,oBA0D3B","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 { ICageSumIndicatorProps } from '../types';\n\n/**\n * Component for displaying the target sum of a cage in Killer Sudoku\n * @public\n */\nexport const CageSumIndicator: React.FC<ICageSumIndicatorProps> = ({\n cage,\n currentSum,\n isComplete,\n isValid,\n position,\n className\n}) => {\n // Calculate display classes based on state\n const displayClasses = useMemo(() => {\n const classes = ['cage-sum-indicator'];\n\n /* c8 ignore next 1 - defense in depth */\n if (className) classes.push(className);\n\n if (!isValid) {\n classes.push('cage-sum-indicator--invalid');\n } else if (isComplete) {\n classes.push('cage-sum-indicator--complete');\n } else if (currentSum !== undefined) {\n classes.push('cage-sum-indicator--partial');\n }\n\n return classes.join(' ');\n }, [className, isValid, isComplete, currentSum]);\n\n return (\n <div\n className={`\n ${displayClasses}\n absolute z-20 pointer-events-none\n text-xs font-bold\n bg-white border border-gray-400 rounded px-1\n min-w-[20px] text-center\n shadow-sm\n `}\n style={{\n top: `${position.top}%`,\n left: `${position.left}%`,\n fontSize: '10px',\n lineHeight: '16px'\n }}\n data-testid={`cage-sum-${cage.id}`}\n >\n <div className=\"text-gray-700\">{cage.total}</div>\n {currentSum !== undefined && (\n <div\n className={`\n text-xs\n ${isValid ? 'text-blue-600' : 'text-red-600'}\n `}\n style={{ fontSize: '8px', lineHeight: '10px' }}\n >\n {currentSum}\n </div>\n )}\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
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.CombinationCard = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
/**
|
|
30
|
+
* Individual combination card component with toggle functionality
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
exports.CombinationCard = react_1.default.memo(({ combination, onToggle, className }) => {
|
|
34
|
+
const { combination: numbers, signature, isEliminated } = combination;
|
|
35
|
+
const handleClick = (0, react_1.useCallback)(() => {
|
|
36
|
+
onToggle(signature);
|
|
37
|
+
}, [onToggle, signature]);
|
|
38
|
+
const handleKeyDown = (0, react_1.useCallback)((event) => {
|
|
39
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
onToggle(signature);
|
|
42
|
+
}
|
|
43
|
+
}, [onToggle, signature]);
|
|
44
|
+
const cardClasses = [
|
|
45
|
+
'px-3 py-1',
|
|
46
|
+
'rounded border',
|
|
47
|
+
'transition-all duration-200',
|
|
48
|
+
'cursor-pointer select-none',
|
|
49
|
+
'hover:shadow-sm',
|
|
50
|
+
'focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1',
|
|
51
|
+
'inline-flex items-center justify-center',
|
|
52
|
+
isEliminated
|
|
53
|
+
? 'border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 opacity-60'
|
|
54
|
+
: 'border-blue-500 dark:border-blue-400 bg-white dark:bg-gray-800 hover:bg-blue-50 dark:hover:bg-gray-700',
|
|
55
|
+
className
|
|
56
|
+
]
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join(' ');
|
|
59
|
+
const numberDisplay = numbers.join('');
|
|
60
|
+
const ariaLabel = numbers.join(', ');
|
|
61
|
+
return (react_1.default.createElement("button", { type: "button", className: cardClasses, onClick: handleClick, onKeyDown: handleKeyDown, "aria-pressed": isEliminated, "aria-label": `Combination ${ariaLabel}${isEliminated ? ' (eliminated)' : ''}`, role: "button" },
|
|
62
|
+
react_1.default.createElement("span", { className: `text-sm font-mono font-bold ${isEliminated ? 'text-gray-500 dark:text-gray-400 line-through' : 'text-gray-900 dark:text-white'}` }, numberDisplay)));
|
|
63
|
+
}, (prev, next) => {
|
|
64
|
+
return (prev.combination.signature === next.combination.signature &&
|
|
65
|
+
prev.combination.isEliminated === next.combination.isEliminated);
|
|
66
|
+
});
|
|
67
|
+
exports.CombinationCard.displayName = 'CombinationCard';
|
|
68
|
+
//# sourceMappingURL=CombinationCard.js.map
|
|
@@ -0,0 +1 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AO,CACL,0CACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,kBACV,YAAY,gBACd,eAAe,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,EAC5E,IAAI,EAAC,QAAQ;QAEb,wCACE,SAAS,EAAE,+BACT,YAAY,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,+BACnE,EAAE,IAED,aAAa,CACT,CACA,CACV,CAAC;AACJ,CAAC,EACD,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;IACb,OAAO,CACL,IAAI,CAAC,WAAW,CAAC,SAAS,KAAK,IAAI,CAAC,WAAW,CAAC,SAAS;QACzD,IAAI,CAAC,WAAW,CAAC,YAAY,KAAK,IAAI,CAAC,WAAW,CAAC,YAAY,CAChE,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ,uBAAe,CAAC,WAAW,GAAG,iBAAiB,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 } from 'react';\nimport { ICombinationCardProps } from '../types';\n\n/**\n * Individual combination card component with toggle functionality\n * @public\n */\nexport const CombinationCard: React.NamedExoticComponent<ICombinationCardProps> =\n React.memo<ICombinationCardProps>(\n ({ combination, onToggle, className }) => {\n const { combination: numbers, signature, isEliminated } = combination;\n\n const handleClick = useCallback(() => {\n onToggle(signature);\n }, [onToggle, signature]);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n onToggle(signature);\n }\n },\n [onToggle, signature]\n );\n\n const cardClasses: string = [\n 'px-3 py-1',\n 'rounded border',\n 'transition-all duration-200',\n 'cursor-pointer select-none',\n 'hover:shadow-sm',\n 'focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1',\n 'inline-flex items-center justify-center',\n isEliminated\n ? 'border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 opacity-60'\n : 'border-blue-500 dark:border-blue-400 bg-white dark:bg-gray-800 hover:bg-blue-50 dark:hover:bg-gray-700',\n className\n ]\n .filter(Boolean)\n .join(' ');\n\n const numberDisplay = numbers.join('');\n const ariaLabel = numbers.join(', ');\n\n return (\n <button\n type=\"button\"\n className={cardClasses}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n aria-pressed={isEliminated}\n aria-label={`Combination ${ariaLabel}${isEliminated ? ' (eliminated)' : ''}`}\n role=\"button\"\n >\n <span\n className={`text-sm font-mono font-bold ${\n isEliminated ? 'text-gray-500 dark:text-gray-400 line-through' : 'text-gray-900 dark:text-white'\n }`}\n >\n {numberDisplay}\n </span>\n </button>\n );\n },\n (prev, next) => {\n return (\n prev.combination.signature === next.combination.signature &&\n prev.combination.isEliminated === next.combination.isEliminated\n );\n }\n );\n\nCombinationCard.displayName = 'CombinationCard';\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.CombinationGrid = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
29
|
+
const CombinationCard_1 = require("./CombinationCard");
|
|
30
|
+
/**
|
|
31
|
+
* Grid layout component for displaying combination cards
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
const CombinationGrid = ({ combinations, onToggle, mode, className }) => {
|
|
35
|
+
const gridClasses = ['flex flex-wrap gap-2 p-4', 'overflow-y-auto', 'justify-start', className]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join(' ');
|
|
38
|
+
if (combinations.length === 0) {
|
|
39
|
+
return (react_1.default.createElement("div", { className: "flex items-center justify-center p-8 text-gray-500 dark:text-gray-400" },
|
|
40
|
+
react_1.default.createElement("p", null, "No combinations available for this cage")));
|
|
41
|
+
}
|
|
42
|
+
// Sort combinations: valid ones first, then by numeric value
|
|
43
|
+
const sortedCombinations = [...combinations].sort((a, b) => {
|
|
44
|
+
// First sort by elimination status (valid ones first)
|
|
45
|
+
if (a.isEliminated !== b.isEliminated) {
|
|
46
|
+
return a.isEliminated ? 1 : -1;
|
|
47
|
+
}
|
|
48
|
+
// Then sort by the numeric value of the combination
|
|
49
|
+
const aValue = parseInt(a.combination.join(''), 10);
|
|
50
|
+
const bValue = parseInt(b.combination.join(''), 10);
|
|
51
|
+
return aValue - bValue;
|
|
52
|
+
});
|
|
53
|
+
return (react_1.default.createElement("div", { className: gridClasses }, sortedCombinations.map((combo) => (react_1.default.createElement(CombinationCard_1.CombinationCard, { key: combo.signature, combination: combo, onToggle: onToggle })))));
|
|
54
|
+
};
|
|
55
|
+
exports.CombinationGrid = CombinationGrid;
|
|
56
|
+
//# sourceMappingURL=CombinationGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CombinationGrid.js","sourceRoot":"","sources":["../../src/components/CombinationGrid.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,0DAA0B;AAE1B,uDAAoD;AAEpD;;;GAGG;AACI,MAAM,eAAe,GAAoC,CAAC,EAC/D,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,SAAS,EACV,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,CAAC,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,CAAC;SAC5F,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,CACL,uCAAK,SAAS,EAAC,uEAAuE;YACpF,mFAA8C,CAC1C,CACP,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,MAAM,kBAAkB,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzD,sDAAsD;QACtD,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;YACtC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,oDAAoD;QACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACpD,OAAO,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,uCAAK,SAAS,EAAE,WAAW,IACxB,kBAAkB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACjC,8BAAC,iCAAe,IAAC,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAClF,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,eAAe,mBAqC1B","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 from 'react';\nimport { ICombinationGridProps } from '../types';\nimport { CombinationCard } from './CombinationCard';\n\n/**\n * Grid layout component for displaying combination cards\n * @public\n */\nexport const CombinationGrid: React.FC<ICombinationGridProps> = ({\n combinations,\n onToggle,\n mode,\n className\n}) => {\n const gridClasses = ['flex flex-wrap gap-2 p-4', 'overflow-y-auto', 'justify-start', className]\n .filter(Boolean)\n .join(' ');\n\n if (combinations.length === 0) {\n return (\n <div className=\"flex items-center justify-center p-8 text-gray-500 dark:text-gray-400\">\n <p>No combinations available for this cage</p>\n </div>\n );\n }\n\n // Sort combinations: valid ones first, then by numeric value\n const sortedCombinations = [...combinations].sort((a, b) => {\n // First sort by elimination status (valid ones first)\n if (a.isEliminated !== b.isEliminated) {\n return a.isEliminated ? 1 : -1;\n }\n // Then sort by the numeric value of the combination\n const aValue = parseInt(a.combination.join(''), 10);\n const bValue = parseInt(b.combination.join(''), 10);\n return aValue - bValue;\n });\n\n return (\n <div className={gridClasses}>\n {sortedCombinations.map((combo) => (\n <CombinationCard key={combo.signature} combination={combo} onToggle={onToggle} />\n ))}\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,146 @@
|
|
|
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.CompactControlRibbon = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
const useResponsiveLayout_1 = require("../hooks/useResponsiveLayout");
|
|
30
|
+
/**
|
|
31
|
+
* Compact control ribbon with icon-only badges for actions and status indicator
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
const CompactControlRibbon = ({ canUndo, canRedo, canReset, isValid, isSolved, validationErrors, onUndo, onRedo, onReset, onExport, showCombinations, canShowCombinations, onCombinations, className }) => {
|
|
35
|
+
const [showResetConfirm, setShowResetConfirm] = (0, react_1.useState)(false);
|
|
36
|
+
const responsiveLayout = (0, useResponsiveLayout_1.useResponsiveLayout)();
|
|
37
|
+
// Handle reset with confirmation
|
|
38
|
+
const handleResetClick = (0, react_1.useCallback)(() => {
|
|
39
|
+
if (showResetConfirm) {
|
|
40
|
+
onReset();
|
|
41
|
+
setShowResetConfirm(false);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
setShowResetConfirm(true);
|
|
45
|
+
// Auto-hide confirmation after 3 seconds
|
|
46
|
+
setTimeout(() => setShowResetConfirm(false), 3000);
|
|
47
|
+
}
|
|
48
|
+
}, [showResetConfirm, onReset]);
|
|
49
|
+
// Cancel reset confirmation
|
|
50
|
+
const handleCancelReset = (0, react_1.useCallback)(() => {
|
|
51
|
+
setShowResetConfirm(false);
|
|
52
|
+
}, []);
|
|
53
|
+
// Calculate if we should use mobile layout
|
|
54
|
+
const isMobileLayout = responsiveLayout.deviceType === 'mobile' &&
|
|
55
|
+
(responsiveLayout.keypadLayoutMode === 'side-by-side' || responsiveLayout.keypadLayoutMode === 'stacked');
|
|
56
|
+
// Calculate container classes
|
|
57
|
+
const containerClasses = (0, react_1.useMemo)(() => {
|
|
58
|
+
const classes = [
|
|
59
|
+
'flex items-center justify-center gap-3 p-2 bg-gray-50 border border-gray-200 rounded-lg shadow-sm'
|
|
60
|
+
];
|
|
61
|
+
if (isMobileLayout) {
|
|
62
|
+
classes.push('gap-2 p-1.5');
|
|
63
|
+
}
|
|
64
|
+
if (className)
|
|
65
|
+
classes.push(className);
|
|
66
|
+
return classes.join(' ');
|
|
67
|
+
}, [isMobileLayout, className]);
|
|
68
|
+
// Calculate button classes
|
|
69
|
+
const getButtonClasses = (0, react_1.useCallback)((isEnabled, variant = 'default') => {
|
|
70
|
+
const classes = [
|
|
71
|
+
'flex items-center justify-center rounded-full transition-all duration-150 font-medium text-sm border-2'
|
|
72
|
+
];
|
|
73
|
+
// Size based on layout
|
|
74
|
+
if (isMobileLayout) {
|
|
75
|
+
classes.push('w-8 h-8 text-xs');
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
classes.push('w-10 h-10 text-sm');
|
|
79
|
+
}
|
|
80
|
+
// Variant and state styling
|
|
81
|
+
if (!isEnabled) {
|
|
82
|
+
classes.push('border-gray-300 text-gray-400 bg-gray-100 cursor-not-allowed');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
switch (variant) {
|
|
86
|
+
case 'danger':
|
|
87
|
+
classes.push('border-red-500 text-red-600 bg-red-50 hover:bg-red-100 active:bg-red-200 cursor-pointer');
|
|
88
|
+
break;
|
|
89
|
+
case 'success':
|
|
90
|
+
classes.push('border-green-500 text-green-600 bg-green-50 hover:bg-green-100 active:bg-green-200 cursor-pointer');
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
classes.push('border-blue-500 text-blue-600 bg-blue-50 hover:bg-blue-100 active:bg-blue-200 cursor-pointer');
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return classes.join(' ');
|
|
98
|
+
}, [isMobileLayout]);
|
|
99
|
+
// Calculate status indicator classes and content
|
|
100
|
+
const statusIndicator = (0, react_1.useMemo)(() => {
|
|
101
|
+
const classes = ['flex items-center justify-center rounded-full border-2 font-bold'];
|
|
102
|
+
// Size based on layout
|
|
103
|
+
if (isMobileLayout) {
|
|
104
|
+
classes.push('w-8 h-8 text-xs');
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
classes.push('w-10 h-10 text-sm');
|
|
108
|
+
}
|
|
109
|
+
let content;
|
|
110
|
+
let title;
|
|
111
|
+
if (isSolved) {
|
|
112
|
+
classes.push('border-green-500 text-green-700 bg-green-100');
|
|
113
|
+
content = '✓';
|
|
114
|
+
title = 'Puzzle solved!';
|
|
115
|
+
}
|
|
116
|
+
else if (isValid) {
|
|
117
|
+
classes.push('border-green-500 text-green-700 bg-green-100');
|
|
118
|
+
content = '✓';
|
|
119
|
+
title = 'Puzzle is valid';
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
classes.push('border-red-500 text-red-700 bg-red-100');
|
|
123
|
+
content = validationErrors.length.toString();
|
|
124
|
+
title = `${validationErrors.length} validation error${validationErrors.length === 1 ? '' : 's'}`;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
className: classes.join(' '),
|
|
128
|
+
content,
|
|
129
|
+
title
|
|
130
|
+
};
|
|
131
|
+
}, [isSolved, isValid, validationErrors.length, isMobileLayout]);
|
|
132
|
+
return (react_1.default.createElement("div", { className: containerClasses, "data-testid": "compact-control-ribbon", role: "toolbar", "aria-label": "Puzzle controls" },
|
|
133
|
+
react_1.default.createElement("div", { className: statusIndicator.className, title: statusIndicator.title, "aria-label": statusIndicator.title, "data-testid": "status-indicator" }, statusIndicator.content),
|
|
134
|
+
react_1.default.createElement("div", { className: "w-px h-6 bg-gray-300" }),
|
|
135
|
+
react_1.default.createElement("button", { type: "button", onClick: onExport, className: getButtonClasses(true, 'success'), title: "Export puzzle", "aria-label": "Export puzzle in compatible format", "data-testid": "compact-export-button" }, "\uD83D\uDCE4"),
|
|
136
|
+
showCombinations && onCombinations && (react_1.default.createElement("button", { type: "button", onClick: onCombinations, disabled: !canShowCombinations, className: getButtonClasses(canShowCombinations ?? false), title: canShowCombinations ? 'Show cage combinations (Ctrl/Cmd+K)' : 'Select cells from a single cage', "aria-label": canShowCombinations ? 'Show combinations for selected cage' : 'No cage selected', "data-testid": "compact-combinations-button" },
|
|
137
|
+
react_1.default.createElement("svg", { className: "w-5 h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor" },
|
|
138
|
+
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z" })))),
|
|
139
|
+
!showResetConfirm ? (react_1.default.createElement("button", { type: "button", onClick: handleResetClick, disabled: !canReset, className: getButtonClasses(canReset, 'danger'), title: "Reset puzzle", "aria-label": "Clear all entries", "data-testid": "compact-reset-button" }, "\uD83D\uDDD1\uFE0F")) : (react_1.default.createElement("div", { className: "flex items-center gap-1" },
|
|
140
|
+
react_1.default.createElement("button", { type: "button", onClick: handleResetClick, className: getButtonClasses(true, 'danger'), title: "Confirm reset - this will clear all entries", "aria-label": "Confirm reset", "data-testid": "compact-confirm-reset-button" }, "\u2713"),
|
|
141
|
+
react_1.default.createElement("button", { type: "button", onClick: handleCancelReset, className: getButtonClasses(true), title: "Cancel reset", "aria-label": "Cancel reset", "data-testid": "compact-cancel-reset-button" }, "\u2715"))),
|
|
142
|
+
react_1.default.createElement("button", { type: "button", onClick: onUndo, disabled: !canUndo, className: getButtonClasses(canUndo), title: "Undo last action", "aria-label": "Undo last action", "data-testid": "compact-undo-button" }, "\u21B6"),
|
|
143
|
+
react_1.default.createElement("button", { type: "button", onClick: onRedo, disabled: !canRedo, className: getButtonClasses(canRedo), title: "Redo last undone action", "aria-label": "Redo last undone action", "data-testid": "compact-redo-button" }, "\u21B7")));
|
|
144
|
+
};
|
|
145
|
+
exports.CompactControlRibbon = CompactControlRibbon;
|
|
146
|
+
//# sourceMappingURL=CompactControlRibbon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompactControlRibbon.js","sourceRoot":"","sources":["../../src/components/CompactControlRibbon.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAA8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E,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,EAC3C,KAAK,EAAC,6CAA6C,gBACxC,eAAe,iBACd,8BAA8B,aAGnC;YACT,0CACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,EACjC,KAAK,EAAC,cAAc,gBACT,cAAc,iBACb,6BAA6B,aAGlC,CACL,CACP;QAGD,0CACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,OAAO,EAClB,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,EACpC,KAAK,EAAC,kBAAkB,gBACb,kBAAkB,iBACjB,qBAAqB,aAG1B;QAGT,0CACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,OAAO,EAClB,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,EACpC,KAAK,EAAC,yBAAyB,gBACpB,yBAAyB,iBACxB,qBAAqB,aAG1B,CACL,CACP,CAAC;AACJ,CAAC,CAAC;AA7PW,QAAA,oBAAoB,wBA6P/B","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 { useResponsiveLayout } from '../hooks/useResponsiveLayout';\n\n/**\n * Props for the CompactControlRibbon component\n * @public\n */\nexport interface ICompactControlRibbonProps {\n /** Whether undo is available */\n readonly canUndo: boolean;\n\n /** Whether redo is available */\n readonly canRedo: boolean;\n\n /** Whether reset is available */\n readonly canReset: boolean;\n\n /** Whether the puzzle is valid */\n readonly isValid: boolean;\n\n /** Whether the puzzle is solved */\n readonly isSolved: boolean;\n\n /** Validation errors for error count display */\n readonly validationErrors: ReadonlyArray<{\n readonly type: string;\n readonly cellId: string;\n readonly message: string;\n }>;\n\n /** Callback for undo action */\n readonly onUndo: () => void;\n\n /** Callback for redo action */\n readonly onRedo: () => void;\n\n /** Callback for reset action */\n readonly onReset: () => void;\n\n /** Callback for export action */\n readonly onExport: () => void;\n\n /** Whether to show combinations button (for killer sudoku) */\n readonly showCombinations?: boolean;\n\n /** Whether combinations button should be enabled */\n readonly canShowCombinations?: boolean;\n\n /** Callback for combinations action */\n readonly onCombinations?: () => void;\n\n /** Additional CSS class name */\n readonly className?: string;\n}\n\n/**\n * Compact control ribbon with icon-only badges for actions and status indicator\n * @public\n */\nexport const CompactControlRibbon: React.FC<ICompactControlRibbonProps> = ({\n canUndo,\n canRedo,\n canReset,\n isValid,\n isSolved,\n validationErrors,\n onUndo,\n onRedo,\n onReset,\n onExport,\n showCombinations,\n canShowCombinations,\n onCombinations,\n className\n}) => {\n const [showResetConfirm, setShowResetConfirm] = useState(false);\n const responsiveLayout = useResponsiveLayout();\n\n // Handle reset with confirmation\n const handleResetClick = useCallback(() => {\n if (showResetConfirm) {\n onReset();\n setShowResetConfirm(false);\n } else {\n setShowResetConfirm(true);\n // Auto-hide confirmation after 3 seconds\n setTimeout(() => setShowResetConfirm(false), 3000);\n }\n }, [showResetConfirm, onReset]);\n\n // Cancel reset confirmation\n const handleCancelReset = useCallback(() => {\n setShowResetConfirm(false);\n }, []);\n\n // Calculate if we should use mobile layout\n const isMobileLayout =\n responsiveLayout.deviceType === 'mobile' &&\n (responsiveLayout.keypadLayoutMode === 'side-by-side' || responsiveLayout.keypadLayoutMode === 'stacked');\n\n // Calculate container classes\n const containerClasses = useMemo(() => {\n const classes = [\n 'flex items-center justify-center gap-3 p-2 bg-gray-50 border border-gray-200 rounded-lg shadow-sm'\n ];\n\n if (isMobileLayout) {\n classes.push('gap-2 p-1.5');\n }\n\n if (className) classes.push(className);\n return classes.join(' ');\n }, [isMobileLayout, className]);\n\n // Calculate button classes\n const getButtonClasses = useCallback(\n (isEnabled: boolean, variant: 'default' | 'danger' | 'success' = 'default') => {\n const classes = [\n 'flex items-center justify-center rounded-full transition-all duration-150 font-medium text-sm border-2'\n ];\n\n // Size based on layout\n if (isMobileLayout) {\n classes.push('w-8 h-8 text-xs');\n } else {\n classes.push('w-10 h-10 text-sm');\n }\n\n // Variant and state styling\n if (!isEnabled) {\n classes.push('border-gray-300 text-gray-400 bg-gray-100 cursor-not-allowed');\n } else {\n switch (variant) {\n case 'danger':\n classes.push(\n 'border-red-500 text-red-600 bg-red-50 hover:bg-red-100 active:bg-red-200 cursor-pointer'\n );\n break;\n case 'success':\n classes.push(\n 'border-green-500 text-green-600 bg-green-50 hover:bg-green-100 active:bg-green-200 cursor-pointer'\n );\n break;\n default:\n classes.push(\n 'border-blue-500 text-blue-600 bg-blue-50 hover:bg-blue-100 active:bg-blue-200 cursor-pointer'\n );\n break;\n }\n }\n\n return classes.join(' ');\n },\n [isMobileLayout]\n );\n\n // Calculate status indicator classes and content\n const statusIndicator = useMemo(() => {\n const classes = ['flex items-center justify-center rounded-full border-2 font-bold'];\n\n // Size based on layout\n if (isMobileLayout) {\n classes.push('w-8 h-8 text-xs');\n } else {\n classes.push('w-10 h-10 text-sm');\n }\n\n let content: string;\n let title: string;\n\n if (isSolved) {\n classes.push('border-green-500 text-green-700 bg-green-100');\n content = '✓';\n title = 'Puzzle solved!';\n } else if (isValid) {\n classes.push('border-green-500 text-green-700 bg-green-100');\n content = '✓';\n title = 'Puzzle is valid';\n } else {\n classes.push('border-red-500 text-red-700 bg-red-100');\n content = validationErrors.length.toString();\n title = `${validationErrors.length} validation error${validationErrors.length === 1 ? '' : 's'}`;\n }\n\n return {\n className: classes.join(' '),\n content,\n title\n };\n }, [isSolved, isValid, validationErrors.length, isMobileLayout]);\n\n return (\n <div\n className={containerClasses}\n data-testid=\"compact-control-ribbon\"\n role=\"toolbar\"\n aria-label=\"Puzzle controls\"\n >\n {/* Status Indicator */}\n <div\n className={statusIndicator.className}\n title={statusIndicator.title}\n aria-label={statusIndicator.title}\n data-testid=\"status-indicator\"\n >\n {statusIndicator.content}\n </div>\n\n {/* Separator */}\n <div className=\"w-px h-6 bg-gray-300\" />\n\n {/* Export Button */}\n <button\n type=\"button\"\n onClick={onExport}\n className={getButtonClasses(true, 'success')}\n title=\"Export puzzle\"\n aria-label=\"Export puzzle in compatible format\"\n data-testid=\"compact-export-button\"\n >\n 📤\n </button>\n\n {/* Combinations Button (for killer sudoku) */}\n {showCombinations && onCombinations && (\n <button\n type=\"button\"\n onClick={onCombinations}\n disabled={!canShowCombinations}\n className={getButtonClasses(canShowCombinations ?? false)}\n title={\n canShowCombinations ? 'Show cage combinations (Ctrl/Cmd+K)' : 'Select cells from a single cage'\n }\n aria-label={canShowCombinations ? 'Show combinations for selected cage' : 'No cage selected'}\n data-testid=\"compact-combinations-button\"\n >\n <svg className=\"w-5 h-5\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z\"\n />\n </svg>\n </button>\n )}\n\n {/* Reset Button */}\n {!showResetConfirm ? (\n <button\n type=\"button\"\n onClick={handleResetClick}\n disabled={!canReset}\n className={getButtonClasses(canReset, 'danger')}\n title=\"Reset puzzle\"\n aria-label=\"Clear all entries\"\n data-testid=\"compact-reset-button\"\n >\n 🗑️\n </button>\n ) : (\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n onClick={handleResetClick}\n className={getButtonClasses(true, 'danger')}\n title=\"Confirm reset - this will clear all entries\"\n aria-label=\"Confirm reset\"\n data-testid=\"compact-confirm-reset-button\"\n >\n ✓\n </button>\n <button\n type=\"button\"\n onClick={handleCancelReset}\n className={getButtonClasses(true)}\n title=\"Cancel reset\"\n aria-label=\"Cancel reset\"\n data-testid=\"compact-cancel-reset-button\"\n >\n ✕\n </button>\n </div>\n )}\n\n {/* Undo Button */}\n <button\n type=\"button\"\n onClick={onUndo}\n disabled={!canUndo}\n className={getButtonClasses(canUndo)}\n title=\"Undo last action\"\n aria-label=\"Undo last action\"\n data-testid=\"compact-undo-button\"\n >\n ↶\n </button>\n\n {/* Redo Button */}\n <button\n type=\"button\"\n onClick={onRedo}\n disabled={!canRedo}\n className={getButtonClasses(canRedo)}\n title=\"Redo last undone action\"\n aria-label=\"Redo last undone action\"\n data-testid=\"compact-redo-button\"\n >\n ↷\n </button>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,142 @@
|
|
|
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.DualKeypad = void 0;
|
|
27
|
+
const tslib_1 = require("tslib");
|
|
28
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
+
const NumberKeypad_1 = require("./NumberKeypad");
|
|
30
|
+
const useResponsiveLayout_1 = require("../hooks/useResponsiveLayout");
|
|
31
|
+
/**
|
|
32
|
+
* Dual keypad component with responsive layout for mobile and desktop sudoku input
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
const DualKeypad = ({ inputMode, onInputModeChange, onNotePress, onValuePress, onClearNotes, onClearValues, hasCellSelection, selectedCellCount, disabled = false, className, forceLayoutMode, showOverlayToggle = true }) => {
|
|
36
|
+
const responsiveLayout = (0, useResponsiveLayout_1.useResponsiveLayout)(forceLayoutMode);
|
|
37
|
+
const [isOverlayVisible, setIsOverlayVisible] = (0, react_1.useState)(false);
|
|
38
|
+
// Determine effective layout mode
|
|
39
|
+
const effectiveLayoutMode = forceLayoutMode || responsiveLayout.keypadLayoutMode;
|
|
40
|
+
// Should show the keypad based on layout mode and overlay state
|
|
41
|
+
const shouldShowKeypad = (0, react_1.useMemo)(() => {
|
|
42
|
+
if (effectiveLayoutMode === 'hidden')
|
|
43
|
+
return false;
|
|
44
|
+
if (effectiveLayoutMode === 'overlay')
|
|
45
|
+
return isOverlayVisible;
|
|
46
|
+
return true;
|
|
47
|
+
}, [effectiveLayoutMode, isOverlayVisible]);
|
|
48
|
+
// Handle note number press
|
|
49
|
+
const handleNotePress = (0, react_1.useCallback)((number) => {
|
|
50
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
51
|
+
if (disabled)
|
|
52
|
+
return;
|
|
53
|
+
onNotePress(number);
|
|
54
|
+
}, [disabled, onNotePress]);
|
|
55
|
+
// Handle value number press
|
|
56
|
+
const handleValuePress = (0, react_1.useCallback)((number) => {
|
|
57
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
58
|
+
if (disabled)
|
|
59
|
+
return;
|
|
60
|
+
onValuePress(number);
|
|
61
|
+
}, [disabled, onValuePress]);
|
|
62
|
+
// Handle clear notes
|
|
63
|
+
const handleClearNotes = (0, react_1.useCallback)(() => {
|
|
64
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
65
|
+
if (disabled)
|
|
66
|
+
return;
|
|
67
|
+
onClearNotes();
|
|
68
|
+
}, [disabled, onClearNotes]);
|
|
69
|
+
// Handle clear values
|
|
70
|
+
const handleClearValues = (0, react_1.useCallback)(() => {
|
|
71
|
+
/* c8 ignore next 1 - defense in depth: disabled buttons prevent handler calls */
|
|
72
|
+
if (disabled)
|
|
73
|
+
return;
|
|
74
|
+
onClearValues();
|
|
75
|
+
}, [disabled, onClearValues]);
|
|
76
|
+
// Toggle overlay visibility
|
|
77
|
+
const toggleOverlay = (0, react_1.useCallback)(() => {
|
|
78
|
+
setIsOverlayVisible((prev) => !prev);
|
|
79
|
+
}, []);
|
|
80
|
+
// Calculate whether to use compact mode
|
|
81
|
+
const useCompactMode = responsiveLayout.isSmallScreen || effectiveLayoutMode === 'overlay';
|
|
82
|
+
// Calculate container classes
|
|
83
|
+
const containerClasses = (0, react_1.useMemo)(() => {
|
|
84
|
+
const classes = ['flex gap-3 p-3'];
|
|
85
|
+
// Layout mode specific styles - FIXED: side-by-side should be flex-row
|
|
86
|
+
if (effectiveLayoutMode === 'side-by-side') {
|
|
87
|
+
classes.push('flex-row justify-center');
|
|
88
|
+
}
|
|
89
|
+
else if (effectiveLayoutMode === 'stacked') {
|
|
90
|
+
classes.push('flex-col');
|
|
91
|
+
}
|
|
92
|
+
else if (effectiveLayoutMode === 'overlay') {
|
|
93
|
+
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');
|
|
94
|
+
}
|
|
95
|
+
if (disabled)
|
|
96
|
+
classes.push('opacity-50 pointer-events-none');
|
|
97
|
+
if (useCompactMode)
|
|
98
|
+
classes.push('gap-2 p-2');
|
|
99
|
+
if (className)
|
|
100
|
+
classes.push(className);
|
|
101
|
+
return classes.join(' ');
|
|
102
|
+
}, [effectiveLayoutMode, disabled, useCompactMode, className]);
|
|
103
|
+
// Overlay backdrop
|
|
104
|
+
const overlayBackdrop = effectiveLayoutMode === 'overlay' && isOverlayVisible && (react_1.default.createElement("div", { className: "fixed inset-0 bg-black bg-opacity-30 z-40", onClick: toggleOverlay, "data-testid": "dual-keypad-overlay-backdrop" }));
|
|
105
|
+
// Show overlay toggle button for desktop/overlay mode
|
|
106
|
+
const overlayToggleButtonClasses = (0, react_1.useMemo)(() => {
|
|
107
|
+
const classes = [
|
|
108
|
+
'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'
|
|
109
|
+
];
|
|
110
|
+
if (isOverlayVisible)
|
|
111
|
+
classes.push('bg-red-500 hover:bg-red-600');
|
|
112
|
+
if (disabled)
|
|
113
|
+
classes.push('opacity-50 cursor-not-allowed');
|
|
114
|
+
return classes.join(' ');
|
|
115
|
+
}, [isOverlayVisible, disabled]);
|
|
116
|
+
const overlayToggleButton = (effectiveLayoutMode === 'overlay' || effectiveLayoutMode === 'hidden') &&
|
|
117
|
+
showOverlayToggle && (react_1.default.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 ? '✕' : '🔢'));
|
|
118
|
+
// Status text for multi-selection only (not single selection)
|
|
119
|
+
const statusText = (0, react_1.useMemo)(() => {
|
|
120
|
+
if (selectedCellCount > 1) {
|
|
121
|
+
return `${selectedCellCount} cells selected`;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}, [selectedCellCount]);
|
|
125
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
126
|
+
overlayBackdrop,
|
|
127
|
+
react_1.default.createElement("div", { className: containerClasses, style: { display: shouldShowKeypad ? 'flex' : 'none' }, "data-testid": "dual-keypad", role: "region", "aria-label": "Number input keypads" }, shouldShowKeypad && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
128
|
+
statusText && (react_1.default.createElement("div", { className: `text-sm text-gray-600 text-center ${effectiveLayoutMode === 'stacked' ? 'mb-2' : 'mb-3'}` }, statusText)),
|
|
129
|
+
effectiveLayoutMode !== 'side-by-side' && effectiveLayoutMode !== 'stacked' && (react_1.default.createElement("div", { className: "flex justify-center gap-3 mb-3" },
|
|
130
|
+
react_1.default.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'
|
|
131
|
+
? 'bg-blue-500 text-white border-blue-600'
|
|
132
|
+
: 'bg-gray-100 border-gray-300 hover:bg-gray-200'} ${disabled ? 'opacity-50 cursor-not-allowed' : ''}` }, "\uD83D\uDCDD Notes"),
|
|
133
|
+
react_1.default.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'
|
|
134
|
+
? 'bg-blue-500 text-white border-blue-600'
|
|
135
|
+
: 'bg-gray-100 border-gray-300 hover:bg-gray-200'} ${disabled ? 'opacity-50 cursor-not-allowed' : ''}` }, "\u270F\uFE0F Values"))),
|
|
136
|
+
react_1.default.createElement(NumberKeypad_1.NumberKeypad, { keypadType: "notes", inputMode: inputMode, isActive: true, onNumberPress: handleNotePress, onClear: handleClearNotes, disabled: disabled || !hasCellSelection, compact: useCompactMode, className: "flex-1" }),
|
|
137
|
+
react_1.default.createElement(NumberKeypad_1.NumberKeypad, { keypadType: "values", inputMode: inputMode, isActive: true, onNumberPress: handleValuePress, onClear: handleClearValues, disabled: disabled || !hasCellSelection, compact: useCompactMode, className: "flex-1" }),
|
|
138
|
+
effectiveLayoutMode === 'overlay' && (react_1.default.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"))))),
|
|
139
|
+
overlayToggleButton));
|
|
140
|
+
};
|
|
141
|
+
exports.DualKeypad = DualKeypad;
|
|
142
|
+
//# sourceMappingURL=DualKeypad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DualKeypad.js","sourceRoot":"","sources":["../../src/components/DualKeypad.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAA8D;AAE9D,iDAA8C;AAC9C,sEAAqF;AA4CrF;;;G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AE,0BAG9C,CACL,CACP;YAGD,8BAAC,2BAAY,IACX,UAAU,EAAC,OAAO,EAClB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,IAAI,EACd,aAAa,EAAE,eAAe,EAC9B,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,QAAQ,IAAI,CAAC,gBAAgB,EACvC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAC,QAAQ,GAClB;YAGF,8BAAC,2BAAY,IACX,UAAU,EAAC,QAAQ,EACnB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,IAAI,EACd,aAAa,EAAE,gBAAgB,EAC/B,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,QAAQ,IAAI,CAAC,gBAAgB,EACvC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAC,QAAQ,GAClB;YAGD,mBAAmB,KAAK,SAAS,IAAI,CACpC,0CACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,aAAa,EACtB,SAAS,EAAC,4IAA4I,gBAC3I,sBAAsB,iBACrB,mBAAmB,aAGxB,CACV,CACA,CACJ,CACG;QAEL,mBAAmB,CACnB,CACJ,CAAC;AACJ,CAAC,CAAC;AAvOW,QAAA,UAAU,cAuOrB","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"]}
|