@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/src/lib/getTileSizes.ts
CHANGED
|
@@ -6,10 +6,8 @@ interface TileSizes {
|
|
|
6
6
|
tileSize: number;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const getTileSizes = (tileSize: number): TileSizes => ({
|
|
9
|
+
export const getTileSizes = (tileSize: number): TileSizes => ({
|
|
10
10
|
pointsFontSize: Math.max(Math.round(tileSize * 0.25), BOARD_TILE_FONT_SIZE_POINTS_MIN),
|
|
11
11
|
tileFontSize: Math.max(Math.round(tileSize * 0.6), BOARD_TILE_FONT_SIZE_MIN),
|
|
12
12
|
tileSize,
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
export default getTileSizes;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RemainingTile } from 'types';
|
|
2
2
|
|
|
3
|
-
const getTotalRemainingTilesCount = (remainingTiles: RemainingTile[]): number => {
|
|
3
|
+
export const getTotalRemainingTilesCount = (remainingTiles: RemainingTile[]): number => {
|
|
4
4
|
return remainingTiles.reduce((sum, { count }) => sum + count, 0);
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export default getTotalRemainingTilesCount;
|
package/src/lib/groupResults.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Result } from '@scrabble-solver/types';
|
|
|
2
2
|
|
|
3
3
|
import { CellFilterEntry, GroupedResults } from 'types';
|
|
4
4
|
|
|
5
|
-
import createRegExp from './createRegExp';
|
|
6
|
-
import resultMatchesCellFilter from './resultMatchesCellFilter';
|
|
5
|
+
import { createRegExp } from './createRegExp';
|
|
6
|
+
import { resultMatchesCellFilter } from './resultMatchesCellFilter';
|
|
7
7
|
|
|
8
|
-
const groupResults = (
|
|
8
|
+
export const groupResults = (
|
|
9
9
|
results: Result[] | undefined,
|
|
10
10
|
query: string,
|
|
11
11
|
cellFilter: CellFilterEntry[],
|
|
@@ -33,5 +33,3 @@ const groupResults = (
|
|
|
33
33
|
|
|
34
34
|
return { matching, other };
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
export default groupResults;
|
package/src/lib/guessLocale.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Locale } from '@scrabble-solver/types';
|
|
2
2
|
|
|
3
|
-
const guessLocale = (): Locale => {
|
|
3
|
+
export const guessLocale = (): Locale => {
|
|
4
4
|
if (!globalThis.navigator) {
|
|
5
5
|
return Locale.EN_US;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
const locales = Object.values(Locale);
|
|
9
|
-
const exactMatch = locales.find((locale) => globalThis.navigator.language === locale);
|
|
9
|
+
const exactMatch = locales.find((locale) => globalThis.navigator.language === String(locale));
|
|
10
10
|
|
|
11
11
|
if (exactMatch) {
|
|
12
12
|
return exactMatch;
|
|
@@ -18,5 +18,3 @@ const guessLocale = (): Locale => {
|
|
|
18
18
|
|
|
19
19
|
return partialMatch || Locale.EN_US;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
export default guessLocale;
|
package/src/lib/index.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
1
|
+
export { arrayEquals } from './arrayEquals';
|
|
2
|
+
export { createArray } from './createArray';
|
|
3
|
+
export { createComparator } from './createComparator';
|
|
4
|
+
export { createGridOf } from './createGridOf';
|
|
5
|
+
export { createKeyComparator } from './createKeyComparator';
|
|
6
|
+
export { createKeyboardNavigation } from './createKeyboardNavigation';
|
|
7
|
+
export { createNullMovingComparator } from './createNullMovingComparator';
|
|
8
|
+
export { createRegExp } from './createRegExp';
|
|
9
|
+
export { createStringComparator } from './createStringComparator';
|
|
10
|
+
export { detectLocale } from './detectLocale';
|
|
11
|
+
export { extractCharacters } from './extractCharacters';
|
|
12
|
+
export { extractCharactersByCase } from './extractCharactersByCase';
|
|
13
|
+
export { extractInputValue } from './extractInputValue';
|
|
14
|
+
export { findCell } from './findCell';
|
|
15
|
+
export { getCellSize } from './getCellSize';
|
|
16
|
+
export { getCoordinate } from './getCoordinate';
|
|
17
|
+
export { getCoordinates } from './getCoordinates';
|
|
18
|
+
export { getRemainingTiles } from './getRemainingTiles';
|
|
19
|
+
export { getRemainingTilesCount } from './getRemainingTilesCount';
|
|
20
|
+
export { getRemainingTilesGroups } from './getRemainingTilesGroups';
|
|
21
|
+
export { getTileSizes } from './getTileSizes';
|
|
22
|
+
export { getTotalRemainingTilesCount } from './getTotalRemainingTilesCount';
|
|
23
|
+
export { groupResults } from './groupResults';
|
|
24
|
+
export { guessLocale } from './guessLocale';
|
|
25
|
+
export { inverseDirection } from './inverseDirection';
|
|
26
|
+
export { isCtrl } from './isCtrl';
|
|
27
|
+
export { isMac } from './isMac';
|
|
28
|
+
export { isRegExp } from './isRegExp';
|
|
29
|
+
export { isStringArray } from './isStringArray';
|
|
30
|
+
export { isUpperCase } from './isUpperCase';
|
|
31
|
+
export { memoize } from './memoize';
|
|
32
|
+
export { noop } from './noop';
|
|
33
|
+
export { numberComparator } from './numberComparator';
|
|
34
|
+
export { resultMatchesCellFilter } from './resultMatchesCellFilter';
|
|
35
|
+
export { reverseComparator } from './reverseComparator';
|
|
36
|
+
export { sortGroupedResults } from './sortGroupedResults';
|
|
37
|
+
export { sortResults } from './sortResults';
|
|
38
|
+
export { unorderedArraysEqual } from './unorderedArraysEqual';
|
|
39
|
+
export { zipCharactersAndTiles } from './zipCharactersAndTiles';
|
package/src/lib/isCtrl.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { KeyboardEvent } from 'react';
|
|
2
2
|
|
|
3
|
-
const isCtrl = <T>(event: KeyboardEvent<T> | globalThis.KeyboardEvent): boolean => {
|
|
3
|
+
export const isCtrl = <T>(event: KeyboardEvent<T> | globalThis.KeyboardEvent): boolean => {
|
|
4
4
|
return event.ctrlKey || event.metaKey;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export default isCtrl;
|
package/src/lib/isMac.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const isMac = (): boolean => {
|
|
1
|
+
export const isMac = (): boolean => {
|
|
2
2
|
if (!globalThis.navigator) {
|
|
3
3
|
return false;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
7
|
+
return globalThis.navigator.platform.startsWith('Mac') || globalThis.navigator.platform === 'iPhone';
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
-
export default isMac;
|
package/src/lib/isRegExp.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const isRegExp = (value: string): boolean => {
|
|
1
|
+
export const isRegExp = (value: string): boolean => {
|
|
2
2
|
try {
|
|
3
3
|
// eslint-disable-next-line no-new
|
|
4
4
|
new RegExp(value);
|
|
@@ -7,5 +7,3 @@ const isRegExp = (value: string): boolean => {
|
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
export default isRegExp;
|
package/src/lib/isStringArray.ts
CHANGED
package/src/lib/isUpperCase.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Locale } from '@scrabble-solver/types';
|
|
2
2
|
|
|
3
|
-
const isUpperCase = (locale: Locale, value: string): boolean => {
|
|
3
|
+
export const isUpperCase = (locale: Locale, value: string): boolean => {
|
|
4
4
|
return value === value.toLocaleUpperCase(locale);
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export default isUpperCase;
|
package/src/lib/memoize.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
interface AnyFunction {
|
|
2
|
-
(...parameters:
|
|
1
|
+
interface AnyFunction<Args extends unknown[], Result> {
|
|
2
|
+
(...parameters: Args): Result;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
interface
|
|
6
|
-
|
|
5
|
+
interface Entry<Args extends unknown[], Result> {
|
|
6
|
+
parameters: Args;
|
|
7
|
+
result: Result;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const cache: Entry<T>[] = [];
|
|
10
|
+
export const memoize = <Args extends unknown[], Result>(
|
|
11
|
+
fn: AnyFunction<Args, Result>,
|
|
12
|
+
): AnyFunction<Args, Result> & {
|
|
13
|
+
hasCache: (...parameters: Args) => boolean;
|
|
14
|
+
} => {
|
|
15
|
+
const cache: Entry<Args, Result>[] = [];
|
|
16
16
|
|
|
17
|
-
const hasCache = (...parameters:
|
|
17
|
+
const hasCache = (...parameters: Args): boolean => Boolean(readCache(parameters));
|
|
18
18
|
|
|
19
|
-
const readCache = (parameters:
|
|
19
|
+
const readCache = (parameters: Args): Result | undefined => {
|
|
20
20
|
return cache.find((entry) => parametersEqual(entry.parameters, parameters))?.result;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const removeCache = (parameters:
|
|
23
|
+
const removeCache = (parameters: Args): void => {
|
|
24
24
|
const index = cache.findIndex((entry) => parametersEqual(entry.parameters, parameters));
|
|
25
25
|
|
|
26
26
|
if (index >= 0) {
|
|
@@ -28,11 +28,11 @@ const memoize = <T extends AnyFunction>(fn: T): AnyCachedFunction<T> => {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const writeCache = (parameters:
|
|
31
|
+
const writeCache = (parameters: Args, result: Result): void => {
|
|
32
32
|
cache.push({ parameters, result });
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const memoized = (...parameters:
|
|
35
|
+
const memoized = (...parameters: Args): Result => {
|
|
36
36
|
const cached = readCache(parameters);
|
|
37
37
|
|
|
38
38
|
if (cached) {
|
|
@@ -55,12 +55,10 @@ const memoize = <T extends AnyFunction>(fn: T): AnyCachedFunction<T> => {
|
|
|
55
55
|
return Object.assign(memoized, { hasCache });
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
const parametersEqual = <
|
|
58
|
+
const parametersEqual = <Args extends unknown[]>(a: Args, b: Args): boolean => {
|
|
59
59
|
if (a.length !== b.length) {
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
return a.every((parameter:
|
|
63
|
+
return a.every((parameter: Args[typeof index], index: number) => parameter === b[index]);
|
|
64
64
|
};
|
|
65
|
-
|
|
66
|
-
export default memoize;
|
package/src/lib/noop.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Result } from '@scrabble-solver/types';
|
|
|
2
2
|
|
|
3
3
|
import { CellFilterEntry } from 'types';
|
|
4
4
|
|
|
5
|
-
const resultMatchesCellFilter = (result: Result, cellFilter: CellFilterEntry[]) => {
|
|
5
|
+
export const resultMatchesCellFilter = (result: Result, cellFilter: CellFilterEntry[]) => {
|
|
6
6
|
const excludeFilters = cellFilter.filter((filter) => filter.type === 'exclude');
|
|
7
7
|
const matchesExcludeFilters = excludeFilters.every(({ x, y }) => {
|
|
8
8
|
return result.cells.every((cell) => cell.x !== x || cell.y !== y);
|
|
@@ -19,5 +19,3 @@ const resultMatchesCellFilter = (result: Result, cellFilter: CellFilterEntry[])
|
|
|
19
19
|
|
|
20
20
|
return matchesExcludeFilters && matchesIncludeFilters;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
export default resultMatchesCellFilter;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Comparator } from 'types';
|
|
2
2
|
|
|
3
|
-
const reverseComparator = <T>(comparator: Comparator<T>): Comparator<T> => {
|
|
3
|
+
export const reverseComparator = <T>(comparator: Comparator<T>): Comparator<T> => {
|
|
4
4
|
return (a: T, b: T): number => -comparator(a, b);
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export default reverseComparator;
|
|
@@ -2,9 +2,9 @@ import { Locale, ShowCoordinates } from '@scrabble-solver/types';
|
|
|
2
2
|
|
|
3
3
|
import { GroupedResults, Sort } from 'types';
|
|
4
4
|
|
|
5
|
-
import sortResults from './sortResults';
|
|
5
|
+
import { sortResults } from './sortResults';
|
|
6
6
|
|
|
7
|
-
const sortGroupedResults = (
|
|
7
|
+
export const sortGroupedResults = (
|
|
8
8
|
results: GroupedResults | undefined,
|
|
9
9
|
sort: Sort,
|
|
10
10
|
locale: Locale,
|
|
@@ -19,5 +19,3 @@ const sortGroupedResults = (
|
|
|
19
19
|
other: sortResults(results.other, sort, locale, showCoordinates) ?? [],
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
export default sortGroupedResults;
|
package/src/lib/sortResults.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Result, ShowCoordinates } from '@scrabble-solver/types';
|
|
|
2
2
|
|
|
3
3
|
import { Comparator, ResultColumnId, Sort, SortDirection } from 'types';
|
|
4
4
|
|
|
5
|
-
import createKeyComparator from './createKeyComparator';
|
|
6
|
-
import createStringComparator from './createStringComparator';
|
|
7
|
-
import getCoordinates from './getCoordinates';
|
|
8
|
-
import reverseComparator from './reverseComparator';
|
|
5
|
+
import { createKeyComparator } from './createKeyComparator';
|
|
6
|
+
import { createStringComparator } from './createStringComparator';
|
|
7
|
+
import { getCoordinates } from './getCoordinates';
|
|
8
|
+
import { reverseComparator } from './reverseComparator';
|
|
9
9
|
|
|
10
10
|
const comparators: Record<ResultColumnId, (locale: string, showCoordinates: ShowCoordinates) => Comparator<Result>> = {
|
|
11
11
|
[ResultColumnId.BlanksCount]: (locale: string) => createKeyComparator('blanksCount', locale),
|
|
@@ -23,7 +23,7 @@ const comparators: Record<ResultColumnId, (locale: string, showCoordinates: Show
|
|
|
23
23
|
[ResultColumnId.WordsCount]: (locale: string) => createKeyComparator('wordsCount', locale),
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const sortResults = (
|
|
26
|
+
export const sortResults = (
|
|
27
27
|
results: Result[] | undefined,
|
|
28
28
|
sort: Sort,
|
|
29
29
|
locale: string,
|
|
@@ -39,5 +39,3 @@ const sortResults = (
|
|
|
39
39
|
const sortedResults = [...results].sort(finalComparator);
|
|
40
40
|
return sortedResults;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
export default sortResults;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import createComparator from './createComparator';
|
|
1
|
+
import { createComparator } from './createComparator';
|
|
2
2
|
|
|
3
|
-
const unorderedArraysEqual = <T>(a: T[], b: T[], locale: string): boolean => {
|
|
3
|
+
export const unorderedArraysEqual = <T>(a: T[], b: T[], locale: string): boolean => {
|
|
4
4
|
if (a.length !== b.length) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
@@ -10,5 +10,3 @@ const unorderedArraysEqual = <T>(a: T[], b: T[], locale: string): boolean => {
|
|
|
10
10
|
const bSorted = [...b].sort(comparator);
|
|
11
11
|
return aSorted.every((character, index) => character === bSorted[index]);
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
export default unorderedArraysEqual;
|
|
@@ -8,7 +8,7 @@ interface CharacterTilePair {
|
|
|
8
8
|
tile: Tile | null;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const zipCharactersAndTiles = (characters: Rack, tiles: Tile[]): CharacterTilePair[] => {
|
|
11
|
+
export const zipCharactersAndTiles = (characters: Rack, tiles: Tile[]): CharacterTilePair[] => {
|
|
12
12
|
let remainingTiles = [...tiles];
|
|
13
13
|
|
|
14
14
|
return characters.map((character) => {
|
|
@@ -26,5 +26,3 @@ const zipCharactersAndTiles = (characters: Rack, tiles: Tile[]): CharacterTilePa
|
|
|
26
26
|
return { character, tile: null };
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
export default zipCharactersAndTiles;
|
|
@@ -11,7 +11,7 @@ interface Props {
|
|
|
11
11
|
onClose: () => void;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const DictionaryModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
15
15
|
const translate = useTranslate();
|
|
16
16
|
|
|
17
17
|
return (
|
|
@@ -24,4 +24,4 @@ const DictionaryModal: FunctionComponent<Props> = ({ className, isOpen, onClose
|
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export
|
|
27
|
+
export const DictionaryModal = memo(DictionaryModalBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DictionaryModal } from './DictionaryModal';
|
|
@@ -11,7 +11,7 @@ interface Props {
|
|
|
11
11
|
onClose: () => void;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const KeyMapModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
15
15
|
const translate = useTranslate();
|
|
16
16
|
const config = useTypedSelector(selectConfig);
|
|
17
17
|
|
|
@@ -60,4 +60,4 @@ const KeyMapModal: FunctionComponent<Props> = ({ className, isOpen, onClose }) =
|
|
|
60
60
|
);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
export
|
|
63
|
+
export const KeyMapModal = memo(KeyMapModalBase);
|
|
@@ -9,7 +9,7 @@ interface Props {
|
|
|
9
9
|
mapping: (ReactNode | ReactNode[])[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const Mapping: FunctionComponent<Props> = ({ className, description, mapping }) => (
|
|
12
|
+
export const Mapping: FunctionComponent<Props> = ({ className, description, mapping }) => (
|
|
13
13
|
<div className={classNames(styles.mapping, className)}>
|
|
14
14
|
<h3 className={styles.description}>{description}</h3>
|
|
15
15
|
|
|
@@ -34,5 +34,3 @@ const Mapping: FunctionComponent<Props> = ({ className, description, mapping })
|
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
);
|
|
37
|
-
|
|
38
|
-
export default Mapping;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Mapping } from './Mapping';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Mapping } from './Mapping';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { KeyMapModal } from './KeyMapModal';
|
|
@@ -18,7 +18,7 @@ interface Props {
|
|
|
18
18
|
onShowWords: () => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const MenuModalBase: FunctionComponent<Props> = ({
|
|
22
22
|
className,
|
|
23
23
|
isOpen,
|
|
24
24
|
onClose,
|
|
@@ -79,4 +79,4 @@ const MenuModal: FunctionComponent<Props> = ({
|
|
|
79
79
|
);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
export
|
|
82
|
+
export const MenuModal = memo(MenuModalBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { MenuModal } from './MenuModal';
|
|
@@ -15,7 +15,7 @@ interface Props {
|
|
|
15
15
|
onClose: () => void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const RemainingTilesModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
19
19
|
const translate = useTranslate();
|
|
20
20
|
const locale = useTypedSelector(selectLocale);
|
|
21
21
|
const groups = useTypedSelector(selectRemainingTilesGroups);
|
|
@@ -57,4 +57,4 @@ const RemainingTilesModal: FunctionComponent<Props> = ({ className, isOpen, onCl
|
|
|
57
57
|
);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
export
|
|
60
|
+
export const RemainingTilesModal = memo(RemainingTilesModalBase);
|
|
@@ -14,7 +14,7 @@ interface Props {
|
|
|
14
14
|
tile: RemainingTile;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const Character: FunctionComponent<Props> = ({ tile }) => {
|
|
17
|
+
export const Character: FunctionComponent<Props> = ({ tile }) => {
|
|
18
18
|
const locale = useTypedSelector(selectLocale);
|
|
19
19
|
const { direction } = LOCALE_FEATURES[locale];
|
|
20
20
|
const { character, count, usedCount } = tile;
|
|
@@ -57,5 +57,3 @@ const Character: FunctionComponent<Props> = ({ tile }) => {
|
|
|
57
57
|
</div>
|
|
58
58
|
);
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
export default Character;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Character } from './Character';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Character } from './Character';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { RemainingTilesModal } from './RemainingTilesModal';
|
|
@@ -15,7 +15,7 @@ interface Props {
|
|
|
15
15
|
onClose: () => void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const ResultsModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
19
19
|
const dispatch = useDispatch();
|
|
20
20
|
const translate = useTranslate();
|
|
21
21
|
const { showResultsInModal } = useAppLayout();
|
|
@@ -96,4 +96,4 @@ const ResultsModal: FunctionComponent<Props> = ({ className, isOpen, onClose })
|
|
|
96
96
|
);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
export
|
|
99
|
+
export const ResultsModal = memo(ResultsModalBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ResultsModal } from './ResultsModal';
|
|
@@ -18,7 +18,7 @@ interface Props {
|
|
|
18
18
|
onClose: () => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const SettingsModalBase: FunctionComponent<Props> = ({ className, isOpen, onClose }) => {
|
|
22
22
|
const translate = useTranslate();
|
|
23
23
|
const isTouchDevice = useIsTouchDevice();
|
|
24
24
|
|
|
@@ -49,4 +49,4 @@ const SettingsModal: FunctionComponent<Props> = ({ className, isOpen, onClose })
|
|
|
49
49
|
);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
export
|
|
52
|
+
export const SettingsModal = memo(SettingsModalBase);
|
|
@@ -13,7 +13,7 @@ interface Props {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const AutoGroupTilesSetting: FunctionComponent<Props> = ({ className, disabled }) => {
|
|
16
|
+
export const AutoGroupTilesSetting: FunctionComponent<Props> = ({ className, disabled }) => {
|
|
17
17
|
const dispatch = useDispatch();
|
|
18
18
|
const translate = useTranslate();
|
|
19
19
|
const value = useTypedSelector(selectAutoGroupTiles);
|
|
@@ -56,5 +56,3 @@ const AutoGroupTilesSetting: FunctionComponent<Props> = ({ className, disabled }
|
|
|
56
56
|
</div>
|
|
57
57
|
);
|
|
58
58
|
};
|
|
59
|
-
|
|
60
|
-
export default AutoGroupTilesSetting;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { AutoGroupTilesSetting } from './AutoGroupTilesSetting';
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { games, hasConfig } from '@scrabble-solver/configs';
|
|
2
1
|
import { isGame } from '@scrabble-solver/types';
|
|
3
|
-
import { ChangeEvent, FunctionComponent } from 'react';
|
|
2
|
+
import { ChangeEvent, FunctionComponent, useMemo } from 'react';
|
|
4
3
|
import { useDispatch } from 'react-redux';
|
|
5
4
|
|
|
6
5
|
import { Radio } from 'components';
|
|
7
6
|
import { selectGame, selectLocale, settingsSlice, useTypedSelector } from 'state';
|
|
8
7
|
|
|
9
8
|
import styles from './ConfigSetting.module.scss';
|
|
9
|
+
import { getOptions } from './lib';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
className?: string;
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const ConfigSetting: FunctionComponent<Props> = ({ className, disabled }) => {
|
|
16
|
+
export const ConfigSetting: FunctionComponent<Props> = ({ className, disabled }) => {
|
|
17
17
|
const dispatch = useDispatch();
|
|
18
18
|
const game = useTypedSelector(selectGame);
|
|
19
19
|
const locale = useTypedSelector(selectLocale);
|
|
20
|
-
const options =
|
|
21
|
-
disabled: !hasConfig(gameConfig.game, locale),
|
|
22
|
-
label: gameConfig.name,
|
|
23
|
-
value: gameConfig.game,
|
|
24
|
-
}));
|
|
20
|
+
const options = useMemo(() => getOptions(locale), [locale]);
|
|
25
21
|
|
|
26
22
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
27
23
|
if (isGame(event.target.value)) {
|
|
@@ -47,5 +43,3 @@ const ConfigSetting: FunctionComponent<Props> = ({ className, disabled }) => {
|
|
|
47
43
|
</div>
|
|
48
44
|
);
|
|
49
45
|
};
|
|
50
|
-
|
|
51
|
-
export default ConfigSetting;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ConfigSetting } from './ConfigSetting';
|