@fgv/ts-sudoku-ui 5.1.0-2 → 5.1.0-21
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/eslint.config.js +18 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +22 -21
- package/.test-failures-catalog.md +0 -470
- package/CHANGELOG.md +0 -11
- package/CSS_MODULES_MIGRATION_SUMMARY.md +0 -189
- package/dist/ts-sudoku-ui.d.ts +0 -668
- package/etc/ts-sudoku-ui.api.md +0 -481
- package/lib/test/fixtures/killerSudokuPuzzles.d.ts +0 -36
- package/lib/test/fixtures/killerSudokuPuzzles.d.ts.map +0 -1
- package/lib/test/fixtures/killerSudokuPuzzles.js +0 -57
- package/lib/test/fixtures/killerSudokuPuzzles.js.map +0 -1
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.d.ts +0 -22
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.d.ts.map +0 -1
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.js +0 -116
- package/lib/test/unit/components/SudokuGridEntry.testHelpers.js.map +0 -1
- package/lib-commonjs/components/CageOverlay.js +0 -138
- package/lib-commonjs/components/CageOverlay.js.map +0 -1
- package/lib-commonjs/components/CageSumIndicator.js +0 -71
- package/lib-commonjs/components/CageSumIndicator.js.map +0 -1
- package/lib-commonjs/components/CombinationCard.js +0 -68
- package/lib-commonjs/components/CombinationCard.js.map +0 -1
- package/lib-commonjs/components/CombinationGrid.js +0 -56
- package/lib-commonjs/components/CombinationGrid.js.map +0 -1
- package/lib-commonjs/components/CompactControlRibbon.js +0 -146
- package/lib-commonjs/components/CompactControlRibbon.js.map +0 -1
- package/lib-commonjs/components/DualKeypad.js +0 -142
- package/lib-commonjs/components/DualKeypad.js.map +0 -1
- package/lib-commonjs/components/KillerCombinationsExplorer.js +0 -74
- package/lib-commonjs/components/KillerCombinationsExplorer.js.map +0 -1
- package/lib-commonjs/components/KillerCombinationsModal.js +0 -140
- package/lib-commonjs/components/KillerCombinationsModal.js.map +0 -1
- package/lib-commonjs/components/KillerCombinationsPanel.js +0 -84
- package/lib-commonjs/components/KillerCombinationsPanel.js.map +0 -1
- package/lib-commonjs/components/NumberKeypad.js +0 -186
- package/lib-commonjs/components/NumberKeypad.js.map +0 -1
- package/lib-commonjs/components/SudokuCell.js +0 -245
- package/lib-commonjs/components/SudokuCell.js.map +0 -1
- package/lib-commonjs/components/SudokuControls.js +0 -145
- package/lib-commonjs/components/SudokuControls.js.map +0 -1
- package/lib-commonjs/components/SudokuGrid.js +0 -182
- package/lib-commonjs/components/SudokuGrid.js.map +0 -1
- package/lib-commonjs/components/SudokuGridEntry.js +0 -378
- package/lib-commonjs/components/SudokuGridEntry.js.map +0 -1
- package/lib-commonjs/components/ValidationDisplay.js +0 -100
- package/lib-commonjs/components/ValidationDisplay.js.map +0 -1
- package/lib-commonjs/contexts/DiagnosticLoggerContext.js +0 -104
- package/lib-commonjs/contexts/DiagnosticLoggerContext.js.map +0 -1
- package/lib-commonjs/contexts/index.js +0 -32
- package/lib-commonjs/contexts/index.js.map +0 -1
- package/lib-commonjs/hooks/useCombinationElimination.js +0 -126
- package/lib-commonjs/hooks/useCombinationElimination.js.map +0 -1
- package/lib-commonjs/hooks/useKeyboardShortcut.js +0 -58
- package/lib-commonjs/hooks/useKeyboardShortcut.js.map +0 -1
- package/lib-commonjs/hooks/useKillerCombinations.js +0 -68
- package/lib-commonjs/hooks/useKillerCombinations.js.map +0 -1
- package/lib-commonjs/hooks/useLongPress.js +0 -72
- package/lib-commonjs/hooks/useLongPress.js.map +0 -1
- package/lib-commonjs/hooks/usePuzzleSession.js +0 -401
- package/lib-commonjs/hooks/usePuzzleSession.js.map +0 -1
- package/lib-commonjs/hooks/useResponsiveLayout.js +0 -142
- package/lib-commonjs/hooks/useResponsiveLayout.js.map +0 -1
- package/lib-commonjs/index.browser.js +0 -29
- package/lib-commonjs/index.browser.js.map +0 -1
- package/lib-commonjs/index.js +0 -73
- package/lib-commonjs/index.js.map +0 -1
- package/lib-commonjs/test/fixtures/killerSudokuPuzzles.js +0 -60
- package/lib-commonjs/test/fixtures/killerSudokuPuzzles.js.map +0 -1
- package/lib-commonjs/test/unit/components/SudokuGridEntry.testHelpers.js +0 -125
- package/lib-commonjs/test/unit/components/SudokuGridEntry.testHelpers.js.map +0 -1
- package/lib-commonjs/types/index.js +0 -26
- package/lib-commonjs/types/index.js.map +0 -1
- package/lib-commonjs/utils/CageLookupManager.js +0 -287
- package/lib-commonjs/utils/CageLookupManager.js.map +0 -1
- package/lib-commonjs/utils/CagePatternManager.js +0 -143
- package/lib-commonjs/utils/CagePatternManager.js.map +0 -1
- package/lib-commonjs/utils/puzzleDefinitionHelper.js +0 -103
- package/lib-commonjs/utils/puzzleDefinitionHelper.js.map +0 -1
|
@@ -1,146 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompactControlRibbon.js","sourceRoot":"","sources":["../../src/components/CompactControlRibbon.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAA8D;AAC9D,sEAAmE;AAsDnE;;;GAGG;AACI,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,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAChE,MAAM,gBAAgB,GAAG,IAAA,yCAAmB,GAAE,CAAC;IAE/C,iCAAiC;IACjC,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,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,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;IACH,CAAC,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,C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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"]}
|
|
@@ -1,142 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DualKeypad.js","sourceRoot":"","sources":["../../src/components/DualKeypad.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAA8D;AAE9D,iDAA8C;AAC9C,sEAAqF;AA4CrF;;;GAGG;AACI,MAAM,UAAU,GAA+B,CAAC,EACrD,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,eAAe,EACf,iBAAiB,GAAG,IAAI,EACzB,EAAE,EAAE;IACH,MAAM,gBAAgB,GAAG,IAAA,yCAAmB,EAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEhE,kCAAkC;IAClC,MAAM,mBAAmB,GAAG,eAAe,IAAI,gBAAgB,CAAC,gBAAgB,CAAC;IAEjF,gEAAgE;IAChE,MAAM,gBAAgB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACpC,IAAI,mBAAmB,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACnD,IAAI,mBAAmB,KAAK,SAAS;YAAE,OAAO,gBAAgB,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE5C,2BAA2B;IAC3B,MAAM,eAAe,GAAG,IAAA,mBAA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* 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"]}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2023 Erik Fortune
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.KillerCombinationsExplorer = void 0;
|
|
27
|
-
const tslib_1 = require("tslib");
|
|
28
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
-
const useKillerCombinations_1 = require("../hooks/useKillerCombinations");
|
|
30
|
-
const useCombinationElimination_1 = require("../hooks/useCombinationElimination");
|
|
31
|
-
const useResponsiveLayout_1 = require("../hooks/useResponsiveLayout");
|
|
32
|
-
const KillerCombinationsPanel_1 = require("./KillerCombinationsPanel");
|
|
33
|
-
const KillerCombinationsModal_1 = require("./KillerCombinationsModal");
|
|
34
|
-
/**
|
|
35
|
-
* Main killer combinations explorer container component
|
|
36
|
-
* Automatically switches between panel (desktop) and modal (mobile) based on screen size
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
const KillerCombinationsExplorer = ({ selectedCage, puzzleId, isOpen, onClose, mobileBreakpoint = 1024, className }) => {
|
|
40
|
-
const { screenWidth } = (0, useResponsiveLayout_1.useResponsiveLayout)();
|
|
41
|
-
// Determine display mode based on screen width
|
|
42
|
-
const mode = screenWidth >= mobileBreakpoint ? 'panel' : 'modal';
|
|
43
|
-
// Get combinations for the selected cage
|
|
44
|
-
const combinationsResult = (0, useKillerCombinations_1.useKillerCombinations)(selectedCage);
|
|
45
|
-
// Get cage ID for storage
|
|
46
|
-
const cageId = selectedCage?.id;
|
|
47
|
-
// Get elimination state
|
|
48
|
-
const { eliminatedSignatures, toggleElimination } = (0, useCombinationElimination_1.useCombinationElimination)(puzzleId, cageId);
|
|
49
|
-
// Merge combinations with elimination state
|
|
50
|
-
const displayCombinations = (0, react_1.useMemo)(() => {
|
|
51
|
-
if (combinationsResult.isFailure()) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
return combinationsResult.value.map((combo) => ({
|
|
55
|
-
...combo,
|
|
56
|
-
isEliminated: eliminatedSignatures.has(combo.signature)
|
|
57
|
-
}));
|
|
58
|
-
}, [combinationsResult, eliminatedSignatures]);
|
|
59
|
-
// Don't render if not open or no cage selected
|
|
60
|
-
if (!isOpen || !selectedCage) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
// Don't render if combinations failed to load
|
|
64
|
-
if (combinationsResult.isFailure()) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
// Render panel or modal based on mode
|
|
68
|
-
if (mode === 'panel') {
|
|
69
|
-
return (react_1.default.createElement(KillerCombinationsPanel_1.KillerCombinationsPanel, { cage: selectedCage, combinations: displayCombinations, onToggle: toggleElimination, onClose: onClose, isOpen: isOpen, className: className }));
|
|
70
|
-
}
|
|
71
|
-
return (react_1.default.createElement(KillerCombinationsModal_1.KillerCombinationsModal, { cage: selectedCage, combinations: displayCombinations, onToggle: toggleElimination, onClose: onClose, isOpen: isOpen, className: className }));
|
|
72
|
-
};
|
|
73
|
-
exports.KillerCombinationsExplorer = KillerCombinationsExplorer;
|
|
74
|
-
//# sourceMappingURL=KillerCombinationsExplorer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KillerCombinationsExplorer.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsExplorer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAAuC;AAEvC,0EAAuE;AACvE,kFAA+E;AAC/E,sEAAmE;AACnE,uEAAoE;AACpE,uEAAoE;AAEpE;;;;GAIG;AACI,MAAM,0BAA0B,GAA+C,CAAC,EACrF,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,gBAAgB,GAAG,IAAI,EACvB,SAAS,EACV,EAAE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AE,iBAAiB,EAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,8BAAC,iDAAuB,IACtB,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;AACJ,CAAC,CAAC;AApEW,QAAA,0BAA0B,8BAoErC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport React, { useMemo } from 'react';\nimport { IKillerCombinationsExplorerProps, IKillerCombinationsMode } from '../types';\nimport { useKillerCombinations } from '../hooks/useKillerCombinations';\nimport { useCombinationElimination } from '../hooks/useCombinationElimination';\nimport { useResponsiveLayout } from '../hooks/useResponsiveLayout';\nimport { KillerCombinationsPanel } from './KillerCombinationsPanel';\nimport { KillerCombinationsModal } from './KillerCombinationsModal';\n\n/**\n * Main killer combinations explorer container component\n * Automatically switches between panel (desktop) and modal (mobile) based on screen size\n * @public\n */\nexport const KillerCombinationsExplorer: React.FC<IKillerCombinationsExplorerProps> = ({\n selectedCage,\n puzzleId,\n isOpen,\n onClose,\n mobileBreakpoint = 1024,\n className\n}) => {\n const { screenWidth } = useResponsiveLayout();\n\n // Determine display mode based on screen width\n const mode: IKillerCombinationsMode = screenWidth >= mobileBreakpoint ? 'panel' : 'modal';\n\n // Get combinations for the selected cage\n const combinationsResult = useKillerCombinations(selectedCage);\n\n // Get cage ID for storage\n const cageId = selectedCage?.id;\n\n // Get elimination state\n const { eliminatedSignatures, toggleElimination } = useCombinationElimination(puzzleId, cageId);\n\n // Merge combinations with elimination state\n const displayCombinations = useMemo(() => {\n if (combinationsResult.isFailure()) {\n return [];\n }\n\n return combinationsResult.value.map((combo) => ({\n ...combo,\n isEliminated: eliminatedSignatures.has(combo.signature)\n }));\n }, [combinationsResult, eliminatedSignatures]);\n\n // Don't render if not open or no cage selected\n if (!isOpen || !selectedCage) {\n return null;\n }\n\n // Don't render if combinations failed to load\n if (combinationsResult.isFailure()) {\n return null;\n }\n\n // Render panel or modal based on mode\n if (mode === 'panel') {\n return (\n <KillerCombinationsPanel\n cage={selectedCage}\n combinations={displayCombinations}\n onToggle={toggleElimination}\n onClose={onClose}\n isOpen={isOpen}\n className={className}\n />\n );\n }\n\n return (\n <KillerCombinationsModal\n cage={selectedCage}\n combinations={displayCombinations}\n onToggle={toggleElimination}\n onClose={onClose}\n isOpen={isOpen}\n className={className}\n />\n );\n};\n"]}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2023 Erik Fortune
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.KillerCombinationsModal = void 0;
|
|
27
|
-
const tslib_1 = require("tslib");
|
|
28
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
29
|
-
const CombinationGrid_1 = require("./CombinationGrid");
|
|
30
|
-
/**
|
|
31
|
-
* Mobile modal variant for killer combinations explorer
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
const KillerCombinationsModal = ({ cage, combinations, onToggle, onClose, isOpen, className }) => {
|
|
35
|
-
const modalRef = (0, react_1.useRef)(null);
|
|
36
|
-
// Handle Escape key to close
|
|
37
|
-
(0, react_1.useEffect)(() => {
|
|
38
|
-
const handleEscape = (event) => {
|
|
39
|
-
if (event.key === 'Escape') {
|
|
40
|
-
onClose();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
if (isOpen) {
|
|
44
|
-
window.addEventListener('keydown', handleEscape);
|
|
45
|
-
return () => window.removeEventListener('keydown', handleEscape);
|
|
46
|
-
}
|
|
47
|
-
}, [isOpen, onClose]);
|
|
48
|
-
// Lock body scroll when modal is open
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
50
|
-
if (isOpen) {
|
|
51
|
-
const originalOverflow = document.body.style.overflow;
|
|
52
|
-
document.body.style.overflow = 'hidden';
|
|
53
|
-
return () => {
|
|
54
|
-
document.body.style.overflow = originalOverflow;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}, [isOpen]);
|
|
58
|
-
// Focus trap and initial focus
|
|
59
|
-
(0, react_1.useEffect)(() => {
|
|
60
|
-
if (isOpen && modalRef.current) {
|
|
61
|
-
const focusableElements = modalRef.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
62
|
-
const firstElement = focusableElements[0];
|
|
63
|
-
const lastElement = focusableElements[focusableElements.length - 1];
|
|
64
|
-
firstElement?.focus();
|
|
65
|
-
const handleTab = (event) => {
|
|
66
|
-
if (event.key === 'Tab') {
|
|
67
|
-
if (event.shiftKey) {
|
|
68
|
-
if (document.activeElement === firstElement) {
|
|
69
|
-
event.preventDefault();
|
|
70
|
-
lastElement?.focus();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
if (document.activeElement === lastElement) {
|
|
75
|
-
event.preventDefault();
|
|
76
|
-
firstElement?.focus();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
window.addEventListener('keydown', handleTab);
|
|
82
|
-
return () => window.removeEventListener('keydown', handleTab);
|
|
83
|
-
}
|
|
84
|
-
}, [isOpen]);
|
|
85
|
-
if (!isOpen) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
const activeCount = combinations.filter((c) => !c.isEliminated).length;
|
|
89
|
-
const totalCount = combinations.length;
|
|
90
|
-
/* c8 ignore next 1 - defense in depth */
|
|
91
|
-
const opacity = isOpen ? 'opacity-100' : 'opacity-0 pointer-events-none';
|
|
92
|
-
const overlayClasses = [
|
|
93
|
-
'fixed inset-0 z-[9999]',
|
|
94
|
-
'flex items-end sm:items-center justify-center',
|
|
95
|
-
'p-4',
|
|
96
|
-
'bg-black bg-opacity-40',
|
|
97
|
-
'transition-opacity duration-300',
|
|
98
|
-
opacity
|
|
99
|
-
]
|
|
100
|
-
.filter(Boolean)
|
|
101
|
-
.join(' ');
|
|
102
|
-
/* c8 ignore next 1 - defense in depth */
|
|
103
|
-
const translation = isOpen ? 'translate-y-0' : 'translate-y-full';
|
|
104
|
-
const dialogClasses = [
|
|
105
|
-
'bg-white dark:bg-gray-900',
|
|
106
|
-
'rounded-t-2xl sm:rounded-2xl',
|
|
107
|
-
'w-full max-w-lg',
|
|
108
|
-
'max-h-[85vh]',
|
|
109
|
-
'overflow-hidden',
|
|
110
|
-
'flex flex-col',
|
|
111
|
-
'shadow-2xl',
|
|
112
|
-
'transform transition-transform duration-300',
|
|
113
|
-
translation,
|
|
114
|
-
className
|
|
115
|
-
]
|
|
116
|
-
.filter(Boolean)
|
|
117
|
-
.join(' ');
|
|
118
|
-
return (react_1.default.createElement("div", { className: overlayClasses, onClick: onClose, role: "presentation" },
|
|
119
|
-
react_1.default.createElement("div", { ref: modalRef, className: dialogClasses, onClick: (e) => e.stopPropagation(), role: "dialog", "aria-modal": "true", "aria-labelledby": "modal-title", "aria-describedby": "modal-description" },
|
|
120
|
-
react_1.default.createElement("div", { className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700" },
|
|
121
|
-
react_1.default.createElement("div", null,
|
|
122
|
-
react_1.default.createElement("h2", { id: "modal-title", className: "text-lg font-semibold text-gray-900 dark:text-gray-100" }, "Combinations"),
|
|
123
|
-
react_1.default.createElement("p", { id: "modal-description", className: "text-sm text-gray-500 dark:text-gray-400" },
|
|
124
|
-
cage.numCells,
|
|
125
|
-
" cells, sum ",
|
|
126
|
-
cage.total)),
|
|
127
|
-
react_1.default.createElement("button", { type: "button", onClick: onClose, className: "p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors", "aria-label": "Close combinations modal" },
|
|
128
|
-
react_1.default.createElement("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
129
|
-
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })))),
|
|
130
|
-
react_1.default.createElement("div", { className: "px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700" },
|
|
131
|
-
react_1.default.createElement("p", { className: "text-xs text-gray-600 dark:text-gray-400" },
|
|
132
|
-
activeCount,
|
|
133
|
-
" of ",
|
|
134
|
-
totalCount,
|
|
135
|
-
" combinations possible")),
|
|
136
|
-
react_1.default.createElement("div", { className: "flex-1 overflow-hidden" },
|
|
137
|
-
react_1.default.createElement(CombinationGrid_1.CombinationGrid, { combinations: combinations, onToggle: onToggle, mode: "modal" })))));
|
|
138
|
-
};
|
|
139
|
-
exports.KillerCombinationsModal = KillerCombinationsModal;
|
|
140
|
-
//# sourceMappingURL=KillerCombinationsModal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KillerCombinationsModal.js","sourceRoot":"","sources":["../../src/components/KillerCombinationsModal.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;AAEH,uDAAiD;AAGjD,uDAAoD;AAcpD;;;GAGG;AACI,MAAM,uBAAuB,GAA4C,CAAC,EAC/E,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,SAAS,EACV,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,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K,SAAS,EAAC,qFAAqF;gBAClG,qCAAG,SAAS,EAAC,0CAA0C;oBACpD,WAAW;;oBAAM,UAAU;6CAC1B,CACA;YAGN,uCAAK,SAAS,EAAC,wBAAwB;gBACrC,8BAAC,iCAAe,IAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,CAC5E,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAvJW,QAAA,uBAAuB,2BAuJlC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport React, { useEffect, useRef } from 'react';\nimport { ICage } from '@fgv/ts-sudoku-lib';\nimport { ICombinationDisplayInfo } from '../types';\nimport { CombinationGrid } from './CombinationGrid';\n\n/**\n * Props for the KillerCombinationsModal component\n */\nexport interface IKillerCombinationsModalProps {\n readonly cage: ICage;\n readonly combinations: ICombinationDisplayInfo[];\n readonly onToggle: (signature: string) => void;\n readonly onClose: () => void;\n readonly isOpen: boolean;\n readonly className?: string;\n}\n\n/**\n * Mobile modal variant for killer combinations explorer\n * @public\n */\nexport const KillerCombinationsModal: React.FC<IKillerCombinationsModalProps> = ({\n cage,\n combinations,\n onToggle,\n onClose,\n isOpen,\n className\n}) => {\n const modalRef = useRef<HTMLDivElement>(null);\n\n // Handle Escape key to close\n useEffect(() => {\n const handleEscape = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') {\n onClose();\n }\n };\n\n if (isOpen) {\n window.addEventListener('keydown', handleEscape);\n return () => window.removeEventListener('keydown', handleEscape);\n }\n }, [isOpen, onClose]);\n\n // Lock body scroll when modal is open\n useEffect(() => {\n if (isOpen) {\n const originalOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n return () => {\n document.body.style.overflow = originalOverflow;\n };\n }\n }, [isOpen]);\n\n // Focus trap and initial focus\n useEffect(() => {\n if (isOpen && modalRef.current) {\n const focusableElements = modalRef.current.querySelectorAll<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n );\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n firstElement?.focus();\n\n const handleTab = (event: KeyboardEvent): void => {\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n if (document.activeElement === firstElement) {\n event.preventDefault();\n lastElement?.focus();\n }\n } else {\n if (document.activeElement === lastElement) {\n event.preventDefault();\n firstElement?.focus();\n }\n }\n }\n };\n\n window.addEventListener('keydown', handleTab);\n return () => window.removeEventListener('keydown', handleTab);\n }\n }, [isOpen]);\n\n if (!isOpen) {\n return null;\n }\n\n const activeCount = combinations.filter((c) => !c.isEliminated).length;\n const totalCount = combinations.length;\n\n /* c8 ignore next 1 - defense in depth */\n const opacity = isOpen ? 'opacity-100' : 'opacity-0 pointer-events-none';\n const overlayClasses = [\n 'fixed inset-0 z-[9999]',\n 'flex items-end sm:items-center justify-center',\n 'p-4',\n 'bg-black bg-opacity-40',\n 'transition-opacity duration-300',\n opacity\n ]\n .filter(Boolean)\n .join(' ');\n\n /* c8 ignore next 1 - defense in depth */\n const translation = isOpen ? 'translate-y-0' : 'translate-y-full';\n const dialogClasses = [\n 'bg-white dark:bg-gray-900',\n 'rounded-t-2xl sm:rounded-2xl',\n 'w-full max-w-lg',\n 'max-h-[85vh]',\n 'overflow-hidden',\n 'flex flex-col',\n 'shadow-2xl',\n 'transform transition-transform duration-300',\n translation,\n className\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div className={overlayClasses} onClick={onClose} role=\"presentation\">\n <div\n ref={modalRef}\n className={dialogClasses}\n onClick={(e) => e.stopPropagation()}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"modal-title\"\n aria-describedby=\"modal-description\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700\">\n <div>\n <h2 id=\"modal-title\" className=\"text-lg font-semibold text-gray-900 dark:text-gray-100\">\n Combinations\n </h2>\n <p id=\"modal-description\" className=\"text-sm text-gray-500 dark:text-gray-400\">\n {cage.numCells} cells, sum {cage.total}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors\"\n aria-label=\"Close combinations modal\"\n >\n <svg className=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n </div>\n\n {/* Stats */}\n <div className=\"px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700\">\n <p className=\"text-xs text-gray-600 dark:text-gray-400\">\n {activeCount} of {totalCount} combinations possible\n </p>\n </div>\n\n {/* Combinations Grid */}\n <div className=\"flex-1 overflow-hidden\">\n <CombinationGrid combinations={combinations} onToggle={onToggle} mode=\"modal\" />\n </div>\n </div>\n </div>\n );\n};\n"]}
|