Skip to content

Commit

Permalink
v0.35.0: multiselect
Browse files Browse the repository at this point in the history
  • Loading branch information
icecream17 authored Feb 26, 2024
1 parent a6e44f7 commit 836352d
Show file tree
Hide file tree
Showing 26 changed files with 382 additions and 158 deletions.
8 changes: 1 addition & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
// "hardcore/ts",
"react-app",
"react-app/jest",
"plugin:flowtype/recommended",
// "plugin:import/recommended",
"plugin:jsx-a11y/strict",
"plugin:jest/recommended",
"plugin:jest/style",
Expand All @@ -32,8 +30,6 @@
"project": "./tsconfig.json"
},
"plugins": [
"flowtype",
// "import",
"jsx-a11y",
"jest",
"jest-dom",
Expand All @@ -60,9 +56,6 @@
"prefer-spread": "warn",


"import/no-unused-modules": "off",


"jest/no-commented-out-tests": "warn",
"jest/no-identical-title": "warn",
"jest/prefer-called-with": "warn",
Expand All @@ -86,6 +79,7 @@

"@typescript-eslint/no-invalid-this": "warn",
"@typescript-eslint/no-invalid-void-type": "warn",
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_", "varsIgnorePattern": "^_"}],
"@typescript-eslint/prefer-enum-initializers": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ Note: Many earlier versions are not specified, that's too much work.

When a `@types` dependency updates, they almost always don't affect anything.

## v0.35.0

- (use) Multiselectable cells! Select multiple cells at the same time with <kbd>Ctrl</kbd>+Click
- Instead of being turned off, a selection will be disabled when clicking off. This is to prepare for the on-screen keyboard later.
- (use) Diagonal keyboard movement!!! Holding <kbd>Up</kbd> and <kbd>Left</kbd> at the same time will now go both directions!
- (use) When editing a cell: the functions of <kbd>Backspace</kbd> and
(<kbd>Shift</kbd> or <kbd>Ctrl</kbd>)+<kbd>Backspace</kbd> have been switched.
- Previously, <kbd>Backspace</kbd> would delete all candidates. Now it adds back all candidates.
- _Additionally_ it sets `pretend` to `true`, so it will still change to a single digit when typing.
- (<kbd>Shift</kbd> or <kbd>Ctrl</kbd>)+<kbd>Backspace</kbd> used to add back all candidates;
now it deletes all candidates.
- (use-bug) Previously, if a bunch of keypresses happen to cause a cell to end up at 9 candidates again,
it was not a condition to `pretend` as described above. Now it is. Personally, despite my extensive usage,
this edge-case has not been run into yet so I do not know if this should be reimplemented.
- (temp-docs) The way the Tabs and the Cells handle multiple keypresses at the same time is different.
Specifically, Cells use a global event handler, while Tabs only have a local event handler.
This means that for example, holding down two keys then focusing the Tabs, the Tabs would only have one key stored on repeat.

## v0.34.0

- (use) Add "explanations" for some strategies.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solver",
"version": "0.34.0",
"version": "0.35.0",
"private": true,
"homepage": "https://icecream17.github.io/solver",
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion src/Api/Spaces/PureSudoku.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import { ALL_CANDIDATES, GrpTyp, IndexToNine, INDICES_TO_NINE, SudokuDigits, ThreeDimensionalArray } from "../../Types"
import { boxAt, CellID, id, to9by9 } from "../Utils"

Expand Down
23 changes: 16 additions & 7 deletions src/Api/Spaces/Sudoku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import Cell from "../../Elems/MainElems/Cell"
import { IndexToNine, SudokuDigits, TwoDimensionalArray } from "../../Types"
import PureSudoku from "./PureSudoku"

/**
* Wraps PureSudoku, to sync the data with the Cell components.
*
* It is also used by the Sudoku component to indirectly access the Cell components. -.-
*
* For sanity, this class should be kept very simple.
*/
export default class Sudoku extends PureSudoku {
cells: TwoDimensionalArray<Cell | undefined | null>
constructor (...args: ConstructorParameters<typeof PureSudoku>) {
Expand Down Expand Up @@ -32,9 +39,16 @@ export default class Sudoku extends PureSudoku {
}
}

override clearCell(x: IndexToNine, y: IndexToNine) {
this.data[x][y] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
this.cells[x][y]?.clearCandidates()
}

/**
* Used for initialization but could also update things
* That's pretty complicated
* Used for Cell initialization
*
* An alternate possibility is having the cell reflect the data, but
* that allows inconsistencies between the visuals and the data.
*/
addCell(cell: Cell) {
this.cells[cell.props.row][cell.props.column] = cell
Expand All @@ -45,9 +59,4 @@ export default class Sudoku extends PureSudoku {
this.cells[cell.props.row][cell.props.column] = undefined
// this.data[cell.props.row][cell.props.column] = cell.state.candidates
}

clearCell(x: IndexToNine, y: IndexToNine) {
this.data[x][y] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
this.cells[x][y]?.clearCandidates()
}
}
2 changes: 1 addition & 1 deletion src/Api/Strategies/pairsTriplesAndQuads.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @flow


import { AlertType, SudokuDigits } from "../../Types";
import { convertArrayToEnglishList } from "../../utils";
Expand Down
2 changes: 0 additions & 2 deletions src/Api/Types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import { SudokuDigits } from "../Types";
import PureSudoku from "./Spaces/PureSudoku";
import { CellID } from "./Utils";
Expand Down
2 changes: 0 additions & 2 deletions src/Api/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import { AlgebraicName, BoxName, BOX_NAMES, COLUMN_NAMES, IndexTo81, IndexToNine, INDICES_TO_NINE, ROW_NAMES, SudokuDigits, ThreeDimensionalArray, TwoDimensionalArray, GrpTyp } from "../Types";

export function algebraic (row: IndexToNine, column: IndexToNine): AlgebraicName {
Expand Down
12 changes: 12 additions & 0 deletions src/Api/boards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,17 @@ export default {
.....4.2.
..85..7..
....2...1
`,

"impossible": `
.....9...
.41....8.
.5..27...
.......5.
3..2.....
.2..6.4..
....5....
81......4
...8..2.7
`
} as const
12 changes: 7 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import GithubCorner from './Elems/GithubCorner'
import Cell from './Elems/MainElems/Cell'
import Title from './Elems/Title'
import Version from './Elems/Version'
import { SudokuProps } from './Elems/MainElems/Sudoku'

declare global {
interface Window {
Expand All @@ -22,8 +23,8 @@ declare global {
}

interface Set<T> {
has (value: unknown): CouldAIsB<typeof value, T>
delete (value: unknown): CouldAIsB<typeof value, T>
has(value: unknown): CouldAIsB<typeof value, T>
delete(value: unknown): CouldAIsB<typeof value, T>
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars --- I can't prefix this with an underscore, _typescript_
Expand Down Expand Up @@ -52,7 +53,7 @@ type AppState = {
class App extends React.Component<_UnusedProps, AppState> {
sudoku: SudokuData
solver: Solver
propsPassedDown: { whenCellMounts: (cell: Cell) => void; whenCellUnmounts: (cell: Cell) => void; whenCellUpdates: (cell: Cell, candidates: SudokuDigits[]) => void }
sudokuProps: SudokuProps
constructor(props: _UnusedProps) {
super(props)

Expand Down Expand Up @@ -80,7 +81,8 @@ class App extends React.Component<_UnusedProps, AppState> {
this.whenCellUnmounts = this.whenCellUnmounts.bind(this)
this.whenCellUpdates = this.whenCellUpdates.bind(this)
this.finishNotice = this.finishNotice.bind(this)
this.propsPassedDown = {
this.sudokuProps = {
sudoku: this.sudoku,
whenCellMounts: this.whenCellMounts,
whenCellUnmounts: this.whenCellUnmounts,
whenCellUpdates: this.whenCellUpdates,
Expand All @@ -103,7 +105,7 @@ class App extends React.Component<_UnusedProps, AppState> {
<Title />
<Version />
</header>
<Main propsPassedDown={this.propsPassedDown} />
<Main sudokuProps={this.sudokuProps} />
<Aside sudoku={this.sudoku} solver={this.solver} />

<GithubCorner />
Expand Down
2 changes: 0 additions & 2 deletions src/Elems/AsideElems/StrategyItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import './StrategyItem.css'
import React from 'react';
import StrategyLabel, { StrategyLabelProps } from './StrategyLabel';
Expand Down
2 changes: 0 additions & 2 deletions src/Elems/AsideElems/StrategyLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import React from 'react';
import ExternalLink from '../ExternalLink';

Expand Down
2 changes: 0 additions & 2 deletions src/Elems/AsideElems/StrategyStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import React from 'react';
import { SuccessError } from '../../Api/Types';

Expand Down
2 changes: 0 additions & 2 deletions src/Elems/AsideElems/StrategyTogglerLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import React from 'react';

export type StrategyTogglerLabelProps = Readonly<{
Expand Down
8 changes: 4 additions & 4 deletions src/Elems/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import './Main.css'
import React from 'react'

import Sudoku, { BaseSudokuProps } from './MainElems/Sudoku'
import Sudoku, { SudokuProps } from './MainElems/Sudoku'

type MainProps = Readonly<{
propsPassedDown: BaseSudokuProps
sudokuProps: SudokuProps
}>

/**
Expand All @@ -14,7 +14,7 @@ type MainProps = Readonly<{
export default function Main (props: MainProps) {
return (
<main className="App-main">
<Sudoku {...props.propsPassedDown} />
<Sudoku {...props.sudokuProps} />
</main>
);
)
}
Loading

0 comments on commit 836352d

Please sign in to comment.