scrabble-solver 2.18.0 → 2.18.2
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/.nx/workspace-data/d/server-process.json +2 -2
- package/.nx/workspace-data/file-map.json +1652 -1412
- package/.nx/workspace-data/lockfile-dependencies.hash +1 -1
- package/.nx/workspace-data/lockfile-nodes.hash +1 -1
- package/.nx/workspace-data/nx_files.nxt +0 -0
- package/.nx/workspace-data/parsed-lock-file.dependencies.json +184 -209
- package/.nx/workspace-data/parsed-lock-file.nodes.json +374 -419
- package/.nx/workspace-data/project-graph.json +669 -670
- package/.nx/workspace-data/source-maps.json +236 -0
- package/CLAUDE.md +13 -11
- package/README.md +2 -2
- package/bun.lock +115 -130
- package/e2e/app.spec.ts +1 -1
- package/e2e/bugs/398-digraphs-in-created-words.spec.ts +2 -2
- package/e2e/bugs/445-tile-text-selection.spec.ts +38 -0
- package/e2e/bugs/451-results-list-gap-hover.spec.ts +35 -0
- package/e2e/bugs/452-stale-translations-cache.spec.ts +32 -0
- package/e2e/features/427-highlight-created-words.spec.ts +86 -0
- package/e2e/features/430-highlight-unreachable-cells-results.spec.ts +75 -0
- package/e2e/features/91-hover-remaining-tile-highlights.spec.ts +22 -0
- package/e2e/features/result-candidate-picker.spec.ts +21 -0
- package/e2e/features/results-interactions.spec.ts +170 -0
- package/e2e/features/solver-paths.spec.ts +2 -2
- package/e2e/features/words-dictionary-search.spec.ts +36 -0
- package/e2e/features/words-empty-state.spec.ts +42 -0
- package/e2e/features/words-interactions.spec.ts +179 -0
- package/e2e/features/words-preview.spec.ts +140 -0
- package/e2e/features/words-table-filtering.spec.ts +22 -0
- package/e2e/features/words-table-sorting.spec.ts +33 -0
- package/e2e/lib/actions.ts +76 -6
- package/e2e/lib/selectors.ts +40 -3
- package/lerna.json +1 -1
- package/package.json +24 -44
- package/packages/configs/package.json +13 -4
- package/packages/constants/package.json +6 -2
- package/packages/dictionaries/package.json +12 -5
- package/packages/logger/package.json +7 -2
- package/packages/scrabble-solver/.next/BUILD_ID +1 -1
- package/packages/scrabble-solver/.next/build-manifest.json +15 -15
- package/packages/scrabble-solver/.next/cache/.previewinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.rscinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
- package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/diagnostics/framework.json +1 -1
- package/packages/scrabble-solver/.next/dynamic-css-manifest.json +2 -2
- package/packages/scrabble-solver/.next/prerender-manifest.json +4 -4
- package/packages/scrabble-solver/.next/react-loadable-manifest.json +37 -37
- package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/chunks/309.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/344.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/371.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/392.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/465.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/546.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/641.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/67.js +1 -0
- package/packages/scrabble-solver/.next/server/chunks/712.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/846.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/886.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/942.js +1 -0
- package/packages/scrabble-solver/.next/server/chunks/953.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/961.js +1 -1
- package/packages/scrabble-solver/.next/server/dynamic-css-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/500.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/_app.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_document.js +2 -2
- package/packages/scrabble-solver/.next/server/pages/_document.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_error.js +2 -2
- package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/solve.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/solve.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/verify.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/verify.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/index.js +4 -4
- package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/not-found.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/not-found.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/static/chunks/100.305bdf9c75b1758f.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/256.66ff9fb6d7db9ec7.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{307.67f52f13e3d60d4e.js → 307.89e6100f58443679.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{363.01eed3233f92b6a4.js → 363.cec65b1f9668a75e.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{422.1559ae6756912ca5.js → 422.3e55b4c94e328701.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{663.d2c9ca36b26695b8.js → 663.bd2c45413fbca518.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/693.677c88e0eb1340b5.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{820.97b82f751ca49579.js → 820.823e9e885ebb66af.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/827.c81b92b383a748c9.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{865.a9b563a45848a83c.js → 865.59baba8296c9b116.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/912.077603e4f0bc6cca.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{939.19b33a3d3c351d73.js → 939.2ad86b50405c7897.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/980.7ce17464fc56648a.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{main-b92e08f3fc96dd8d.js → main-7e52da35a4beea0b.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-f9ec81278ffa7b1a.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/index-b5bf018100015277.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/not-found-a59f9deeeff63d17.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/webpack-9f5c9d275348829b.js +1 -0
- package/packages/scrabble-solver/.next/static/css/65bcc9440e067113.css +1 -0
- package/packages/scrabble-solver/.next/static/css/{abc2425d3ba607bc.css → 92f85ce358a0a468.css} +2 -1
- package/packages/scrabble-solver/.next/static/css/a691348b788f8bc0.css +1 -0
- package/packages/scrabble-solver/.next/static/css/cd4d7f2458487399.css +1 -0
- package/packages/scrabble-solver/.next/static/{FL82obwzFHRzvV6z76I-U → nvGZh1gPuX98L07YmxlYD}/_buildManifest.js +1 -1
- package/packages/scrabble-solver/.next/trace +21 -21
- package/packages/scrabble-solver/.next/trace-build +1 -1
- package/packages/scrabble-solver/AGENTS.md +9 -0
- package/packages/scrabble-solver/CLAUDE.md +1 -0
- package/packages/scrabble-solver/package.json +22 -13
- package/packages/scrabble-solver/public/robots.txt +1 -0
- package/packages/scrabble-solver/public/service-worker.js +1 -1
- package/packages/scrabble-solver/public/site.webmanifest +14 -0
- package/packages/scrabble-solver/src/components/Board/Board.tsx +3 -1
- package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +26 -20
- package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +4 -4
- package/packages/scrabble-solver/src/components/Board/lib.test.ts +106 -0
- package/packages/scrabble-solver/src/components/Board/lib.ts +34 -3
- package/packages/scrabble-solver/src/components/Board/selectors.ts +17 -5
- package/packages/scrabble-solver/src/components/Button/Button.module.scss +1 -1
- package/packages/scrabble-solver/src/components/Modal/Modal.module.scss +0 -4
- package/packages/scrabble-solver/src/components/Results/Header.tsx +30 -5
- package/packages/scrabble-solver/src/components/Results/Result.tsx +45 -55
- package/packages/scrabble-solver/src/components/Results/Results.module.scss +0 -126
- package/packages/scrabble-solver/src/components/Results/Results.module.scss.d.ts +0 -10
- package/packages/scrabble-solver/src/components/Results/Results.tsx +25 -5
- package/packages/scrabble-solver/src/components/Solver/Solver.module.scss +4 -4
- package/packages/scrabble-solver/src/components/Solver/Solver.tsx +5 -3
- package/packages/scrabble-solver/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.module.scss +5 -1
- package/packages/scrabble-solver/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.module.scss.d.ts +1 -0
- package/packages/scrabble-solver/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.tsx +5 -2
- package/packages/scrabble-solver/src/components/Table/Cell.tsx +42 -0
- package/packages/scrabble-solver/src/components/Table/Header.tsx +11 -0
- package/packages/scrabble-solver/src/components/{Results → Table}/HeaderButton.tsx +22 -14
- package/packages/scrabble-solver/src/components/Table/Row.tsx +59 -0
- package/packages/scrabble-solver/src/components/{ResultsInput/ResultsInput.tsx → Table/Search.tsx} +9 -11
- package/packages/scrabble-solver/src/components/Table/Table.module.scss +147 -0
- package/packages/scrabble-solver/src/components/Table/Table.module.scss.d.ts +19 -0
- package/packages/scrabble-solver/src/components/Table/index.ts +5 -0
- package/packages/scrabble-solver/src/components/Tile/Tile.module.scss +2 -1
- package/packages/scrabble-solver/src/hooks/useColumns.ts +7 -5
- package/packages/scrabble-solver/src/hooks/useIsCompactLayout.ts +14 -0
- package/packages/scrabble-solver/src/i18n/languages/english.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/french.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/german.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/persian.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/polish.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/romanian.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/spanish.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/turkish.json +6 -1
- package/packages/scrabble-solver/src/icons/QuestionSquare.svg +5 -0
- package/packages/scrabble-solver/src/lib/createCoordinatesComparator.ts +23 -0
- package/packages/scrabble-solver/src/lib/createKeyComparator.ts +1 -4
- package/packages/scrabble-solver/src/lib/createSortComparator.ts +22 -0
- package/packages/scrabble-solver/src/lib/getCoordinates.test.ts +21 -0
- package/packages/scrabble-solver/src/lib/getCoordinates.ts +16 -0
- package/packages/scrabble-solver/src/lib/getNextSort.ts +12 -0
- package/packages/scrabble-solver/src/lib/waitForIdleOrFirstIntent.ts +19 -8
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/RemainingTilesModal.tsx +3 -1
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/components/Character/Character.tsx +8 -9
- package/packages/scrabble-solver/src/modals/ResultsModal/ResultsModal.tsx +14 -10
- package/packages/scrabble-solver/src/modals/WordsModal/WordsModal.module.scss +16 -27
- package/packages/scrabble-solver/src/modals/WordsModal/WordsModal.module.scss.d.ts +3 -6
- package/packages/scrabble-solver/src/modals/WordsModal/WordsModal.tsx +56 -42
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordRow.tsx +92 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordsTable.module.scss +69 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordsTable.module.scss.d.ts +16 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordsTable.tsx +137 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/index.ts +1 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/index.ts +1 -0
- package/packages/scrabble-solver/src/pages/_app.tsx +40 -76
- package/packages/scrabble-solver/src/pages/_document.tsx +21 -19
- package/packages/scrabble-solver/src/pages/api/verify.ts +7 -6
- package/packages/scrabble-solver/src/pages/index.tsx +58 -6
- package/packages/scrabble-solver/src/pages/not-found.tsx +13 -2
- package/packages/scrabble-solver/src/parameters/index.ts +9 -0
- package/packages/scrabble-solver/src/sdk/verify.ts +3 -2
- package/packages/scrabble-solver/src/solver-worker/client.test.ts +10 -3
- package/packages/scrabble-solver/src/solver-worker/index.worker.ts +7 -7
- package/packages/scrabble-solver/src/solver-worker/messages.ts +3 -3
- package/packages/scrabble-solver/src/state/hoveredWord/index.ts +4 -0
- package/packages/scrabble-solver/src/state/hoveredWord/initialState.ts +5 -0
- package/packages/scrabble-solver/src/state/hoveredWord/selectors.ts +5 -0
- package/packages/scrabble-solver/src/state/hoveredWord/slice.ts +18 -0
- package/packages/scrabble-solver/src/state/hoveredWord/types.ts +5 -0
- package/packages/scrabble-solver/src/state/index.ts +1 -0
- package/packages/scrabble-solver/src/state/localStorage.ts +13 -2
- package/packages/scrabble-solver/src/state/results/lib.ts +9 -26
- package/packages/scrabble-solver/src/state/results/selectors.ts +9 -1
- package/packages/scrabble-solver/src/state/results/slice.ts +4 -16
- package/packages/scrabble-solver/src/state/sagas.ts +30 -5
- package/packages/scrabble-solver/src/state/selectors.ts +18 -1
- package/packages/scrabble-solver/src/state/store.ts +2 -0
- package/packages/scrabble-solver/src/state/types.ts +2 -0
- package/packages/scrabble-solver/src/state/verify/initialState.ts +7 -0
- package/packages/scrabble-solver/src/state/verify/lib.test.ts +55 -0
- package/packages/scrabble-solver/src/state/verify/lib.ts +49 -0
- package/packages/scrabble-solver/src/state/verify/selectors.ts +37 -0
- package/packages/scrabble-solver/src/state/verify/slice.ts +13 -2
- package/packages/scrabble-solver/src/state/verify/types.ts +6 -2
- package/packages/scrabble-solver/src/styles/_tokens.scss +2 -0
- package/packages/scrabble-solver/src/styles/mixins.scss +5 -0
- package/packages/scrabble-solver/src/styles/variables.module.scss +1 -0
- package/packages/scrabble-solver/src/styles/variables.module.scss.d.ts +1 -0
- package/packages/scrabble-solver/src/styles/variables.scss +1 -1
- package/packages/scrabble-solver/src/types/index.ts +24 -11
- package/packages/scrabble-solver/tsconfig.tsbuildinfo +1 -1
- package/packages/solver/package.json +14 -6
- package/packages/types/build/Bingo.d.ts +0 -3
- package/packages/types/build/Bingo.js +0 -14
- package/packages/types/build/Board.d.ts +3 -1
- package/packages/types/build/Board.js +5 -40
- package/packages/types/build/BoardJson.d.ts +0 -1
- package/packages/types/build/BoardJson.js +0 -19
- package/packages/types/build/BoardWord.d.ts +7 -0
- package/packages/types/build/BoardWord.js +2 -0
- package/packages/types/build/CellJson.d.ts +0 -1
- package/packages/types/build/CellJson.js +0 -11
- package/packages/types/build/Game.d.ts +0 -1
- package/packages/types/build/Game.js +1 -4
- package/packages/types/build/Locale.d.ts +0 -1
- package/packages/types/build/Locale.js +1 -4
- package/packages/types/build/Result.js +3 -3
- package/packages/types/build/TileJson.d.ts +0 -1
- package/packages/types/build/TileJson.js +0 -6
- package/packages/types/build/index.d.ts +9 -8
- package/packages/types/build/index.js +14 -17
- package/packages/types/build/lib/getBoardWords.d.ts +3 -0
- package/packages/types/build/lib/getBoardWords.js +10 -0
- package/packages/types/build/lib/getCells.d.ts +4 -0
- package/packages/types/build/lib/getCells.js +27 -0
- package/packages/types/build/lib/getCollidingWords.d.ts +3 -0
- package/packages/types/build/lib/getCollidingWords.js +19 -0
- package/packages/types/build/lib/getCollision.d.ts +3 -0
- package/packages/types/build/lib/getCollision.js +31 -0
- package/packages/types/build/lib/getCollisions.d.ts +3 -0
- package/packages/types/build/lib/getCollisions.js +17 -0
- package/packages/types/build/lib/getPlacedCell.d.ts +3 -0
- package/packages/types/build/lib/getPlacedCell.js +10 -0
- package/packages/types/build/lib/getWordThrough.d.ts +4 -0
- package/packages/types/build/lib/getWordThrough.js +23 -0
- package/packages/types/build/lib/getWordsInRows.d.ts +8 -0
- package/packages/types/build/lib/getWordsInRows.js +29 -0
- package/packages/types/build/lib/index.d.ts +5 -0
- package/packages/types/build/lib/index.js +21 -0
- package/packages/types/build/lib/isSameBoardWord.d.ts +2 -0
- package/packages/types/build/lib/isSameBoardWord.js +6 -0
- package/packages/types/build/lib/toBoardWord.d.ts +4 -0
- package/packages/types/build/lib/toBoardWord.js +11 -0
- package/packages/types/build/lib/transpose.d.ts +1 -0
- package/packages/types/build/lib/transpose.js +16 -0
- package/packages/types/build/type-guards/index.d.ts +10 -0
- package/packages/types/build/type-guards/index.js +23 -0
- package/packages/types/build/type-guards/isBingo.d.ts +2 -0
- package/packages/types/build/type-guards/isBingo.js +9 -0
- package/packages/types/build/type-guards/isBoardJson.d.ts +2 -0
- package/packages/types/build/type-guards/isBoardJson.js +21 -0
- package/packages/types/build/type-guards/isCellJson.d.ts +2 -0
- package/packages/types/build/type-guards/isCellJson.js +13 -0
- package/packages/types/build/type-guards/isGame.d.ts +2 -0
- package/packages/types/build/type-guards/isGame.js +7 -0
- package/packages/types/build/type-guards/isLocale.d.ts +2 -0
- package/packages/types/build/type-guards/isLocale.js +7 -0
- package/packages/types/build/type-guards/isMultiplierBingo.d.ts +2 -0
- package/packages/types/build/type-guards/isMultiplierBingo.js +8 -0
- package/packages/types/build/type-guards/isScoreBingo.d.ts +2 -0
- package/packages/types/build/type-guards/isScoreBingo.js +8 -0
- package/packages/types/build/type-guards/isTileJson.d.ts +2 -0
- package/packages/types/build/type-guards/isTileJson.js +8 -0
- package/packages/types/package.json +10 -3
- package/packages/types/src/Bingo.ts +0 -14
- package/packages/types/src/Board.test.ts +85 -0
- package/packages/types/src/Board.ts +8 -49
- package/packages/types/src/BoardJson.ts +1 -21
- package/packages/types/src/BoardWord.ts +8 -0
- package/packages/types/src/CellJson.ts +1 -12
- package/packages/types/src/Game.ts +0 -4
- package/packages/types/src/Locale.ts +0 -4
- package/packages/types/src/Result.ts +3 -3
- package/packages/types/src/TileJson.ts +0 -6
- package/packages/types/src/index.ts +20 -8
- package/packages/types/src/lib/getBoardWords.ts +11 -0
- package/packages/types/src/lib/getCells.test.ts +127 -0
- package/packages/types/src/lib/getCells.ts +31 -0
- package/packages/types/src/lib/getCollidingWords.ts +25 -0
- package/packages/types/src/lib/getCollision.ts +38 -0
- package/packages/types/src/lib/getCollisions.test.ts +82 -0
- package/packages/types/src/lib/getCollisions.ts +22 -0
- package/packages/types/src/lib/getPlacedCell.ts +9 -0
- package/packages/types/src/lib/getWordThrough.ts +30 -0
- package/packages/types/src/lib/getWordsInRows.ts +34 -0
- package/packages/types/src/lib/index.ts +5 -0
- package/packages/types/src/lib/isSameBoardWord.ts +5 -0
- package/packages/types/src/lib/toBoardWord.ts +12 -0
- package/packages/types/src/lib/transpose.ts +15 -0
- package/packages/types/src/type-guards/index.ts +10 -0
- package/packages/types/src/type-guards/isBingo.ts +8 -0
- package/packages/types/src/type-guards/isBoardJson.test.ts +33 -0
- package/packages/types/src/type-guards/isBoardJson.ts +23 -0
- package/packages/types/src/type-guards/isCellJson.ts +14 -0
- package/packages/types/src/type-guards/isGame.ts +5 -0
- package/packages/types/src/type-guards/isLocale.ts +5 -0
- package/packages/types/src/type-guards/isMultiplierBingo.ts +7 -0
- package/packages/types/src/type-guards/isScoreBingo.ts +7 -0
- package/packages/types/src/type-guards/isTileJson.ts +7 -0
- package/packages/word-definitions/package.json +9 -3
- package/packages/word-lists/package.json +11 -3
- package/playwright-report/index.html +1 -1
- package/screencast.gif +0 -0
- package/packages/scrabble-solver/.next/server/chunks/316.js +0 -1
- package/packages/scrabble-solver/.next/server/chunks/916.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/106.e414e88694add27f.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/127.125d896a19061d71.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/18.8b91e137d239e15c.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/583.7a46807be14c377e.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/711.ba7b8f900dfd40d0.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/912.ff8037ba9d4db5c8.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-ba5d628e81a15461.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/index-5f9fa6ac3cd3d97b.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/not-found-23d61fd3ed791cad.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/webpack-e34c3ae12275e978.js +0 -1
- package/packages/scrabble-solver/.next/static/css/b74cd7de82dabcdd.css +0 -1
- package/packages/scrabble-solver/.next/static/css/c403ce739a9c0d83.css +0 -1
- package/packages/scrabble-solver/.next/static/css/fbfdce70731d0d2b.css +0 -1
- package/packages/scrabble-solver/src/components/Results/Cell.tsx +0 -32
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.module.scss +0 -12
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.module.scss.d.ts +0 -7
- package/packages/scrabble-solver/src/components/ResultsInput/index.ts +0 -1
- package/packages/scrabble-solver/src/components/SeoMessage/SeoMessage.tsx +0 -18
- package/packages/scrabble-solver/src/components/SeoMessage/index.ts +0 -1
- package/packages/types/build/readResultCells.d.ts +0 -5
- package/packages/types/build/readResultCells.js +0 -75
- package/packages/types/src/readResultCells.test.ts +0 -140
- package/packages/types/src/readResultCells.ts +0 -90
- /package/packages/scrabble-solver/.next/static/{FL82obwzFHRzvV6z76I-U → nvGZh1gPuX98L07YmxlYD}/_ssgManifest.js +0 -0
- /package/packages/types/build/{isError.d.ts → type-guards/isError.d.ts} +0 -0
- /package/packages/types/build/{isError.js → type-guards/isError.js} +0 -0
- /package/packages/types/build/{isObject.d.ts → type-guards/isObject.d.ts} +0 -0
- /package/packages/types/build/{isObject.js → type-guards/isObject.js} +0 -0
- /package/packages/types/src/{isError.ts → type-guards/isError.ts} +0 -0
- /package/packages/types/src/{isObject.ts → type-guards/isObject.ts} +0 -0
|
@@ -3,10 +3,7 @@ import { type Comparator } from '@/types';
|
|
|
3
3
|
import { createStringComparator } from './createStringComparator';
|
|
4
4
|
import { numberComparator } from './numberComparator';
|
|
5
5
|
|
|
6
|
-
export const createKeyComparator = <T extends
|
|
7
|
-
key: keyof T,
|
|
8
|
-
locale: string,
|
|
9
|
-
): Comparator<T> => {
|
|
6
|
+
export const createKeyComparator = <T extends object>(key: keyof T, locale: string): Comparator<T> => {
|
|
10
7
|
const stringComparator = createStringComparator(locale);
|
|
11
8
|
|
|
12
9
|
return (a: T, b: T): number => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ShowCoordinates } from '@scrabble-solver/types';
|
|
2
|
+
|
|
3
|
+
import { type Comparator, type ComparatorFactory, type Sort, SortDirection } from '@/types';
|
|
4
|
+
|
|
5
|
+
import { reverseComparator } from './reverseComparator';
|
|
6
|
+
|
|
7
|
+
interface Parameters<Item, Id extends string> {
|
|
8
|
+
comparators: Record<Id, ComparatorFactory<Item>>;
|
|
9
|
+
locale: string;
|
|
10
|
+
showCoordinates: ShowCoordinates;
|
|
11
|
+
sort: Sort<Id>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createSortComparator<Item, Id extends string>({
|
|
15
|
+
comparators,
|
|
16
|
+
locale,
|
|
17
|
+
showCoordinates,
|
|
18
|
+
sort,
|
|
19
|
+
}: Parameters<Item, Id>): Comparator<Item> {
|
|
20
|
+
const comparator = comparators[sort.column](locale, showCoordinates);
|
|
21
|
+
return sort.direction === SortDirection.Descending ? reverseComparator(comparator) : comparator;
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getCoordinates } from './getCoordinates';
|
|
2
|
+
|
|
3
|
+
describe('getCoordinates', () => {
|
|
4
|
+
const point = { x: 3, y: 5 };
|
|
5
|
+
|
|
6
|
+
it('encodes a horizontal word as row number followed by column letter in original mode', () => {
|
|
7
|
+
expect(getCoordinates({ ...point, isHorizontal: true }, 'original')).toBe('6D');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('encodes a vertical word as column letter followed by row number in original mode', () => {
|
|
11
|
+
expect(getCoordinates({ ...point, isHorizontal: false }, 'original')).toBe('D6');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('encodes a horizontal word as row letter followed by column number in alternative mode', () => {
|
|
15
|
+
expect(getCoordinates({ ...point, isHorizontal: true }, 'alternative')).toBe('F4');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('encodes a vertical word as column number followed by row letter in alternative mode', () => {
|
|
19
|
+
expect(getCoordinates({ ...point, isHorizontal: false }, 'alternative')).toBe('4F');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ShowCoordinates } from '@scrabble-solver/types';
|
|
2
|
+
|
|
3
|
+
import { getCoordinate } from './getCoordinate';
|
|
4
|
+
|
|
5
|
+
interface Parameters {
|
|
6
|
+
isHorizontal: boolean;
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getCoordinates = ({ isHorizontal, x, y }: Parameters, showCoordinates: ShowCoordinates): string => {
|
|
12
|
+
const xCoordinate = getCoordinate(x, showCoordinates === 'original' ? 'letter' : 'number');
|
|
13
|
+
const yCoordinate = getCoordinate(y, showCoordinates === 'original' ? 'number' : 'letter');
|
|
14
|
+
|
|
15
|
+
return isHorizontal ? `${yCoordinate}${xCoordinate}` : `${xCoordinate}${yCoordinate}`;
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Sort, SortDirection } from '@/types';
|
|
2
|
+
|
|
3
|
+
export const getNextSort = <Id extends string>(sort: Sort<Id>, column: Id): Sort<Id> => {
|
|
4
|
+
return {
|
|
5
|
+
column,
|
|
6
|
+
direction: sort.column === column ? toggleDirection(sort.direction) : sort.direction,
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const toggleDirection = (direction: SortDirection): SortDirection => {
|
|
11
|
+
return direction === SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending;
|
|
12
|
+
};
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
export function waitForIdleOrFirstIntent(): Promise<void> {
|
|
2
2
|
return new Promise((resolve) => {
|
|
3
|
-
const settle = ()
|
|
4
|
-
window.removeEventListener('pointerdown', settle);
|
|
5
|
-
window.removeEventListener('keydown', settle);
|
|
6
|
-
resolve();
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
window.addEventListener('pointerdown', settle, { once: true });
|
|
10
|
-
window.addEventListener('keydown', settle, { once: true });
|
|
3
|
+
const settle = onFirstIntent(resolve);
|
|
11
4
|
whenIdle(settle);
|
|
12
5
|
});
|
|
13
6
|
}
|
|
14
7
|
|
|
8
|
+
export function waitForFirstIntent(): Promise<void> {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
onFirstIntent(resolve);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
15
14
|
export function waitForIdle(): Promise<void> {
|
|
16
15
|
return new Promise((resolve) => whenIdle(resolve));
|
|
17
16
|
}
|
|
18
17
|
|
|
18
|
+
function onFirstIntent(callback: () => void): () => void {
|
|
19
|
+
const settle = () => {
|
|
20
|
+
window.removeEventListener('pointerdown', settle);
|
|
21
|
+
window.removeEventListener('keydown', settle);
|
|
22
|
+
callback();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
window.addEventListener('pointerdown', settle, { once: true });
|
|
26
|
+
window.addEventListener('keydown', settle, { once: true });
|
|
27
|
+
return settle;
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
function whenIdle(callback: () => void): void {
|
|
20
31
|
const requestIdle = () => {
|
|
21
32
|
if ('requestIdleCallback' in window) {
|
|
@@ -2,6 +2,7 @@ import { type FunctionComponent, memo } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Badge } from '@/components/Badge';
|
|
4
4
|
import { Modal } from '@/components/Modal';
|
|
5
|
+
import { useMediaQuery } from '@/hooks/useMediaQuery';
|
|
5
6
|
import { LOCALE_FEATURES } from '@/i18n/constants';
|
|
6
7
|
import { selectLocale, useTranslate, useTypedSelector } from '@/state';
|
|
7
8
|
|
|
@@ -17,6 +18,7 @@ interface Props {
|
|
|
17
18
|
|
|
18
19
|
const RemainingTilesModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
19
20
|
const translate = useTranslate();
|
|
21
|
+
const coversViewport = useMediaQuery('<s');
|
|
20
22
|
const locale = useTypedSelector(selectLocale);
|
|
21
23
|
const groups = useTypedSelector(selectRemainingTilesGroups);
|
|
22
24
|
const { direction } = LOCALE_FEATURES[locale];
|
|
@@ -44,7 +46,7 @@ const RemainingTilesModalBase: FunctionComponent<Props> = ({ className, isOpen,
|
|
|
44
46
|
{tiles.map((tile) => {
|
|
45
47
|
return (
|
|
46
48
|
<div className={styles.character} key={tile.character}>
|
|
47
|
-
<Character tile={tile} />
|
|
49
|
+
<Character canHighlight={!coversViewport} tile={tile} />
|
|
48
50
|
</div>
|
|
49
51
|
);
|
|
50
52
|
})}
|
package/packages/scrabble-solver/src/modals/RemainingTilesModal/components/Character/Character.tsx
CHANGED
|
@@ -18,10 +18,11 @@ import { type RemainingTile } from '@/types';
|
|
|
18
18
|
import styles from './Character.module.scss';
|
|
19
19
|
|
|
20
20
|
interface Props {
|
|
21
|
+
canHighlight: boolean;
|
|
21
22
|
tile: RemainingTile;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export const Character: FunctionComponent<Props> = ({ tile }) => {
|
|
25
|
+
export const Character: FunctionComponent<Props> = ({ canHighlight, tile }) => {
|
|
25
26
|
const dispatch = useDispatch();
|
|
26
27
|
const locale = useTypedSelector(selectLocale);
|
|
27
28
|
const hoveredCharacter = useTypedSelector(selectHoveredCharacter);
|
|
@@ -37,14 +38,12 @@ export const Character: FunctionComponent<Props> = ({ tile }) => {
|
|
|
37
38
|
const current = direction === 'ltr' ? remainingCount : count;
|
|
38
39
|
const total = direction === 'ltr' ? count : remainingCount;
|
|
39
40
|
const isUsed = usedCount > 0;
|
|
40
|
-
const
|
|
41
|
+
const isHighlightable = canHighlight && isUsed;
|
|
42
|
+
const isHighlighted = isHighlightable && hoveredCharacter === character;
|
|
41
43
|
|
|
42
44
|
const handleMouseEnter = useCallback(() => {
|
|
43
|
-
if (!isUsed) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
45
|
dispatch(hoveredTileSlice.actions.set(character));
|
|
47
|
-
}, [character, dispatch
|
|
46
|
+
}, [character, dispatch]);
|
|
48
47
|
|
|
49
48
|
const handleMouseLeave = useCallback(() => {
|
|
50
49
|
dispatch(hoveredTileSlice.actions.clear());
|
|
@@ -64,15 +63,15 @@ export const Character: FunctionComponent<Props> = ({ tile }) => {
|
|
|
64
63
|
[styles.unused]: !isUsed,
|
|
65
64
|
})}
|
|
66
65
|
data-testid={character === BLANK ? 'remaining-tile-blank' : `remaining-tile-${character}`}
|
|
67
|
-
onMouseEnter={handleMouseEnter}
|
|
68
|
-
onMouseLeave={handleMouseLeave}
|
|
66
|
+
onMouseEnter={isHighlightable ? handleMouseEnter : undefined}
|
|
67
|
+
onMouseLeave={isHighlightable ? handleMouseLeave : undefined}
|
|
69
68
|
>
|
|
70
69
|
<Tile
|
|
71
70
|
aria-label={character}
|
|
72
71
|
character={character}
|
|
73
72
|
className={styles.tile}
|
|
74
73
|
disabled
|
|
75
|
-
highlighted={
|
|
74
|
+
highlighted={isHighlighted}
|
|
76
75
|
isBlank={character === BLANK}
|
|
77
76
|
isValid={remainingCount >= 0}
|
|
78
77
|
locale={locale}
|
|
@@ -6,10 +6,17 @@ import { Button } from '@/components/Button';
|
|
|
6
6
|
import { Dictionary } from '@/components/Dictionary';
|
|
7
7
|
import { Modal } from '@/components/Modal';
|
|
8
8
|
import { Results } from '@/components/Results';
|
|
9
|
-
import {
|
|
9
|
+
import { useIsCompactLayout } from '@/hooks/useIsCompactLayout';
|
|
10
|
+
import { useIsTouchDevice } from '@/hooks/useIsTouchDevice';
|
|
10
11
|
import Check from '@/icons/Check.svg';
|
|
11
12
|
import EyeFill from '@/icons/EyeFill.svg';
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
resultsSlice,
|
|
15
|
+
selectResultCandidate,
|
|
16
|
+
selectResultCandidateIndex,
|
|
17
|
+
useTranslate,
|
|
18
|
+
useTypedSelector,
|
|
19
|
+
} from '@/state';
|
|
13
20
|
|
|
14
21
|
import styles from './ResultsModal.module.scss';
|
|
15
22
|
|
|
@@ -22,25 +29,22 @@ interface Props {
|
|
|
22
29
|
const ResultsModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
23
30
|
const dispatch = useDispatch();
|
|
24
31
|
const translate = useTranslate();
|
|
25
|
-
const showResultsInModal =
|
|
26
|
-
const
|
|
32
|
+
const showResultsInModal = useIsCompactLayout();
|
|
33
|
+
const previewsOnRepeatedClick = useIsTouchDevice();
|
|
27
34
|
const resultCandidate = useTypedSelector(selectResultCandidate);
|
|
28
|
-
const
|
|
29
|
-
const highlightedIndex = index === -1 ? undefined : index;
|
|
35
|
+
const highlightedIndex = useTypedSelector(selectResultCandidateIndex);
|
|
30
36
|
|
|
31
37
|
const callbacks = useMemo(
|
|
32
38
|
() => ({
|
|
33
39
|
onClick: (result: Result) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (isSelected) {
|
|
40
|
+
if (previewsOnRepeatedClick && result === resultCandidate) {
|
|
37
41
|
onClose();
|
|
38
42
|
} else {
|
|
39
43
|
dispatch(resultsSlice.actions.changeResultCandidate(result));
|
|
40
44
|
}
|
|
41
45
|
},
|
|
42
46
|
}),
|
|
43
|
-
[dispatch, onClose, resultCandidate],
|
|
47
|
+
[dispatch, onClose, previewsOnRepeatedClick, resultCandidate],
|
|
44
48
|
);
|
|
45
49
|
|
|
46
50
|
const handleInsert = () => {
|
|
@@ -1,35 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
flex-wrap: wrap;
|
|
6
|
-
}
|
|
1
|
+
@use 'styles/mixins' as *;
|
|
7
2
|
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.word {
|
|
3
|
+
.content {
|
|
4
|
+
position: relative;
|
|
13
5
|
display: flex;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
margin-top: var(--spacing--s);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.invalid {
|
|
22
|
-
color: var(--color--error);
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
height: 100%;
|
|
8
|
+
gap: var(--spacing--l);
|
|
23
9
|
}
|
|
24
10
|
|
|
25
|
-
.
|
|
26
|
-
|
|
11
|
+
.words {
|
|
12
|
+
flex: 1 1 auto;
|
|
27
13
|
}
|
|
28
14
|
|
|
29
|
-
.
|
|
30
|
-
|
|
15
|
+
.dictionary {
|
|
16
|
+
flex: 0 0 var(--dictionary--height--mobile);
|
|
17
|
+
background-color: var(--color--background--element);
|
|
18
|
+
border: var(--border);
|
|
19
|
+
border-radius: var(--border--radius);
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
@include media('desktop') {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
35
24
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// Generated by scripts/generate-scss-types.ts - do not edit.
|
|
2
2
|
declare const styles: {
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
6
|
-
readonly title: string;
|
|
7
|
-
readonly valid: string;
|
|
8
|
-
readonly word: string;
|
|
3
|
+
readonly content: string;
|
|
4
|
+
readonly dictionary: string;
|
|
5
|
+
readonly words: string;
|
|
9
6
|
};
|
|
10
7
|
|
|
11
8
|
export default styles;
|
|
@@ -1,59 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { type FunctionComponent, memo, useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useDispatch } from 'react-redux';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Button } from '@/components/Button';
|
|
5
|
+
import { Dictionary } from '@/components/Dictionary';
|
|
5
6
|
import { Modal } from '@/components/Modal';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import { useIsCompactLayout } from '@/hooks/useIsCompactLayout';
|
|
8
|
+
import EyeFill from '@/icons/EyeFill.svg';
|
|
9
|
+
import { hoveredWordSlice, selectHoveredWord, useTranslate, useTypedSelector } from '@/state';
|
|
9
10
|
|
|
11
|
+
import { WordsTable } from './components';
|
|
10
12
|
import styles from './WordsModal.module.scss';
|
|
11
13
|
|
|
12
14
|
interface Props {
|
|
13
15
|
className?: string;
|
|
14
16
|
isOpen: boolean;
|
|
15
17
|
onClose: () => void;
|
|
18
|
+
onPreview: () => void;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
const WordsModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
21
|
+
const WordsModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose, onPreview }) => {
|
|
22
|
+
const dispatch = useDispatch();
|
|
19
23
|
const translate = useTranslate();
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
24
|
+
const hoveredWord = useTypedSelector(selectHoveredWord);
|
|
25
|
+
const showsPreviewButton = useIsCompactLayout();
|
|
26
|
+
const keepsHighlightOnClose = useRef(false);
|
|
27
|
+
|
|
28
|
+
const handlePreview = useCallback(() => {
|
|
29
|
+
keepsHighlightOnClose.current = true;
|
|
30
|
+
onPreview();
|
|
31
|
+
}, [onPreview]);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!isOpen) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
if (!keepsHighlightOnClose.current) {
|
|
40
|
+
dispatch(hoveredWordSlice.actions.clear());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
keepsHighlightOnClose.current = false;
|
|
44
|
+
};
|
|
45
|
+
}, [dispatch, isOpen]);
|
|
23
46
|
|
|
24
47
|
return (
|
|
25
|
-
<Modal
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
</span>
|
|
49
|
-
}
|
|
50
|
-
>
|
|
51
|
-
{validWords.map((word, index) => (
|
|
52
|
-
<div className={styles.word} key={index}>
|
|
53
|
-
<Check aria-hidden="true" className={classNames(styles.icon, styles.valid)} role="img" /> {word}
|
|
54
|
-
</div>
|
|
55
|
-
))}
|
|
56
|
-
</Modal.Section>
|
|
48
|
+
<Modal
|
|
49
|
+
className={className}
|
|
50
|
+
footer={
|
|
51
|
+
showsPreviewButton && (
|
|
52
|
+
<Button
|
|
53
|
+
aria-label={translate('words.preview')}
|
|
54
|
+
disabled={!hoveredWord}
|
|
55
|
+
Icon={EyeFill}
|
|
56
|
+
tooltip={translate('words.preview')}
|
|
57
|
+
onClick={handlePreview}
|
|
58
|
+
>
|
|
59
|
+
{translate('words.preview')}
|
|
60
|
+
</Button>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
isOpen={isOpen}
|
|
64
|
+
title={translate('words')}
|
|
65
|
+
onClose={onClose}
|
|
66
|
+
>
|
|
67
|
+
<div className={styles.content}>
|
|
68
|
+
<WordsTable className={styles.words} isOpen={isOpen} onPreview={handlePreview} />
|
|
69
|
+
<Dictionary className={styles.dictionary} />
|
|
70
|
+
</div>
|
|
57
71
|
</Modal>
|
|
58
72
|
);
|
|
59
73
|
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { type ReactElement } from 'react';
|
|
3
|
+
import Highlighter from 'react-highlight-words';
|
|
4
|
+
import { useDispatch } from 'react-redux';
|
|
5
|
+
import { type RowComponentProps } from 'react-window';
|
|
6
|
+
|
|
7
|
+
import { Cell, Row } from '@/components/Table';
|
|
8
|
+
import Check from '@/icons/Check.svg';
|
|
9
|
+
import Cross from '@/icons/Cross.svg';
|
|
10
|
+
import {
|
|
11
|
+
hoveredWordSlice,
|
|
12
|
+
selectIsWordMatching,
|
|
13
|
+
selectWordCoordinates,
|
|
14
|
+
selectWordsQuery,
|
|
15
|
+
useTranslate,
|
|
16
|
+
useTypedSelector,
|
|
17
|
+
} from '@/state';
|
|
18
|
+
import { type VerifiedWord } from '@/types';
|
|
19
|
+
|
|
20
|
+
import styles from './WordsTable.module.scss';
|
|
21
|
+
|
|
22
|
+
export interface WordRowData {
|
|
23
|
+
highlightFollowsPointer: boolean;
|
|
24
|
+
highlightedIndex: number;
|
|
25
|
+
isTouchDevice: boolean;
|
|
26
|
+
words: VerifiedWord[];
|
|
27
|
+
onPreview: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const WordRow = ({
|
|
31
|
+
highlightFollowsPointer,
|
|
32
|
+
highlightedIndex,
|
|
33
|
+
index,
|
|
34
|
+
isTouchDevice,
|
|
35
|
+
style,
|
|
36
|
+
words,
|
|
37
|
+
onPreview,
|
|
38
|
+
}: RowComponentProps<WordRowData>): ReactElement => {
|
|
39
|
+
const dispatch = useDispatch();
|
|
40
|
+
const translate = useTranslate();
|
|
41
|
+
const isSelected = index === highlightedIndex;
|
|
42
|
+
const word = words[index];
|
|
43
|
+
const coordinates = useTypedSelector((state) => selectWordCoordinates(state, index));
|
|
44
|
+
const isMatching = useTypedSelector((state) => selectIsWordMatching(state, index));
|
|
45
|
+
const query = useTypedSelector(selectWordsQuery);
|
|
46
|
+
const validityLabel = translate(word.isValid ? 'words.valid' : 'words.invalid');
|
|
47
|
+
const Icon = word.isValid ? Check : Cross;
|
|
48
|
+
|
|
49
|
+
const handleSet = () => {
|
|
50
|
+
dispatch(hoveredWordSlice.actions.set(word));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const handleClear = () => {
|
|
54
|
+
dispatch(hoveredWordSlice.actions.clear());
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleClick = () => {
|
|
58
|
+
if (!isSelected) {
|
|
59
|
+
handleSet();
|
|
60
|
+
} else if (isTouchDevice) {
|
|
61
|
+
onPreview();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Row
|
|
67
|
+
aria-label={word.word}
|
|
68
|
+
data-testid={`word-${word.x}-${word.y}-${word.direction}`}
|
|
69
|
+
highlighted={isSelected}
|
|
70
|
+
inactive={!isMatching}
|
|
71
|
+
style={style}
|
|
72
|
+
onBlur={highlightFollowsPointer ? handleClear : undefined}
|
|
73
|
+
onClick={highlightFollowsPointer ? undefined : handleClick}
|
|
74
|
+
onFocus={highlightFollowsPointer ? handleSet : undefined}
|
|
75
|
+
onMouseEnter={highlightFollowsPointer ? handleSet : undefined}
|
|
76
|
+
>
|
|
77
|
+
<Cell className={styles.coordinates} translationKey="settings.showCoordinates" value={coordinates} />
|
|
78
|
+
|
|
79
|
+
<Cell primary translationKey="common.word" value={word.word}>
|
|
80
|
+
<Highlighter highlightClassName={styles.highlight} searchWords={[query]} textToHighlight={word.word} />
|
|
81
|
+
</Cell>
|
|
82
|
+
|
|
83
|
+
<Cell className={styles.stat} value={validityLabel}>
|
|
84
|
+
<Icon
|
|
85
|
+
aria-label={validityLabel}
|
|
86
|
+
className={classNames(styles.icon, word.isValid ? styles.valid : styles.invalid)}
|
|
87
|
+
role="img"
|
|
88
|
+
/>
|
|
89
|
+
</Cell>
|
|
90
|
+
</Row>
|
|
91
|
+
);
|
|
92
|
+
};
|
package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordsTable.module.scss
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
@use 'styles/mixins' as *;
|
|
2
|
+
|
|
3
|
+
.words {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
height: 100%;
|
|
8
|
+
background: var(--color--background--element);
|
|
9
|
+
border: var(--border);
|
|
10
|
+
border-radius: var(--border--radius);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.content {
|
|
14
|
+
flex: 1;
|
|
15
|
+
position: relative;
|
|
16
|
+
height: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.listContainer {
|
|
20
|
+
position: absolute;
|
|
21
|
+
inset: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.list {
|
|
25
|
+
@include scrollbars;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.stat {
|
|
29
|
+
$width: 55px;
|
|
30
|
+
|
|
31
|
+
flex: 0 0 $width;
|
|
32
|
+
max-width: $width;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.coordinates {
|
|
37
|
+
$width: 55px;
|
|
38
|
+
|
|
39
|
+
flex: 0 0 $width;
|
|
40
|
+
max-width: $width;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.invalid {
|
|
44
|
+
color: var(--color--error);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.valid {
|
|
48
|
+
color: var(--color--success);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.icon {
|
|
52
|
+
$size: 24px;
|
|
53
|
+
|
|
54
|
+
display: block;
|
|
55
|
+
width: $size;
|
|
56
|
+
height: $size;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.input {
|
|
60
|
+
border-top: var(--border);
|
|
61
|
+
border-bottom-left-radius: var(--border--radius);
|
|
62
|
+
border-bottom-right-radius: var(--border--radius);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.highlight {
|
|
66
|
+
background-color: var(--color--mark);
|
|
67
|
+
color: var(--color--foreground);
|
|
68
|
+
border-radius: var(--border--radius);
|
|
69
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by scripts/generate-scss-types.ts - do not edit.
|
|
2
|
+
declare const styles: {
|
|
3
|
+
readonly content: string;
|
|
4
|
+
readonly coordinates: string;
|
|
5
|
+
readonly highlight: string;
|
|
6
|
+
readonly icon: string;
|
|
7
|
+
readonly input: string;
|
|
8
|
+
readonly invalid: string;
|
|
9
|
+
readonly list: string;
|
|
10
|
+
readonly listContainer: string;
|
|
11
|
+
readonly stat: string;
|
|
12
|
+
readonly valid: string;
|
|
13
|
+
readonly words: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default styles;
|