poi-plugin-quest-info-2 0.9.14 → 0.10.0
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/CHANGELOG.md +12 -0
- package/build/kcQuestsData/DATA_VERSION +1 -1
- package/build/kcQuestsData/index.ts +1 -1
- package/build/kcQuestsData/quests-scn-new.json +7 -1
- package/build/kcQuestsData/quests-scn.json +238 -65
- package/build/kcanotifyGamedata/DATA_VERSION +1 -1
- package/build/kcanotifyGamedata/index.ts +1 -1
- package/build/kcanotifyGamedata/quests-en.json +3934 -1348
- package/build/kcanotifyGamedata/quests-jp.json +4244 -646
- package/build/kcanotifyGamedata/quests-ko.json +4446 -924
- package/build/kcanotifyGamedata/quests-scn.json +4295 -913
- package/build/kcanotifyGamedata/quests-tcn.json +4218 -869
- package/build/prePostQuest.json +152 -26
- package/build/questCategory.json +18 -8
- package/build/questCodeMap.json +21 -4
- package/package.json +3 -1
- package/src/Toolbar.tsx +3 -11
- package/src/__tests__/__snapshots__/questCategory.spec.ts.snap +10 -0
- package/src/__tests__/__snapshots__/questHelper.spec.ts.snap +15 -1
- package/src/__tests__/kcanotifyData.spec.ts +1 -1
- package/src/__tests__/kcwikiData.spec.ts +6 -6
- package/src/__tests__/questCategory.spec.ts +2 -2
- package/src/components/QuestCard/index.tsx +37 -6
- package/src/store/search.ts +13 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Card, Elevation, H5 } from '@blueprintjs/core'
|
|
2
2
|
import React, { forwardRef } from 'react'
|
|
3
|
+
import Highlighter from 'react-highlight-words'
|
|
3
4
|
import type { StyledComponentProps } from 'styled-components'
|
|
4
5
|
import { usePluginTranslation } from '../../poi/hooks'
|
|
5
6
|
import {
|
|
7
|
+
QUEST_STATUS,
|
|
6
8
|
getQuestPrePost,
|
|
7
9
|
guessQuestCategory,
|
|
8
|
-
QUEST_STATUS,
|
|
9
10
|
} from '../../questHelper'
|
|
10
11
|
import { useQuestStatus } from '../../store/quest'
|
|
12
|
+
import { useStableSearchWords } from '../../store/search'
|
|
11
13
|
import { QuestTag } from '../QuestTag'
|
|
12
14
|
import {
|
|
13
15
|
CardActionWrapper,
|
|
@@ -24,7 +26,7 @@ export type QuestCardProps = {
|
|
|
24
26
|
gameId: number
|
|
25
27
|
code: string
|
|
26
28
|
name: string
|
|
27
|
-
desc: string
|
|
29
|
+
desc: string
|
|
28
30
|
tip?: string
|
|
29
31
|
tip2?: string
|
|
30
32
|
status?: QUEST_STATUS
|
|
@@ -70,6 +72,7 @@ export const QuestCard = forwardRef<
|
|
|
70
72
|
const status = useQuestStatus(gameId)
|
|
71
73
|
const headIcon = questIconMap[guessQuestCategory(code).type]
|
|
72
74
|
const TailIcon = questStatusMap[status]
|
|
75
|
+
const searchWords = useStableSearchWords()
|
|
73
76
|
|
|
74
77
|
return (
|
|
75
78
|
<FlexCard
|
|
@@ -80,10 +83,38 @@ export const QuestCard = forwardRef<
|
|
|
80
83
|
>
|
|
81
84
|
<CardMedia src={headIcon}></CardMedia>
|
|
82
85
|
<CardBody>
|
|
83
|
-
<H5>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
<H5>
|
|
87
|
+
<Highlighter
|
|
88
|
+
searchWords={searchWords}
|
|
89
|
+
autoEscape={false}
|
|
90
|
+
textToHighlight={[code, name]
|
|
91
|
+
.filter((i) => i != undefined)
|
|
92
|
+
.join(' - ')}
|
|
93
|
+
/>
|
|
94
|
+
</H5>
|
|
95
|
+
<Highlighter
|
|
96
|
+
searchWords={searchWords}
|
|
97
|
+
autoEscape={false}
|
|
98
|
+
textToHighlight={desc}
|
|
99
|
+
/>
|
|
100
|
+
{tip2 && (
|
|
101
|
+
<b>
|
|
102
|
+
<Highlighter
|
|
103
|
+
searchWords={searchWords}
|
|
104
|
+
autoEscape={false}
|
|
105
|
+
textToHighlight={tip2}
|
|
106
|
+
/>
|
|
107
|
+
</b>
|
|
108
|
+
)}
|
|
109
|
+
{tip && (
|
|
110
|
+
<i>
|
|
111
|
+
<Highlighter
|
|
112
|
+
searchWords={searchWords}
|
|
113
|
+
autoEscape={false}
|
|
114
|
+
textToHighlight={tip}
|
|
115
|
+
/>
|
|
116
|
+
</i>
|
|
117
|
+
)}
|
|
87
118
|
|
|
88
119
|
<CardAction gameId={gameId}></CardAction>
|
|
89
120
|
</CardBody>
|
package/src/store/search.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react'
|
|
2
|
+
import { useThrottle } from 'react-use'
|
|
2
3
|
import { useStore } from './store'
|
|
3
4
|
|
|
4
5
|
export const useSearchInput = () => {
|
|
@@ -15,3 +16,15 @@ export const useSearchInput = () => {
|
|
|
15
16
|
setSearchInput,
|
|
16
17
|
}
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
export const useStableSearchWords = () => {
|
|
21
|
+
const { searchInput } = useSearchInput()
|
|
22
|
+
const throttledSearchInput = useThrottle(searchInput)
|
|
23
|
+
const searchKeywords = throttledSearchInput
|
|
24
|
+
.split(' ')
|
|
25
|
+
// Remove empty string
|
|
26
|
+
.filter((i) => !!i)
|
|
27
|
+
.map((i) => i.toUpperCase())
|
|
28
|
+
|
|
29
|
+
return searchKeywords
|
|
30
|
+
}
|