@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,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { useMemo } from 'react';
|
|
25
|
+
/**
|
|
26
|
+
* Component for displaying the target sum of a cage in Killer Sudoku
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export const CageSumIndicator = ({ cage, currentSum, isComplete, isValid, position, className }) => {
|
|
30
|
+
// Calculate display classes based on state
|
|
31
|
+
const displayClasses = useMemo(() => {
|
|
32
|
+
const classes = ['cage-sum-indicator'];
|
|
33
|
+
/* c8 ignore next 1 - defense in depth */
|
|
34
|
+
if (className)
|
|
35
|
+
classes.push(className);
|
|
36
|
+
if (!isValid) {
|
|
37
|
+
classes.push('cage-sum-indicator--invalid');
|
|
38
|
+
}
|
|
39
|
+
else if (isComplete) {
|
|
40
|
+
classes.push('cage-sum-indicator--complete');
|
|
41
|
+
}
|
|
42
|
+
else if (currentSum !== undefined) {
|
|
43
|
+
classes.push('cage-sum-indicator--partial');
|
|
44
|
+
}
|
|
45
|
+
return classes.join(' ');
|
|
46
|
+
}, [className, isValid, isComplete, currentSum]);
|
|
47
|
+
return (React.createElement("div", { className: `
|
|
48
|
+
${displayClasses}
|
|
49
|
+
absolute z-20 pointer-events-none
|
|
50
|
+
text-xs font-bold
|
|
51
|
+
bg-white border border-gray-400 rounded px-1
|
|
52
|
+
min-w-[20px] text-center
|
|
53
|
+
shadow-sm
|
|
54
|
+
`, style: {
|
|
55
|
+
top: `${position.top}%`,
|
|
56
|
+
left: `${position.left}%`,
|
|
57
|
+
fontSize: '10px',
|
|
58
|
+
lineHeight: '16px'
|
|
59
|
+
}, "data-testid": `cage-sum-${cage.id}` },
|
|
60
|
+
React.createElement("div", { className: "text-gray-700" }, cage.total),
|
|
61
|
+
currentSum !== undefined && (React.createElement("div", { className: `
|
|
62
|
+
text-xs
|
|
63
|
+
${isValid ? 'text-blue-600' : 'text-red-600'}
|
|
64
|
+
`, style: { fontSize: '8px', lineHeight: '10px' } }, currentSum))));
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=CageSumIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CageSumIndicator.js","sourceRoot":"","sources":["../../src/components/CageSumIndicator.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGvC;;;GAGG;AACH,MAAM,CAAC,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,OAAO,CAAC,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,6BACE,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,6BAAK,SAAS,EAAC,eAAe,IAAE,IAAI,CAAC,KAAK,CAAO;QAChD,UAAU,KAAK,SAAS,IAAI,CAC3B,6BACE,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","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,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ICombinationCardProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Individual combination card component with toggle functionality
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const CombinationCard: React.NamedExoticComponent<ICombinationCardProps>;
|
|
8
|
+
//# sourceMappingURL=CombinationCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CombinationCard.d.ts","sourceRoot":"","sources":["../../src/components/CombinationCard.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,oBAAoB,CAAC,qBAAqB,CAgE3E,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { useCallback } from 'react';
|
|
25
|
+
/**
|
|
26
|
+
* Individual combination card component with toggle functionality
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export const CombinationCard = React.memo(({ combination, onToggle, className }) => {
|
|
30
|
+
const { combination: numbers, signature, isEliminated } = combination;
|
|
31
|
+
const handleClick = useCallback(() => {
|
|
32
|
+
onToggle(signature);
|
|
33
|
+
}, [onToggle, signature]);
|
|
34
|
+
const handleKeyDown = useCallback((event) => {
|
|
35
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
onToggle(signature);
|
|
38
|
+
}
|
|
39
|
+
}, [onToggle, signature]);
|
|
40
|
+
const cardClasses = [
|
|
41
|
+
'px-3 py-1',
|
|
42
|
+
'rounded border',
|
|
43
|
+
'transition-all duration-200',
|
|
44
|
+
'cursor-pointer select-none',
|
|
45
|
+
'hover:shadow-sm',
|
|
46
|
+
'focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1',
|
|
47
|
+
'inline-flex items-center justify-center',
|
|
48
|
+
isEliminated
|
|
49
|
+
? 'border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 opacity-60'
|
|
50
|
+
: 'border-blue-500 dark:border-blue-400 bg-white dark:bg-gray-800 hover:bg-blue-50 dark:hover:bg-gray-700',
|
|
51
|
+
className
|
|
52
|
+
]
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.join(' ');
|
|
55
|
+
const numberDisplay = numbers.join('');
|
|
56
|
+
const ariaLabel = numbers.join(', ');
|
|
57
|
+
return (React.createElement("button", { type: "button", className: cardClasses, onClick: handleClick, onKeyDown: handleKeyDown, "aria-pressed": isEliminated, "aria-label": `Combination ${ariaLabel}${isEliminated ? ' (eliminated)' : ''}`, role: "button" },
|
|
58
|
+
React.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)));
|
|
59
|
+
}, (prev, next) => {
|
|
60
|
+
return (prev.combination.signature === next.combination.signature &&
|
|
61
|
+
prev.combination.isEliminated === next.combination.isEliminated);
|
|
62
|
+
});
|
|
63
|
+
CombinationCard.displayName = 'CombinationCard';
|
|
64
|
+
//# sourceMappingURL=CombinationCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CombinationCard.js","sourceRoot":"","sources":["../../src/components/CombinationCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAG3C;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAC1B,KAAK,CAAC,IAAI,CACR,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;IACvC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC;IAEtE,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACtB,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAE1B,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,KAA0B,EAAE,EAAE;QAC7B,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YAC/C,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,SAAS,CAAC,CACtB,CAAC;IAEF,MAAM,WAAW,GAAW;QAC1B,WAAW;QACX,gBAAgB;QAChB,6BAA6B;QAC7B,4BAA4B;QAC5B,iBAAiB;QACjB,yEAAyE;QACzE,yCAAyC;QACzC,YAAY;YACV,CAAC,CAAC,6EAA6E;YAC/E,CAAC,CAAC,wGAAwG;QAC5G,SAAS;KACV;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO,CACL,gCACE,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,8BACE,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,eAAe,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,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ICombinationGridProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Grid layout component for displaying combination cards
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const CombinationGrid: React.FC<ICombinationGridProps>;
|
|
8
|
+
//# sourceMappingURL=CombinationGrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CombinationGrid.d.ts","sourceRoot":"","sources":["../../src/components/CombinationGrid.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqC3D,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import { CombinationCard } from './CombinationCard';
|
|
26
|
+
/**
|
|
27
|
+
* Grid layout component for displaying combination cards
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export const CombinationGrid = ({ combinations, onToggle, mode, className }) => {
|
|
31
|
+
const gridClasses = ['flex flex-wrap gap-2 p-4', 'overflow-y-auto', 'justify-start', className]
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join(' ');
|
|
34
|
+
if (combinations.length === 0) {
|
|
35
|
+
return (React.createElement("div", { className: "flex items-center justify-center p-8 text-gray-500 dark:text-gray-400" },
|
|
36
|
+
React.createElement("p", null, "No combinations available for this cage")));
|
|
37
|
+
}
|
|
38
|
+
// Sort combinations: valid ones first, then by numeric value
|
|
39
|
+
const sortedCombinations = [...combinations].sort((a, b) => {
|
|
40
|
+
// First sort by elimination status (valid ones first)
|
|
41
|
+
if (a.isEliminated !== b.isEliminated) {
|
|
42
|
+
return a.isEliminated ? 1 : -1;
|
|
43
|
+
}
|
|
44
|
+
// Then sort by the numeric value of the combination
|
|
45
|
+
const aValue = parseInt(a.combination.join(''), 10);
|
|
46
|
+
const bValue = parseInt(b.combination.join(''), 10);
|
|
47
|
+
return aValue - bValue;
|
|
48
|
+
});
|
|
49
|
+
return (React.createElement("div", { className: gridClasses }, sortedCombinations.map((combo) => (React.createElement(CombinationCard, { key: combo.signature, combination: combo, onToggle: onToggle })))));
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=CombinationGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CombinationGrid.js","sourceRoot":"","sources":["../../src/components/CombinationGrid.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,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,6BAAK,SAAS,EAAC,uEAAuE;YACpF,yEAA8C,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,6BAAK,SAAS,EAAE,WAAW,IACxB,kBAAkB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACjC,oBAAC,eAAe,IAAC,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAClF,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport React 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,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the CompactControlRibbon component
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface ICompactControlRibbonProps {
|
|
7
|
+
/** Whether undo is available */
|
|
8
|
+
readonly canUndo: boolean;
|
|
9
|
+
/** Whether redo is available */
|
|
10
|
+
readonly canRedo: boolean;
|
|
11
|
+
/** Whether reset is available */
|
|
12
|
+
readonly canReset: boolean;
|
|
13
|
+
/** Whether the puzzle is valid */
|
|
14
|
+
readonly isValid: boolean;
|
|
15
|
+
/** Whether the puzzle is solved */
|
|
16
|
+
readonly isSolved: boolean;
|
|
17
|
+
/** Validation errors for error count display */
|
|
18
|
+
readonly validationErrors: ReadonlyArray<{
|
|
19
|
+
readonly type: string;
|
|
20
|
+
readonly cellId: string;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
}>;
|
|
23
|
+
/** Callback for undo action */
|
|
24
|
+
readonly onUndo: () => void;
|
|
25
|
+
/** Callback for redo action */
|
|
26
|
+
readonly onRedo: () => void;
|
|
27
|
+
/** Callback for reset action */
|
|
28
|
+
readonly onReset: () => void;
|
|
29
|
+
/** Callback for export action */
|
|
30
|
+
readonly onExport: () => void;
|
|
31
|
+
/** Whether to show combinations button (for killer sudoku) */
|
|
32
|
+
readonly showCombinations?: boolean;
|
|
33
|
+
/** Whether combinations button should be enabled */
|
|
34
|
+
readonly canShowCombinations?: boolean;
|
|
35
|
+
/** Callback for combinations action */
|
|
36
|
+
readonly onCombinations?: () => void;
|
|
37
|
+
/** Additional CSS class name */
|
|
38
|
+
readonly className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Compact control ribbon with icon-only badges for actions and status indicator
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare const CompactControlRibbon: React.FC<ICompactControlRibbonProps>;
|
|
45
|
+
//# sourceMappingURL=CompactControlRibbon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompactControlRibbon.d.ts","sourceRoot":"","sources":["../../src/components/CompactControlRibbon.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAG9D;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,gDAAgD;IAChD,QAAQ,CAAC,gBAAgB,EAAE,aAAa,CAAC;QACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;IAEH,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;IAE5B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;IAE5B,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAE7B,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAE9B,8DAA8D;IAC9D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAEpC,oDAAoD;IACpD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAEvC,uCAAuC;IACvC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAErC,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CA6PrE,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Erik Fortune
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
25
|
+
import { useResponsiveLayout } from '../hooks/useResponsiveLayout';
|
|
26
|
+
/**
|
|
27
|
+
* Compact control ribbon with icon-only badges for actions and status indicator
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export const CompactControlRibbon = ({ canUndo, canRedo, canReset, isValid, isSolved, validationErrors, onUndo, onRedo, onReset, onExport, showCombinations, canShowCombinations, onCombinations, className }) => {
|
|
31
|
+
const [showResetConfirm, setShowResetConfirm] = useState(false);
|
|
32
|
+
const responsiveLayout = useResponsiveLayout();
|
|
33
|
+
// Handle reset with confirmation
|
|
34
|
+
const handleResetClick = useCallback(() => {
|
|
35
|
+
if (showResetConfirm) {
|
|
36
|
+
onReset();
|
|
37
|
+
setShowResetConfirm(false);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
setShowResetConfirm(true);
|
|
41
|
+
// Auto-hide confirmation after 3 seconds
|
|
42
|
+
setTimeout(() => setShowResetConfirm(false), 3000);
|
|
43
|
+
}
|
|
44
|
+
}, [showResetConfirm, onReset]);
|
|
45
|
+
// Cancel reset confirmation
|
|
46
|
+
const handleCancelReset = useCallback(() => {
|
|
47
|
+
setShowResetConfirm(false);
|
|
48
|
+
}, []);
|
|
49
|
+
// Calculate if we should use mobile layout
|
|
50
|
+
const isMobileLayout = responsiveLayout.deviceType === 'mobile' &&
|
|
51
|
+
(responsiveLayout.keypadLayoutMode === 'side-by-side' || responsiveLayout.keypadLayoutMode === 'stacked');
|
|
52
|
+
// Calculate container classes
|
|
53
|
+
const containerClasses = useMemo(() => {
|
|
54
|
+
const classes = [
|
|
55
|
+
'flex items-center justify-center gap-3 p-2 bg-gray-50 border border-gray-200 rounded-lg shadow-sm'
|
|
56
|
+
];
|
|
57
|
+
if (isMobileLayout) {
|
|
58
|
+
classes.push('gap-2 p-1.5');
|
|
59
|
+
}
|
|
60
|
+
if (className)
|
|
61
|
+
classes.push(className);
|
|
62
|
+
return classes.join(' ');
|
|
63
|
+
}, [isMobileLayout, className]);
|
|
64
|
+
// Calculate button classes
|
|
65
|
+
const getButtonClasses = useCallback((isEnabled, variant = 'default') => {
|
|
66
|
+
const classes = [
|
|
67
|
+
'flex items-center justify-center rounded-full transition-all duration-150 font-medium text-sm border-2'
|
|
68
|
+
];
|
|
69
|
+
// Size based on layout
|
|
70
|
+
if (isMobileLayout) {
|
|
71
|
+
classes.push('w-8 h-8 text-xs');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
classes.push('w-10 h-10 text-sm');
|
|
75
|
+
}
|
|
76
|
+
// Variant and state styling
|
|
77
|
+
if (!isEnabled) {
|
|
78
|
+
classes.push('border-gray-300 text-gray-400 bg-gray-100 cursor-not-allowed');
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
switch (variant) {
|
|
82
|
+
case 'danger':
|
|
83
|
+
classes.push('border-red-500 text-red-600 bg-red-50 hover:bg-red-100 active:bg-red-200 cursor-pointer');
|
|
84
|
+
break;
|
|
85
|
+
case 'success':
|
|
86
|
+
classes.push('border-green-500 text-green-600 bg-green-50 hover:bg-green-100 active:bg-green-200 cursor-pointer');
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
classes.push('border-blue-500 text-blue-600 bg-blue-50 hover:bg-blue-100 active:bg-blue-200 cursor-pointer');
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return classes.join(' ');
|
|
94
|
+
}, [isMobileLayout]);
|
|
95
|
+
// Calculate status indicator classes and content
|
|
96
|
+
const statusIndicator = useMemo(() => {
|
|
97
|
+
const classes = ['flex items-center justify-center rounded-full border-2 font-bold'];
|
|
98
|
+
// Size based on layout
|
|
99
|
+
if (isMobileLayout) {
|
|
100
|
+
classes.push('w-8 h-8 text-xs');
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
classes.push('w-10 h-10 text-sm');
|
|
104
|
+
}
|
|
105
|
+
let content;
|
|
106
|
+
let title;
|
|
107
|
+
if (isSolved) {
|
|
108
|
+
classes.push('border-green-500 text-green-700 bg-green-100');
|
|
109
|
+
content = '✓';
|
|
110
|
+
title = 'Puzzle solved!';
|
|
111
|
+
}
|
|
112
|
+
else if (isValid) {
|
|
113
|
+
classes.push('border-green-500 text-green-700 bg-green-100');
|
|
114
|
+
content = '✓';
|
|
115
|
+
title = 'Puzzle is valid';
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
classes.push('border-red-500 text-red-700 bg-red-100');
|
|
119
|
+
content = validationErrors.length.toString();
|
|
120
|
+
title = `${validationErrors.length} validation error${validationErrors.length === 1 ? '' : 's'}`;
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
className: classes.join(' '),
|
|
124
|
+
content,
|
|
125
|
+
title
|
|
126
|
+
};
|
|
127
|
+
}, [isSolved, isValid, validationErrors.length, isMobileLayout]);
|
|
128
|
+
return (React.createElement("div", { className: containerClasses, "data-testid": "compact-control-ribbon", role: "toolbar", "aria-label": "Puzzle controls" },
|
|
129
|
+
React.createElement("div", { className: statusIndicator.className, title: statusIndicator.title, "aria-label": statusIndicator.title, "data-testid": "status-indicator" }, statusIndicator.content),
|
|
130
|
+
React.createElement("div", { className: "w-px h-6 bg-gray-300" }),
|
|
131
|
+
React.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"),
|
|
132
|
+
showCombinations && onCombinations && (React.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" },
|
|
133
|
+
React.createElement("svg", { className: "w-5 h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor" },
|
|
134
|
+
React.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" })))),
|
|
135
|
+
!showResetConfirm ? (React.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.createElement("div", { className: "flex items-center gap-1" },
|
|
136
|
+
React.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"),
|
|
137
|
+
React.createElement("button", { type: "button", onClick: handleCancelReset, className: getButtonClasses(true), title: "Cancel reset", "aria-label": "Cancel reset", "data-testid": "compact-cancel-reset-button" }, "\u2715"))),
|
|
138
|
+
React.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"),
|
|
139
|
+
React.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")));
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=CompactControlRibbon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompactControlRibbon.js","sourceRoot":"","sources":["../../src/components/CompactControlRibbon.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAsDnE;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAyC,CAAC,EACzE,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACV,EAAE,EAAE;IACH,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChE,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;IAE/C,iCAAiC;IACjC,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;QACxC,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC;YACV,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAC1B,yCAAyC;YACzC,UAAU,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAA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 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,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputMode } from '../types';
|
|
3
|
+
import { KeypadLayoutMode } from '../hooks/useResponsiveLayout';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the DualKeypad component
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IDualKeypadProps {
|
|
9
|
+
/** Current input mode */
|
|
10
|
+
readonly inputMode: InputMode;
|
|
11
|
+
/** Callback when input mode changes */
|
|
12
|
+
readonly onInputModeChange: (mode: InputMode) => void;
|
|
13
|
+
/** Callback when a number is pressed for notes */
|
|
14
|
+
readonly onNotePress: (number: number) => void;
|
|
15
|
+
/** Callback when a number is pressed for values */
|
|
16
|
+
readonly onValuePress: (number: number) => void;
|
|
17
|
+
/** Callback when clear notes is pressed */
|
|
18
|
+
readonly onClearNotes: () => void;
|
|
19
|
+
/** Callback when clear values is pressed */
|
|
20
|
+
readonly onClearValues: () => void;
|
|
21
|
+
/** Whether any cells are selected */
|
|
22
|
+
readonly hasCellSelection: boolean;
|
|
23
|
+
/** Number of selected cells */
|
|
24
|
+
readonly selectedCellCount: number;
|
|
25
|
+
/** Whether the keypad is disabled */
|
|
26
|
+
readonly disabled?: boolean;
|
|
27
|
+
/** Additional CSS class name */
|
|
28
|
+
readonly className?: string;
|
|
29
|
+
/** Force a specific layout mode (overrides responsive detection) */
|
|
30
|
+
readonly forceLayoutMode?: KeypadLayoutMode;
|
|
31
|
+
/** Whether to show the overlay toggle for desktop */
|
|
32
|
+
readonly showOverlayToggle?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dual keypad component with responsive layout for mobile and desktop sudoku input
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare const DualKeypad: React.FC<IDualKeypadProps>;
|
|
39
|
+
//# sourceMappingURL=DualKeypad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DualKeypad.d.ts","sourceRoot":"","sources":["../../src/components/DualKeypad.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAuB,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B,uCAAuC;IACvC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAEtD,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAE/C,mDAAmD;IACnD,QAAQ,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhD,2CAA2C;IAC3C,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;IAElC,4CAA4C;IAC5C,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC;IAEnC,qCAAqC;IACrC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IAEnC,+BAA+B;IAC/B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAEnC,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,oEAAoE;IACpE,QAAQ,CAAC,eAAe,CAAC,EAAE,gBAAgB,CAAC;IAE5C,qDAAqD;IACrD,QAAQ,CAAC,iBAAiB,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