poi-plugin-inventory-cleaner 1.9.2 → 1.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/i18n/en-US.json CHANGED
@@ -30,6 +30,7 @@
30
30
  "stock.keepMinus": "Keep one less",
31
31
  "stock.keepPlus": "Keep one more",
32
32
  "stock.batchToggle": "Batch keep",
33
+ "stock.categoryAll": "All categories",
33
34
  "stock.batchHint": "Set one keep count per category; leave empty and Apply to clear it",
34
35
  "stock.batchApply": "Apply",
35
36
  "stock.batchKinds": "{{count}} kinds",
package/i18n/zh-CN.json CHANGED
@@ -30,6 +30,7 @@
30
30
  "stock.keepMinus": "少留一件",
31
31
  "stock.keepPlus": "多留一件",
32
32
  "stock.batchToggle": "批量保留",
33
+ "stock.categoryAll": "全部类别",
33
34
  "stock.batchHint": "按类别统一设置;留空点「应用」= 清除该类自定义值",
34
35
  "stock.batchApply": "应用",
35
36
  "stock.batchKinds": "{{count}} 种",
package/index.js CHANGED
@@ -9,6 +9,7 @@ const {
9
9
  filterRows,
10
10
  stepKeep,
11
11
  summarize,
12
+ OTHER_CATEGORY,
12
13
  } = require('./lib/inventory')
13
14
  const { buildQuestNeeds } = require('./lib/quest-needs')
14
15
  const { CSS } = require('./lib/style')
@@ -260,6 +261,7 @@ function App() {
260
261
  const state = useExternalStore(subscribe, getSnapshot)
261
262
  const [view, setView] = React.useState('all')
262
263
  const [keyword, setKeyword] = React.useState('')
264
+ const [category, setCategory] = React.useState('')
263
265
  const [keeps, setKeeps] = React.useState(loadKeeps)
264
266
 
265
267
  const handleKeepChange = React.useCallback((id, rawValue) => {
@@ -306,8 +308,8 @@ function App() {
306
308
  setKeeps((prev) => applyCategoryKeep(prev, rows, category, batchValues[category]))
307
309
  }
308
310
  const visible = React.useMemo(
309
- () => filterRows(rows, { view, keyword }),
310
- [rows, view, keyword],
311
+ () => filterRows(rows, { view, keyword, category }),
312
+ [rows, view, keyword, category],
311
313
  )
312
314
 
313
315
  const data = React.useMemo(
@@ -363,6 +365,22 @@ function App() {
363
365
  placeholder: t('stock.search'),
364
366
  onChange: (event) => setKeyword(event.target.value),
365
367
  }),
368
+ h(
369
+ 'select',
370
+ {
371
+ className: 'stock-category',
372
+ value: category,
373
+ onChange: (event) => setCategory(event.target.value),
374
+ },
375
+ h('option', { value: '' }, t('stock.categoryAll')),
376
+ categories.map((entry) =>
377
+ h(
378
+ 'option',
379
+ { key: entry.key || 'other', value: entry.key || OTHER_CATEGORY },
380
+ (entry.key || t('stock.batchOther')) + ' (' + entry.kinds + ')',
381
+ ),
382
+ ),
383
+ ),
366
384
  h(
367
385
  'div',
368
386
  { className: 'stock-views' },
package/lib/inventory.js CHANGED
@@ -179,12 +179,20 @@ function summarize(rows) {
179
179
  }
180
180
  }
181
181
 
182
+ const OTHER_CATEGORY = '__other__'
183
+
182
184
  function filterRows(rows, options = {}) {
183
185
  const keyword = String(options.keyword || '')
184
186
  .trim()
185
187
  .toLowerCase()
186
188
  const view = options.view || 'all'
189
+ const category = String(options.category || '').trim()
187
190
  return rows.filter((row) => {
191
+ if (category === OTHER_CATEGORY) {
192
+ if (row.category) return false
193
+ } else if (category && (row.category || '') !== category) {
194
+ return false
195
+ }
188
196
  if (view === 'scrap' && row.verdict !== 'scrap' && !row.manual) return false
189
197
  if (view === 'protected' && !row.protected) return false
190
198
  if (view === 'keepSome' && row.verdict !== 'keepSome') return false
@@ -202,6 +210,7 @@ function filterRows(rows, options = {}) {
202
210
  }
203
211
 
204
212
  module.exports = {
213
+ OTHER_CATEGORY,
205
214
  applyCategoryKeep,
206
215
  stepKeep,
207
216
  buildInventory,
package/lib/style.js CHANGED
@@ -100,6 +100,24 @@ const CSS = `
100
100
  border-color: var(--stock-indigo);
101
101
  }
102
102
 
103
+ .stock-category {
104
+ height: 32px;
105
+ padding: 0 8px;
106
+ border: 1px solid var(--stock-border);
107
+ border-radius: 8px;
108
+ color: inherit;
109
+ background: var(--stock-surface);
110
+ font-family: inherit;
111
+ font-size: 12px;
112
+ cursor: pointer;
113
+ outline: none;
114
+ max-width: 220px;
115
+ }
116
+
117
+ .stock-category:focus {
118
+ border-color: var(--stock-indigo);
119
+ }
120
+
103
121
  .stock-views {
104
122
  display: flex;
105
123
  gap: 6px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poi-plugin-inventory-cleaner",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "库存清理大师:对照改修攻略与保留上限,找出囤积过量、可以清理的装备,并标出不能拆的改修材料。",
5
5
  "main": "index.js",
6
6
  "files": [