@scrabble-solver/scrabble-solver 2.15.8 → 2.15.10
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +13 -13
- package/.next/cache/.rscinfo +1 -1
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/.next/diagnostics/framework.json +1 -1
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +4 -4
- package/.next/required-server-files.json +1 -2
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/60.js +1 -1
- package/.next/server/chunks/812.js +1 -1
- package/.next/server/chunks/974.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/_app.js +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_error.js +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/dictionary/[locale]/[word].js +2 -2
- package/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
- package/.next/server/pages/api/dictionary/[locale].js +1 -1
- package/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
- package/.next/server/pages/api/solve.js +1 -1
- package/.next/server/pages/api/solve.js.nft.json +1 -1
- package/.next/server/pages/api/verify.js +1 -1
- package/.next/server/pages/api/verify.js.nft.json +1 -1
- package/.next/server/pages/api/visit.js +1 -1
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/index.js +1 -1
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/server/webpack-api-runtime.js +1 -1
- package/.next/static/chunks/{main-b934e2c3dd3b55b5.js → main-016492249b3393e2.js} +1 -1
- package/.next/static/chunks/pages/{404-7451dd58396eaa39.js → 404-590e2a3839c1d9e0.js} +1 -1
- package/.next/static/chunks/pages/_app-ac93a74c390f2ab8.js +1 -0
- package/.next/static/chunks/pages/index-e5f1caa581e6d3b8.js +1 -0
- package/.next/static/chunks/webpack-6224d37324e372cb.js +1 -0
- package/.next/static/{IJuVKnkd8P2us9rVuan82 → ylO_ttKeJTuoqDYywao5A}/_buildManifest.js +1 -1
- package/.next/trace +23 -23
- package/LICENSE +1 -1
- package/next.config.js +3 -0
- package/package.json +11 -10
- package/src/api/getServerLoggingData.ts +1 -3
- package/src/api/index.ts +5 -5
- package/src/api/isBoardValid.ts +3 -5
- package/src/api/isCellValid.ts +4 -6
- package/src/api/isCharacterValid.ts +2 -3
- package/src/api/isRowValid.ts +3 -5
- package/src/components/Alert/Alert.tsx +1 -3
- package/src/components/Alert/index.ts +1 -1
- package/src/components/Badge/Badge.tsx +1 -3
- package/src/components/Badge/index.ts +1 -1
- package/src/components/Board/Board.tsx +3 -5
- package/src/components/Board/BoardPure.tsx +2 -2
- package/src/components/Board/components/Actions/Actions.tsx +3 -5
- package/src/components/Board/components/Actions/index.ts +1 -1
- package/src/components/Board/components/Cell/Cell.tsx +3 -5
- package/src/components/Board/components/Cell/index.ts +1 -1
- package/src/components/Board/components/InputPrompt/InputPrompt.tsx +3 -5
- package/src/components/Board/components/InputPrompt/index.ts +1 -1
- package/src/components/Board/components/ToggleDirectionButton/ToggleDirectionButton.tsx +2 -4
- package/src/components/Board/components/ToggleDirectionButton/index.ts +1 -1
- package/src/components/Board/components/index.ts +4 -4
- package/src/components/Board/hooks/index.ts +6 -6
- package/src/components/Board/hooks/useBackgroundImage.tsx +7 -9
- package/src/components/Board/hooks/useBoardStyle.ts +7 -9
- package/src/components/Board/hooks/useFloatingActions.ts +1 -3
- package/src/components/Board/hooks/useFloatingFocus.ts +1 -3
- package/src/components/Board/hooks/useFloatingInputPrompt.ts +1 -3
- package/src/components/Board/hooks/useGrid.ts +7 -9
- package/src/components/Board/index.ts +1 -1
- package/src/components/Board/lib/getBonusColor.ts +1 -3
- package/src/components/Board/lib/getPositionInGrid.ts +1 -3
- package/src/components/Board/lib/index.ts +2 -2
- package/src/components/Button/Button.tsx +3 -3
- package/src/components/Button/Link.tsx +1 -3
- package/src/components/Button/index.ts +1 -1
- package/src/components/Dictionary/Dictionary.tsx +3 -5
- package/src/components/Dictionary/index.ts +1 -1
- package/src/components/DictionaryInput/DictionaryInput.tsx +1 -3
- package/src/components/DictionaryInput/index.ts +1 -1
- package/src/components/EmptyState/EmptyState.tsx +4 -6
- package/src/components/EmptyState/index.ts +1 -1
- package/src/components/IconButton/IconButton.tsx +3 -3
- package/src/components/IconButton/Link.tsx +1 -3
- package/src/components/IconButton/index.ts +1 -1
- package/src/components/Key/Key.tsx +1 -3
- package/src/components/Key/index.ts +1 -1
- package/src/components/Keys/Arrows/Arrows.tsx +2 -4
- package/src/components/Keys/Arrows/index.ts +1 -1
- package/src/components/{keys.tsx → Keys/index.tsx} +3 -1
- package/src/components/Loading/Loading.tsx +2 -4
- package/src/components/Loading/index.ts +1 -1
- package/src/components/Logo/Logo.tsx +1 -3
- package/src/components/Logo/LogoBlueprint.tsx +2 -4
- package/src/components/Logo/index.ts +1 -1
- package/src/components/Modal/Modal.tsx +3 -3
- package/src/components/Modal/components/Section/Section.tsx +1 -3
- package/src/components/Modal/components/Section/index.ts +1 -1
- package/src/components/Modal/components/index.ts +1 -1
- package/src/components/Modal/index.ts +1 -1
- package/src/components/NavButtons/NavButtons.tsx +3 -3
- package/src/components/NavButtons/index.ts +1 -1
- package/src/components/NotFound/NotFound.tsx +2 -4
- package/src/components/NotFound/index.ts +1 -1
- package/src/components/PlainTiles/PlainTiles.tsx +10 -4
- package/src/components/PlainTiles/Tile.tsx +1 -3
- package/src/components/PlainTiles/index.ts +1 -1
- package/src/components/PlainTiles/lib/createPlainTile.ts +10 -6
- package/src/components/PlainTiles/lib/createPlainTiles.ts +2 -4
- package/src/components/PlainTiles/lib/getViewbox.ts +1 -3
- package/src/components/PlainTiles/lib/getX.ts +1 -3
- package/src/components/PlainTiles/lib/getY.ts +1 -3
- package/src/components/PlainTiles/lib/index.ts +6 -6
- package/src/components/PlainTiles/lib/randomize.ts +1 -3
- package/src/components/Progress/Progress.tsx +1 -3
- package/src/components/Progress/index.ts +1 -1
- package/src/components/Rack/Rack.tsx +9 -11
- package/src/components/Rack/components/InputPrompt/InputPrompt.tsx +3 -5
- package/src/components/Rack/components/InputPrompt/index.ts +1 -1
- package/src/components/Rack/components/RackTile/RackTile.tsx +9 -10
- package/src/components/Rack/components/RackTile/index.ts +1 -1
- package/src/components/Rack/components/index.ts +2 -2
- package/src/components/Rack/index.ts +1 -1
- package/src/components/Radio/Radio.tsx +1 -3
- package/src/components/Radio/index.ts +1 -1
- package/src/components/Results/Cell.tsx +9 -3
- package/src/components/Results/Header.tsx +2 -4
- package/src/components/Results/HeaderButton.tsx +1 -3
- package/src/components/Results/Result.tsx +2 -4
- package/src/components/Results/Results.tsx +7 -9
- package/src/components/Results/SolveButton.tsx +2 -4
- package/src/components/Results/index.ts +1 -1
- package/src/components/ResultsInput/ResultsInput.tsx +1 -3
- package/src/components/ResultsInput/index.ts +1 -1
- package/src/components/SeoMessage/SeoMessage.tsx +4 -6
- package/src/components/SeoMessage/index.ts +1 -1
- package/src/components/Solver/Solver.tsx +8 -8
- package/src/components/Solver/components/InsertButton/InsertButton.tsx +2 -4
- package/src/components/Solver/components/InsertButton/index.ts +1 -1
- package/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.tsx +4 -6
- package/src/components/Solver/components/ResultCandidatePicker/index.ts +1 -1
- package/src/components/Solver/components/index.ts +2 -2
- package/src/components/Solver/index.ts +1 -1
- package/src/components/Spinner/Spinner.tsx +1 -3
- package/src/components/Spinner/index.ts +1 -1
- package/src/components/Tile/Tile.tsx +2 -4
- package/src/components/Tile/TilePure.tsx +2 -2
- package/src/components/Tile/index.ts +1 -1
- package/src/components/Tooltip/TooltipTrigger.tsx +5 -3
- package/src/components/index.ts +24 -25
- package/src/hooks/index.ts +13 -13
- package/src/hooks/useAppLayout.ts +19 -15
- package/src/hooks/useColumns.ts +2 -4
- package/src/hooks/useDirection.ts +1 -3
- package/src/hooks/useEffectOnce.ts +8 -2
- package/src/hooks/useIsTouchDevice.ts +2 -4
- package/src/hooks/useLanguage.ts +1 -3
- package/src/hooks/useLatest.ts +1 -3
- package/src/hooks/useLocalStorage.ts +1 -3
- package/src/hooks/useMedia.ts +1 -3
- package/src/hooks/useMediaQueries.ts +2 -4
- package/src/hooks/useMediaQuery.ts +2 -4
- package/src/hooks/useOnWindowResize.ts +1 -3
- package/src/hooks/useViewportSize.ts +2 -4
- package/src/i18n/i18n.ts +1 -3
- package/src/i18n/index.ts +1 -1
- package/src/lib/arrayEquals.ts +1 -3
- package/src/lib/createArray.ts +1 -3
- package/src/lib/createComparator.ts +3 -5
- package/src/lib/createGridOf.ts +2 -4
- package/src/lib/createKeyComparator.ts +6 -5
- package/src/lib/createKeyboardNavigation.ts +2 -4
- package/src/lib/createNullMovingComparator.test.ts +1 -1
- package/src/lib/createNullMovingComparator.ts +1 -3
- package/src/lib/createRegExp.ts +1 -3
- package/src/lib/createStringComparator.ts +5 -3
- package/src/lib/detectLocale.ts +1 -3
- package/src/lib/extractCharacters.test.ts +3 -2
- package/src/lib/extractCharacters.ts +17 -5
- package/src/lib/extractCharactersByCase.test.ts +1 -1
- package/src/lib/extractCharactersByCase.ts +2 -4
- package/src/lib/extractInputValue.ts +1 -3
- package/src/lib/findCell.ts +1 -3
- package/src/lib/getCellSize.ts +3 -5
- package/src/lib/getCoordinate.ts +1 -3
- package/src/lib/getCoordinates.ts +2 -4
- package/src/lib/getRemainingTiles.ts +8 -5
- package/src/lib/getRemainingTilesCount.ts +1 -3
- package/src/lib/getRemainingTilesGroups.ts +3 -5
- package/src/lib/getTileSizes.ts +1 -3
- package/src/lib/getTotalRemainingTilesCount.ts +1 -3
- package/src/lib/groupResults.ts +3 -5
- package/src/lib/guessLocale.ts +2 -4
- package/src/lib/index.ts +39 -39
- package/src/lib/inverseDirection.ts +1 -3
- package/src/lib/isCtrl.ts +1 -3
- package/src/lib/isMac.ts +3 -4
- package/src/lib/isRegExp.ts +1 -3
- package/src/lib/isStringArray.ts +1 -3
- package/src/lib/isUpperCase.ts +1 -3
- package/src/lib/memoize.ts +18 -20
- package/src/lib/noop.ts +1 -3
- package/src/lib/numberComparator.ts +1 -3
- package/src/lib/resultMatchesCellFilter.ts +1 -3
- package/src/lib/reverseComparator.ts +1 -3
- package/src/lib/sortGroupedResults.ts +2 -4
- package/src/lib/sortResults.ts +5 -7
- package/src/lib/unorderedArraysEqual.ts +2 -4
- package/src/lib/zipCharactersAndTiles.ts +1 -3
- package/src/modals/DictionaryModal/DictionaryModal.tsx +2 -2
- package/src/modals/DictionaryModal/index.ts +1 -1
- package/src/modals/KeyMapModal/KeyMapModal.tsx +2 -2
- package/src/modals/KeyMapModal/components/Mapping/Mapping.tsx +1 -3
- package/src/modals/KeyMapModal/components/Mapping/index.ts +1 -1
- package/src/modals/KeyMapModal/components/index.ts +1 -1
- package/src/modals/KeyMapModal/index.ts +1 -1
- package/src/modals/MenuModal/MenuModal.tsx +2 -2
- package/src/modals/MenuModal/index.ts +1 -1
- package/src/modals/RemainingTilesModal/RemainingTilesModal.tsx +2 -2
- package/src/modals/RemainingTilesModal/components/Character/Character.tsx +1 -3
- package/src/modals/RemainingTilesModal/components/Character/index.ts +1 -1
- package/src/modals/RemainingTilesModal/components/index.ts +1 -1
- package/src/modals/RemainingTilesModal/index.ts +1 -1
- package/src/modals/ResultsModal/ResultsModal.tsx +2 -2
- package/src/modals/ResultsModal/index.ts +1 -1
- package/src/modals/SettingsModal/SettingsModal.tsx +2 -2
- package/src/modals/SettingsModal/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -3
- package/src/modals/SettingsModal/components/AutoGroupTilesSetting/index.ts +1 -1
- package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.tsx +4 -10
- package/src/modals/SettingsModal/components/ConfigSetting/index.ts +1 -1
- package/src/modals/SettingsModal/components/ConfigSetting/lib.ts +19 -0
- package/src/modals/SettingsModal/components/InputModeSetting/InputModeSetting.tsx +1 -3
- package/src/modals/SettingsModal/components/InputModeSetting/index.ts +1 -1
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.tsx +1 -3
- package/src/modals/SettingsModal/components/LocaleSetting/index.ts +1 -1
- package/src/modals/SettingsModal/components/ShowCoordinatesSetting/ShowCoordinatesSetting.tsx +1 -3
- package/src/modals/SettingsModal/components/ShowCoordinatesSetting/index.ts +1 -1
- package/src/modals/SettingsModal/components/index.ts +5 -5
- package/src/modals/SettingsModal/index.ts +1 -1
- package/src/modals/WordsModal/WordsModal.tsx +2 -2
- package/src/modals/WordsModal/index.ts +1 -1
- package/src/modals/index.ts +7 -7
- package/src/pages/_app.tsx +2 -1
- package/src/pages/api/dictionary/[locale]/[word].ts +1 -1
- package/src/pages/api/dictionary/[locale]/index.ts +1 -1
- package/src/pages/api/solve.ts +6 -4
- package/src/pages/api/verify.ts +6 -4
- package/src/pages/api/visit.ts +2 -2
- package/src/pages/index.tsx +7 -0
- package/src/sdk/fetch.ts +1 -3
- package/src/sdk/fetchJson.ts +2 -4
- package/src/sdk/findWordDefinitions.ts +2 -4
- package/src/sdk/getDictionary.ts +2 -4
- package/src/sdk/index.ts +4 -4
- package/src/sdk/solve.ts +2 -4
- package/src/sdk/verify.ts +2 -4
- package/src/sdk/visit.ts +1 -3
- package/src/service-worker/average.ts +1 -3
- package/src/service-worker/dictionaries/expirationManager.ts +1 -3
- package/src/service-worker/dictionaries/getDictionary.ts +3 -5
- package/src/service-worker/dictionaries/getDictionaryUrl.ts +1 -3
- package/src/service-worker/dictionaries/index.ts +2 -2
- package/src/service-worker/dictionaries/revalidateDictionary.ts +3 -5
- package/src/service-worker/getTrie.ts +1 -3
- package/src/service-worker/index.ts +4 -2
- package/src/service-worker/routeSolveRequests.ts +17 -11
- package/src/service-worker/routeVerifyRequests.ts +7 -5
- package/src/serviceWorkerManager.ts +4 -4
- package/src/state/index.ts +4 -4
- package/src/state/localStorage.ts +10 -12
- package/src/state/sagas.ts +5 -2
- package/src/state/selectors.ts +2 -5
- package/src/state/slices/boardInitialState.ts +6 -7
- package/src/state/slices/boardSlice.ts +5 -7
- package/src/state/slices/cellFilterInitialState.ts +1 -3
- package/src/state/slices/cellFilterSlice.ts +2 -4
- package/src/state/slices/dictionaryInitialState.ts +2 -4
- package/src/state/slices/dictionarySlice.ts +2 -4
- package/src/state/slices/index.ts +16 -16
- package/src/state/slices/rackInitialState.ts +2 -4
- package/src/state/slices/rackSlice.ts +2 -4
- package/src/state/slices/resultsInitialState.ts +1 -3
- package/src/state/slices/resultsSlice.ts +2 -4
- package/src/state/slices/settingsInitialState.ts +2 -4
- package/src/state/slices/settingsSlice.ts +2 -4
- package/src/state/slices/solveInitialState.ts +3 -5
- package/src/state/slices/solveSlice.ts +2 -4
- package/src/state/slices/verifyInitialState.ts +2 -4
- package/src/state/slices/verifySlice.ts +2 -4
- package/src/state/store.ts +1 -3
- package/src/state/useTranslate.ts +2 -4
- package/src/state/useTypedSelector.ts +1 -3
- package/src/types/api.ts +15 -0
- package/src/types/index.ts +2 -0
- package/tsconfig.json +1 -1
- package/.next/cache/eslint/.cache_8dgz12 +0 -1
- package/.next/static/chunks/pages/_app-34618eeeff128581.js +0 -1
- package/.next/static/chunks/pages/index-d492616d9bc42176.js +0 -1
- package/.next/static/chunks/webpack-4224e970a97a4a86.js +0 -1
- package/src/components/Keys/index.ts +0 -1
- package/tsconfig.jest.json +0 -7
- /package/.next/static/{IJuVKnkd8P2us9rVuan82 → ylO_ttKeJTuoqDYywao5A}/_ssgManifest.js +0 -0
package/LICENSE
CHANGED
package/next.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/scrabble-solver",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.10",
|
|
4
4
|
"description": "Scrabble Solver 2 - App",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"@floating-ui/react": "^0.27.5",
|
|
28
28
|
"@kamilmielnik/trie": "^4.0.0",
|
|
29
29
|
"@reduxjs/toolkit": "^2.6.1",
|
|
30
|
-
"@scrabble-solver/configs": "^2.15.
|
|
31
|
-
"@scrabble-solver/constants": "^2.15.
|
|
32
|
-
"@scrabble-solver/dictionaries": "^2.15.
|
|
33
|
-
"@scrabble-solver/logger": "^2.15.
|
|
34
|
-
"@scrabble-solver/solver": "^2.15.
|
|
35
|
-
"@scrabble-solver/types": "^2.15.
|
|
36
|
-
"@scrabble-solver/word-definitions": "^2.15.
|
|
30
|
+
"@scrabble-solver/configs": "^2.15.10",
|
|
31
|
+
"@scrabble-solver/constants": "^2.15.10",
|
|
32
|
+
"@scrabble-solver/dictionaries": "^2.15.10",
|
|
33
|
+
"@scrabble-solver/logger": "^2.15.10",
|
|
34
|
+
"@scrabble-solver/solver": "^2.15.10",
|
|
35
|
+
"@scrabble-solver/types": "^2.15.10",
|
|
36
|
+
"@scrabble-solver/word-definitions": "^2.15.10",
|
|
37
37
|
"classnames": "^2.5.1",
|
|
38
38
|
"env-cmd": "^10.1.0",
|
|
39
39
|
"include-media": "^2.0.0",
|
|
40
40
|
"include-media-query-builder": "^1.1.0",
|
|
41
|
-
"next": "^15.2.
|
|
41
|
+
"next": "^15.2.4",
|
|
42
42
|
"normalize.css": "^8.0.1",
|
|
43
43
|
"react": "^19.0.0",
|
|
44
44
|
"react-cool-onclickoutside": "^1.7.0",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"react-window": "^1.8.11",
|
|
50
50
|
"redux-saga": "^1.3.0",
|
|
51
51
|
"store2": "^2.14.4",
|
|
52
|
+
"transliteration": "^2.3.5",
|
|
52
53
|
"use-debounce": "^10.0.4",
|
|
53
54
|
"workbox-expiration": "^7.3.0",
|
|
54
55
|
"workbox-precaching": "^7.3.0",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"@types/redux-saga": "^0.10.5",
|
|
71
72
|
"sass": "^1.86.0"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "dab5a817c1bde1a3ebf8e8907215adf12af5cb27"
|
|
74
75
|
}
|
|
@@ -8,12 +8,10 @@ interface ServerLoggingData {
|
|
|
8
8
|
xRealIp?: string | string[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const getServerLoggingData = (request: NextApiRequest): ServerLoggingData => ({
|
|
11
|
+
export const getServerLoggingData = (request: NextApiRequest): ServerLoggingData => ({
|
|
12
12
|
origin: request.headers.origin,
|
|
13
13
|
referer: request.headers.referer,
|
|
14
14
|
userAgent: request.headers['user-agent'],
|
|
15
15
|
xForwardedFor: request.headers['x-forwarded-for'],
|
|
16
16
|
xRealIp: request.headers['x-real-ip'],
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
export default getServerLoggingData;
|
package/src/api/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { getServerLoggingData } from './getServerLoggingData';
|
|
2
|
+
export { isBoardValid } from './isBoardValid';
|
|
3
|
+
export { isCellValid } from './isCellValid';
|
|
4
|
+
export { isCharacterValid } from './isCharacterValid';
|
|
5
|
+
export { isRowValid } from './isRowValid';
|
package/src/api/isBoardValid.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BoardJson, CellJson, Config } from '@scrabble-solver/types';
|
|
2
2
|
|
|
3
|
-
import isRowValid from './isRowValid';
|
|
3
|
+
import { isRowValid } from './isRowValid';
|
|
4
4
|
|
|
5
|
-
const isBoardValid = (board: BoardJson, config: Config): boolean => {
|
|
6
|
-
if (board.length !== config.
|
|
5
|
+
export const isBoardValid = (board: BoardJson, config: Config): boolean => {
|
|
6
|
+
if (board.length !== config.boardHeight) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -39,5 +39,3 @@ const areTwoCharacterTilesValid = (board: CellJson[][], config: Config): boolean
|
|
|
39
39
|
|
|
40
40
|
return true;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
export default isBoardValid;
|
package/src/api/isCellValid.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { CellJson, Config } from '@scrabble-solver/types';
|
|
2
2
|
|
|
3
|
-
import isCharacterValid from './isCharacterValid';
|
|
3
|
+
import { isCharacterValid } from './isCharacterValid';
|
|
4
4
|
|
|
5
|
-
const isCellValid = (cell: CellJson, config: Config): boolean => {
|
|
5
|
+
export const isCellValid = (cell: CellJson, config: Config): boolean => {
|
|
6
6
|
const { isEmpty, tile, x, y } = cell;
|
|
7
7
|
|
|
8
|
-
if (x < 0 || x >= config.
|
|
8
|
+
if (x < 0 || x >= config.boardWidth) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
if (y < 0 || y >= config.
|
|
12
|
+
if (y < 0 || y >= config.boardHeight) {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -23,5 +23,3 @@ const isCellValid = (cell: CellJson, config: Config): boolean => {
|
|
|
23
23
|
|
|
24
24
|
return true;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
export default isCellValid;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const TWO_TILE_CHARACTER_LENGTH = 2;
|
|
2
|
+
|
|
2
3
|
const MAX_CHARACTER_LENGTH = TWO_TILE_CHARACTER_LENGTH;
|
|
3
4
|
|
|
4
|
-
const isCharacterValid = (character: string): boolean => {
|
|
5
|
+
export const isCharacterValid = (character: string): boolean => {
|
|
5
6
|
/*
|
|
6
7
|
* We could be strict here and check whether config.hasCharacter(character) || character === BLANK
|
|
7
8
|
* but since this case won't really affect/break solving, we don't need to worry about it.
|
|
@@ -9,5 +10,3 @@ const isCharacterValid = (character: string): boolean => {
|
|
|
9
10
|
*/
|
|
10
11
|
return character.length !== 0 && character.length <= MAX_CHARACTER_LENGTH;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
export default isCharacterValid;
|
package/src/api/isRowValid.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CellJson, Config } from '@scrabble-solver/types';
|
|
2
2
|
|
|
3
|
-
import isCellValid from './isCellValid';
|
|
3
|
+
import { isCellValid } from './isCellValid';
|
|
4
4
|
|
|
5
|
-
const isRowValid = (row: CellJson[], config: Config): boolean => {
|
|
6
|
-
if (row.length !== config.
|
|
5
|
+
export const isRowValid = (row: CellJson[], config: Config): boolean => {
|
|
6
|
+
if (row.length !== config.boardWidth) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -15,5 +15,3 @@ const isRowValid = (row: CellJson[], config: Config): boolean => {
|
|
|
15
15
|
|
|
16
16
|
return true;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
export default isRowValid;
|
|
@@ -18,7 +18,7 @@ const ICON_PER_TYPE: Record<Props['variant'], FunctionComponent<SVGAttributes<SV
|
|
|
18
18
|
warning: ExclamationTriangleFill,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const Alert: FunctionComponent<Props> = ({ children, className, variant, ...props }) => {
|
|
21
|
+
export const Alert: FunctionComponent<Props> = ({ children, className, variant, ...props }) => {
|
|
22
22
|
const Icon = ICON_PER_TYPE[variant];
|
|
23
23
|
|
|
24
24
|
return (
|
|
@@ -39,5 +39,3 @@ const Alert: FunctionComponent<Props> = ({ children, className, variant, ...prop
|
|
|
39
39
|
</div>
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
export default Alert;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Alert } from './Alert';
|
|
@@ -8,8 +8,6 @@ interface Props {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const Badge: FunctionComponent<Props> = ({ children, className }) => (
|
|
11
|
+
export const Badge: FunctionComponent<Props> = ({ children, className }) => (
|
|
12
12
|
<div className={classNames(styles.badge, className)}>{children}</div>
|
|
13
13
|
);
|
|
14
|
-
|
|
15
|
-
export default Badge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Badge } from './Badge';
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from 'state';
|
|
24
24
|
|
|
25
25
|
import styles from './Board.module.scss';
|
|
26
|
-
import BoardPure from './BoardPure';
|
|
26
|
+
import { BoardPure } from './BoardPure';
|
|
27
27
|
import { Actions, InputPrompt } from './components';
|
|
28
28
|
import { useBoardStyle, useFloatingActions, useFloatingFocus, useFloatingInputPrompt, useGrid } from './hooks';
|
|
29
29
|
|
|
@@ -31,7 +31,7 @@ interface Props {
|
|
|
31
31
|
className?: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const Board: FunctionComponent<Props> = ({ className }) => {
|
|
34
|
+
export const Board: FunctionComponent<Props> = ({ className }) => {
|
|
35
35
|
const dispatch = useDispatch();
|
|
36
36
|
const locale = useTypedSelector(selectLocale);
|
|
37
37
|
const rows = useTypedSelector(selectRowsWithCandidate);
|
|
@@ -116,7 +116,7 @@ const Board: FunctionComponent<Props> = ({ className }) => {
|
|
|
116
116
|
dispatch(solveSlice.actions.submit());
|
|
117
117
|
setHasFocus(false);
|
|
118
118
|
},
|
|
119
|
-
[activeIndex, dispatch, locale],
|
|
119
|
+
[activeIndex, dispatch, insertValue, locale],
|
|
120
120
|
);
|
|
121
121
|
|
|
122
122
|
const handleToggleBlank = useCallback(() => {
|
|
@@ -227,5 +227,3 @@ const Board: FunctionComponent<Props> = ({ className }) => {
|
|
|
227
227
|
</>
|
|
228
228
|
);
|
|
229
229
|
};
|
|
230
|
-
|
|
231
|
-
export default Board;
|
|
@@ -38,7 +38,7 @@ interface Props {
|
|
|
38
38
|
onPaste: ClipboardEventHandler<HTMLInputElement>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const
|
|
41
|
+
const BoardPureBase = forwardRef<HTMLDivElement, Props>(
|
|
42
42
|
(
|
|
43
43
|
{
|
|
44
44
|
className,
|
|
@@ -149,4 +149,4 @@ const BoardPure = forwardRef<HTMLDivElement, Props>(
|
|
|
149
149
|
),
|
|
150
150
|
);
|
|
151
151
|
|
|
152
|
-
export
|
|
152
|
+
export const BoardPure = memo(BoardPureBase);
|
|
@@ -9,8 +9,8 @@ import { findCell, isMac } from 'lib';
|
|
|
9
9
|
import { selectCellFilter, selectInputMode, selectResultCandidateCells, useTranslate, useTypedSelector } from 'state';
|
|
10
10
|
import { Direction } from 'types';
|
|
11
11
|
|
|
12
|
-
import Button from '../../../Button';
|
|
13
|
-
import ToggleDirectionButton from '../ToggleDirectionButton';
|
|
12
|
+
import { Button } from '../../../Button';
|
|
13
|
+
import { ToggleDirectionButton } from '../ToggleDirectionButton';
|
|
14
14
|
|
|
15
15
|
import styles from './Actions.module.scss';
|
|
16
16
|
import { getNextCellFilter } from './lib';
|
|
@@ -24,7 +24,7 @@ interface Props extends HTMLProps<HTMLDivElement> {
|
|
|
24
24
|
onToggleFilterCell: MouseEventHandler<HTMLButtonElement>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const Actions = forwardRef<HTMLDivElement, Props>(
|
|
27
|
+
export const Actions = forwardRef<HTMLDivElement, Props>(
|
|
28
28
|
(
|
|
29
29
|
{ cell, className, direction, onDirectionToggle, onEnterWord, onToggleBlank, onToggleFilterCell, ...props },
|
|
30
30
|
ref,
|
|
@@ -98,5 +98,3 @@ const Actions = forwardRef<HTMLDivElement, Props>(
|
|
|
98
98
|
);
|
|
99
99
|
},
|
|
100
100
|
);
|
|
101
|
-
|
|
102
|
-
export default Actions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Actions } from './Actions';
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
useTypedSelector,
|
|
22
22
|
} from 'state';
|
|
23
23
|
|
|
24
|
-
import Tile from '../../../Tile';
|
|
24
|
+
import { Tile } from '../../../Tile';
|
|
25
25
|
|
|
26
26
|
import styles from './Cell.module.scss';
|
|
27
27
|
|
|
@@ -38,7 +38,7 @@ interface Props {
|
|
|
38
38
|
onFocus: (x: number, y: number) => void;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const Cell: FunctionComponent<Props> = ({
|
|
41
|
+
export const Cell: FunctionComponent<Props> = ({
|
|
42
42
|
cell,
|
|
43
43
|
cellBottom,
|
|
44
44
|
cellLeft,
|
|
@@ -101,7 +101,7 @@ const Cell: FunctionComponent<Props> = ({
|
|
|
101
101
|
})}
|
|
102
102
|
className={classNames(styles.tile, className, {
|
|
103
103
|
[styles.first3]: x < 3,
|
|
104
|
-
[styles.last3]: config.
|
|
104
|
+
[styles.last3]: config.boardWidth - x - 1 < 3,
|
|
105
105
|
[styles.sharpTopLeft]: cellTop?.hasTile() || cellLeft?.hasTile(),
|
|
106
106
|
[styles.sharpTopRight]: cellTop?.hasTile() || cellRight?.hasTile(),
|
|
107
107
|
[styles.sharpBottomLeft]: cellBottom?.hasTile() || cellLeft?.hasTile(),
|
|
@@ -123,5 +123,3 @@ const Cell: FunctionComponent<Props> = ({
|
|
|
123
123
|
/>
|
|
124
124
|
);
|
|
125
125
|
};
|
|
126
|
-
|
|
127
|
-
export default Cell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Cell } from './Cell';
|
|
@@ -5,8 +5,8 @@ import { Check } from 'icons';
|
|
|
5
5
|
import { useTranslate } from 'state';
|
|
6
6
|
import { Direction } from 'types';
|
|
7
7
|
|
|
8
|
-
import Button from '../../../Button';
|
|
9
|
-
import ToggleDirectionButton from '../ToggleDirectionButton';
|
|
8
|
+
import { Button } from '../../../Button';
|
|
9
|
+
import { ToggleDirectionButton } from '../ToggleDirectionButton';
|
|
10
10
|
|
|
11
11
|
import styles from './InputPrompt.module.scss';
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ interface Props extends Omit<HTMLProps<HTMLFormElement>, 'onSubmit'> {
|
|
|
18
18
|
onSubmit: (input: string) => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const InputPrompt = forwardRef<HTMLFormElement, Props>(
|
|
21
|
+
export const InputPrompt = forwardRef<HTMLFormElement, Props>(
|
|
22
22
|
({ className, direction, initialValue, onDirectionToggle, onSubmit, ...props }, ref) => {
|
|
23
23
|
const translate = useTranslate();
|
|
24
24
|
const [inputRef, setInputRef] = useState<HTMLInputElement | null>(null);
|
|
@@ -78,5 +78,3 @@ const InputPrompt = forwardRef<HTMLFormElement, Props>(
|
|
|
78
78
|
);
|
|
79
79
|
},
|
|
80
80
|
);
|
|
81
|
-
|
|
82
|
-
export default InputPrompt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { InputPrompt } from './InputPrompt';
|
|
@@ -6,7 +6,7 @@ import { ArrowDown } from 'icons';
|
|
|
6
6
|
import { useTranslate } from 'state';
|
|
7
7
|
import { Direction } from 'types';
|
|
8
8
|
|
|
9
|
-
import Button from '../../../Button';
|
|
9
|
+
import { Button } from '../../../Button';
|
|
10
10
|
|
|
11
11
|
import styles from './ToggleDirectionButton.module.scss';
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
15
15
|
direction: Direction;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const ToggleDirectionButton: FunctionComponent<Props> = ({ className, direction, ...props }) => {
|
|
18
|
+
export const ToggleDirectionButton: FunctionComponent<Props> = ({ className, direction, ...props }) => {
|
|
19
19
|
const translate = useTranslate();
|
|
20
20
|
const isTouchDevice = useIsTouchDevice();
|
|
21
21
|
|
|
@@ -39,5 +39,3 @@ const ToggleDirectionButton: FunctionComponent<Props> = ({ className, direction,
|
|
|
39
39
|
/>
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
export default ToggleDirectionButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ToggleDirectionButton } from './ToggleDirectionButton';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
export { Actions } from './Actions';
|
|
2
|
+
export { Cell } from './Cell';
|
|
3
|
+
export { InputPrompt } from './InputPrompt';
|
|
4
|
+
export { ToggleDirectionButton } from './ToggleDirectionButton';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { useBackgroundImage } from './useBackgroundImage';
|
|
2
|
+
export { useBoardStyle } from './useBoardStyle';
|
|
3
|
+
export { useFloatingActions } from './useFloatingActions';
|
|
4
|
+
export { useFloatingFocus } from './useFloatingFocus';
|
|
5
|
+
export { useFloatingInputPrompt } from './useFloatingInputPrompt';
|
|
6
|
+
export { useGrid } from './useGrid';
|
|
@@ -24,17 +24,17 @@ const BONUS_WORD_2 = 'b2';
|
|
|
24
24
|
const BONUS_WORD_3 = 'b3';
|
|
25
25
|
const BONUS_WORD_4 = 'b4';
|
|
26
26
|
|
|
27
|
-
const useBackgroundImage = () => {
|
|
28
|
-
const {
|
|
27
|
+
export const useBackgroundImage = () => {
|
|
28
|
+
const { boardHeight, boardWidth, cellSize, coordinatesSize } = useAppLayout();
|
|
29
29
|
const locale = useTypedSelector(selectLocale);
|
|
30
30
|
const { direction } = LOCALE_FEATURES[locale];
|
|
31
31
|
const showCoordinates = useTypedSelector(selectShowCoordinates);
|
|
32
32
|
const { isLessThanXs } = useMediaQueries();
|
|
33
33
|
const borderRadius = isLessThanXs ? BORDER_RADIUS_XS : BORDER_RADIUS;
|
|
34
34
|
const config = useTypedSelector(selectConfig);
|
|
35
|
-
const center = { x: Math.floor(config.
|
|
36
|
-
const viewBoxHeight =
|
|
37
|
-
const viewBoxWidth =
|
|
35
|
+
const center = { x: Math.floor(config.boardWidth / 2), y: Math.floor(config.boardHeight / 2) };
|
|
36
|
+
const viewBoxHeight = boardHeight;
|
|
37
|
+
const viewBoxWidth = boardWidth;
|
|
38
38
|
const bonusSize = cellSize * 0.8;
|
|
39
39
|
const bonusOffset = cellSize * 0.1;
|
|
40
40
|
const iconSize = cellSize * 0.4;
|
|
@@ -157,7 +157,7 @@ const useBackgroundImage = () => {
|
|
|
157
157
|
</>
|
|
158
158
|
)}
|
|
159
159
|
|
|
160
|
-
{Array.from({ length: config.
|
|
160
|
+
{Array.from({ length: config.boardHeight - 1 }).map((_value, index) => (
|
|
161
161
|
<use
|
|
162
162
|
key={index}
|
|
163
163
|
href={`#${HORIZONTAL_LINE}`}
|
|
@@ -165,7 +165,7 @@ const useBackgroundImage = () => {
|
|
|
165
165
|
/>
|
|
166
166
|
))}
|
|
167
167
|
|
|
168
|
-
{Array.from({ length: config.
|
|
168
|
+
{Array.from({ length: config.boardWidth - 1 }).map((_value, index) => (
|
|
169
169
|
<use
|
|
170
170
|
key={index}
|
|
171
171
|
href={`#${VERTICAL_LINE}`}
|
|
@@ -213,5 +213,3 @@ const useBackgroundImage = () => {
|
|
|
213
213
|
const dataUrl = `data:image/svg+xml;base64,${encodedSvg}`;
|
|
214
214
|
return dataUrl;
|
|
215
215
|
};
|
|
216
|
-
|
|
217
|
-
export default useBackgroundImage;
|
|
@@ -5,9 +5,9 @@ import { getTileSizes } from 'lib';
|
|
|
5
5
|
import { BORDER_WIDTH } from 'parameters';
|
|
6
6
|
import { selectConfig, selectShowCoordinates, useTypedSelector } from 'state';
|
|
7
7
|
|
|
8
|
-
import useBackgroundImage from './useBackgroundImage';
|
|
8
|
+
import { useBackgroundImage } from './useBackgroundImage';
|
|
9
9
|
|
|
10
|
-
const useBoardStyle = () => {
|
|
10
|
+
export const useBoardStyle = () => {
|
|
11
11
|
const config = useTypedSelector(selectConfig);
|
|
12
12
|
const { cellSize } = useAppLayout();
|
|
13
13
|
const { tileFontSize } = getTileSizes(cellSize);
|
|
@@ -20,17 +20,15 @@ const useBoardStyle = () => {
|
|
|
20
20
|
fontSize: tileFontSize,
|
|
21
21
|
gridTemplateColumns:
|
|
22
22
|
showCoordinates === 'hidden'
|
|
23
|
-
? `repeat(${config.
|
|
24
|
-
: `${coordinatesSize}px repeat(${config.
|
|
23
|
+
? `repeat(${config.boardWidth}, 1fr)`
|
|
24
|
+
: `${coordinatesSize}px repeat(${config.boardWidth}, 1fr)`,
|
|
25
25
|
gridTemplateRows:
|
|
26
26
|
showCoordinates === 'hidden'
|
|
27
|
-
? `repeat(${config.
|
|
28
|
-
: `${coordinatesSize}px repeat(${config.
|
|
27
|
+
? `repeat(${config.boardHeight}, 1fr)`
|
|
28
|
+
: `${coordinatesSize}px repeat(${config.boardHeight}, 1fr)`,
|
|
29
29
|
}),
|
|
30
|
-
[backgroundImage, config.
|
|
30
|
+
[backgroundImage, config.boardHeight, config.boardWidth, coordinatesSize, showCoordinates, tileFontSize],
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
return boardStyle;
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
export default useBoardStyle;
|
|
@@ -3,7 +3,7 @@ import { autoUpdate, offset, shift, useFloating } from '@floating-ui/react';
|
|
|
3
3
|
import { useAppLayout } from 'hooks';
|
|
4
4
|
import { BOARD_CELL_ACTIONS_OFFSET } from 'parameters';
|
|
5
5
|
|
|
6
|
-
const useFloatingActions = () => {
|
|
6
|
+
export const useFloatingActions = () => {
|
|
7
7
|
const { actionsWidth } = useAppLayout();
|
|
8
8
|
|
|
9
9
|
return useFloating({
|
|
@@ -18,5 +18,3 @@ const useFloatingActions = () => {
|
|
|
18
18
|
whileElementsMounted: autoUpdate,
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
export default useFloatingActions;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { autoUpdate, useFloating } from '@floating-ui/react';
|
|
2
2
|
|
|
3
|
-
const useFloatingFocus = () => {
|
|
3
|
+
export const useFloatingFocus = () => {
|
|
4
4
|
return useFloating({
|
|
5
5
|
placement: 'top-start',
|
|
6
6
|
whileElementsMounted: autoUpdate,
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
export default useFloatingFocus;
|
|
@@ -2,7 +2,7 @@ import { autoUpdate, offset, shift, useFloating } from '@floating-ui/react';
|
|
|
2
2
|
|
|
3
3
|
import { BOARD_CELL_ACTIONS_OFFSET } from 'parameters';
|
|
4
4
|
|
|
5
|
-
const useFloatingInputPrompt = () => {
|
|
5
|
+
export const useFloatingInputPrompt = () => {
|
|
6
6
|
return useFloating({
|
|
7
7
|
middleware: [
|
|
8
8
|
offset({
|
|
@@ -15,5 +15,3 @@ const useFloatingInputPrompt = () => {
|
|
|
15
15
|
whileElementsMounted: autoUpdate,
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
export default useFloatingInputPrompt;
|
|
@@ -40,7 +40,7 @@ interface Actions {
|
|
|
40
40
|
onPaste: ClipboardEventHandler<HTMLInputElement>;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
43
|
+
export const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
44
44
|
const height = rows.length;
|
|
45
45
|
const width = rows[0].length;
|
|
46
46
|
const dispatch = useDispatch();
|
|
@@ -69,7 +69,7 @@ const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
|
69
69
|
setActiveIndex({ x, y });
|
|
70
70
|
inputRefs[y][x].current?.focus();
|
|
71
71
|
},
|
|
72
|
-
[safeActiveIndex, inputRefs],
|
|
72
|
+
[safeActiveIndex, height, inputRefs, width],
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
const getInputRefPosition = useCallback(
|
|
@@ -106,7 +106,7 @@ const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
characters.forEach((character) => {
|
|
109
|
-
if (x >= config.
|
|
109
|
+
if (x >= config.boardWidth || y >= config.boardHeight) {
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -188,7 +188,7 @@ const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
|
188
188
|
moveFocus(Math.abs(position.x - x) + Math.abs(position.y - y));
|
|
189
189
|
actions.forEach(dispatch);
|
|
190
190
|
},
|
|
191
|
-
[config, directionRef, dispatch, moveFocus, rows],
|
|
191
|
+
[config, directionRef, dispatch, height, moveFocus, rows, width],
|
|
192
192
|
);
|
|
193
193
|
|
|
194
194
|
const onChange = useCallback(
|
|
@@ -219,7 +219,7 @@ const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
|
219
219
|
|
|
220
220
|
insertValue(position, value);
|
|
221
221
|
},
|
|
222
|
-
[dispatch, insertValue, moveFocus, rows],
|
|
222
|
+
[dispatch, insertValue, moveFocus, rows, getInputRefPosition],
|
|
223
223
|
);
|
|
224
224
|
|
|
225
225
|
const onDirectionToggle = useCallback(() => setLastDirection(toggleDirection), []);
|
|
@@ -347,7 +347,7 @@ const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
|
347
347
|
dispatch(boardSlice.actions.toggleCellIsBlank(position));
|
|
348
348
|
},
|
|
349
349
|
});
|
|
350
|
-
}, [changeActiveIndex, config, direction, dispatch, locale, moveFocus, onDirectionToggle, rows]);
|
|
350
|
+
}, [changeActiveIndex, config, direction, dispatch, getInputRefPosition, locale, moveFocus, onDirectionToggle, rows]);
|
|
351
351
|
|
|
352
352
|
const onPaste = useCallback<ClipboardEventHandler>(
|
|
353
353
|
(event) => {
|
|
@@ -366,7 +366,7 @@ const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
|
366
366
|
const value = event.clipboardData.getData('text/plain').toLocaleLowerCase();
|
|
367
367
|
insertValue(position, value);
|
|
368
368
|
},
|
|
369
|
-
[insertValue],
|
|
369
|
+
[getInputRefPosition, insertValue],
|
|
370
370
|
);
|
|
371
371
|
|
|
372
372
|
return [
|
|
@@ -374,5 +374,3 @@ const useGrid = (rows: Cell[][]): [State, Actions] => {
|
|
|
374
374
|
{ insertValue, onChange, onDirectionToggle, onFocus, onKeyDown, onPaste },
|
|
375
375
|
];
|
|
376
376
|
};
|
|
377
|
-
|
|
378
|
-
export default useGrid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Board } from './Board';
|
|
@@ -3,7 +3,7 @@ import { Bonus } from '@scrabble-solver/types';
|
|
|
3
3
|
|
|
4
4
|
import { COLOR_BONUS_CHARACTER, COLOR_BONUS_CHARACTER_MULTIPLIER, COLOR_BONUS_WORD } from 'parameters';
|
|
5
5
|
|
|
6
|
-
const getBonusColor = (bonus: Bonus): string => {
|
|
6
|
+
export const getBonusColor = (bonus: Bonus): string => {
|
|
7
7
|
if (bonus.type === BONUS_WORD) {
|
|
8
8
|
return COLOR_BONUS_WORD[bonus.multiplier];
|
|
9
9
|
}
|
|
@@ -14,5 +14,3 @@ const getBonusColor = (bonus: Bonus): string => {
|
|
|
14
14
|
|
|
15
15
|
return COLOR_BONUS_CHARACTER_MULTIPLIER[bonus.multiplier];
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
export default getBonusColor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Point } from 'types';
|
|
2
2
|
|
|
3
|
-
const getPositionInGrid = <T>(grid: T[][], constraint: (value: T) => boolean): Point | undefined => {
|
|
3
|
+
export const getPositionInGrid = <T>(grid: T[][], constraint: (value: T) => boolean): Point | undefined => {
|
|
4
4
|
for (let y = 0; y < grid.length; ++y) {
|
|
5
5
|
for (let x = 0; x < grid[0].length; ++x) {
|
|
6
6
|
if (constraint(grid[y][x])) {
|
|
@@ -11,5 +11,3 @@ const getPositionInGrid = <T>(grid: T[][], constraint: (value: T) => boolean): P
|
|
|
11
11
|
|
|
12
12
|
return undefined;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
export default getPositionInGrid;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { getBonusColor } from './getBonusColor';
|
|
2
|
+
export { getPositionInGrid } from './getPositionInGrid';
|