@linxin666/dsh-pet 0.4.10 → 0.4.12
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/README.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +4 -4
- package/lib/client.js +1137 -352
- package/lib/client.js.map +1 -1
- package/lib/index.js +32 -0
- package/lib/types/client/PetPreview.d.ts +12 -0
- package/lib/types/client/PetPreview.d.ts.map +1 -0
- package/lib/types/client/PetPreview.js +32 -0
- package/lib/types/client/PetSettingsCard.d.ts +46 -3
- package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PetSettingsCard.js +96 -11
- package/lib/types/client/PluginSettingsCard.d.ts +131 -17
- package/lib/types/client/PluginSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PluginSettingsCard.js +158 -37
- package/lib/types/client/RangeBubble.d.ts +47 -0
- package/lib/types/client/RangeBubble.d.ts.map +1 -0
- package/lib/types/client/RangeBubble.js +107 -0
- package/lib/types/client/SegmentGroup.d.ts +29 -0
- package/lib/types/client/SegmentGroup.d.ts.map +1 -0
- package/lib/types/client/SegmentGroup.js +81 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +9 -28
- package/lib/types/client/locales.d.ts +36 -44
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js +36 -44
- package/lib/types/client/settings-form.d.ts +79 -41
- package/lib/types/client/settings-form.d.ts.map +1 -1
- package/lib/types/client/settings-form.js +96 -36
- package/lib/types/client/settings-registration.d.ts +15 -0
- package/lib/types/client/settings-registration.d.ts.map +1 -0
- package/lib/types/client/settings-registration.js +24 -0
- package/lib/types/client/web-extension-contract.d.ts +32 -0
- package/lib/types/client/web-extension-contract.d.ts.map +1 -0
- package/lib/types/client/web-extension-contract.js +6 -0
- package/lib/types/client/web-extension-page.d.ts +51 -0
- package/lib/types/client/web-extension-page.d.ts.map +1 -0
- package/lib/types/client/web-extension-page.js +122 -0
- package/lib/types/registry.d.ts.map +1 -1
- package/lib/types/registry.js +35 -0
- package/package.json +1 -1
- package/src/client/PetPreview.tsx +51 -0
- package/src/client/PetSettingsCard.test.tsx +78 -22
- package/src/client/PetSettingsCard.tsx +252 -115
- package/src/client/PluginSettingsCard.tsx +369 -108
- package/src/client/RangeBubble.tsx +163 -0
- package/src/client/SegmentGroup.tsx +92 -0
- package/src/client/index.ts +9 -27
- package/src/client/locales.ts +36 -44
- package/src/client/settings-card.module.css +493 -91
- package/src/client/settings-form.ts +116 -49
- package/src/client/settings-registration.test.ts +79 -0
- package/src/client/settings-registration.ts +34 -0
- package/src/client/settings-section.module.css +182 -0
- package/src/client/web-extension-contract.ts +35 -0
- package/src/client/web-extension-page.ts +150 -0
- package/src/registry.test.ts +121 -1
- package/src/registry.ts +37 -0
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
* knowledge.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type
|
|
12
|
+
import { useEffect, type ReactNode } from 'react'
|
|
13
13
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
14
14
|
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
15
15
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
16
16
|
// Type-only: pulls the settings-surface SlotMap merge (the 'settings.section' entry).
|
|
17
17
|
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
18
|
-
import {
|
|
18
|
+
import type {} from './web-extension-contract.ts'
|
|
19
|
+
import { PluginSettingsCard, ValueField, BooleanField, ChoiceField, ToggleSwitch } from './PluginSettingsCard.tsx'
|
|
20
|
+
import { PetPreview, type PetPreviewDefinition } from './PetPreview.tsx'
|
|
19
21
|
import { CardForm, booleanField, choiceField, numberField, type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts'
|
|
20
22
|
import sectionCss from './settings-section.module.css'
|
|
21
23
|
|
|
@@ -65,6 +67,8 @@ export interface PetSettingsCardState extends CardShell {
|
|
|
65
67
|
statusBubbles: CardFieldState
|
|
66
68
|
/** Pet choices (registry ids + display names), loaded from the host. */
|
|
67
69
|
petChoices: readonly { value: string; label: string }[]
|
|
70
|
+
/** The same registry entries with the visual data their thumbnails need. */
|
|
71
|
+
petPreviews: readonly PetPreviewDefinition[]
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
/** The registration-side face the card's slot entry injects. */
|
|
@@ -73,6 +77,12 @@ export interface PetSettingsCardFace extends CardActions {
|
|
|
73
77
|
/** Card snapshot bound by the renderer as usePetSettingsCard. */
|
|
74
78
|
petSettingsCard: SnapshotStore<PetSettingsCardState>
|
|
75
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Ask the card for the pet registry again. The pet API only exists while the
|
|
82
|
+
* plugin is enabled, so opening the master switch has to be able to re-ask
|
|
83
|
+
* instead of leaving the picker empty until the page reloads.
|
|
84
|
+
*/
|
|
85
|
+
refreshPets(): void
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
/**
|
|
@@ -82,15 +92,24 @@ export interface PetSettingsCardFace extends CardActions {
|
|
|
82
92
|
*/
|
|
83
93
|
const STATUS_BUBBLE_CHOICES = ['auto', 'off'] as const
|
|
84
94
|
|
|
95
|
+
/**
|
|
96
|
+
* The spans the coarse sliders cover, spelled as literals for the same reason.
|
|
97
|
+
* Size and bubble scale are the schema's own bounds (src/persist.ts); the
|
|
98
|
+
* insets reach the schema's far end only by typing, so their slider covers the
|
|
99
|
+
* distances a window can show.
|
|
100
|
+
*/
|
|
101
|
+
export const SIZE_RANGE = { min: 32, max: 1024, step: 1 }
|
|
102
|
+
export const INSET_RANGE = { min: 0, max: 1000, step: 1 }
|
|
103
|
+
export const BUBBLE_SCALE_RANGE = { min: 0.5, max: 2, step: 0.05 }
|
|
104
|
+
|
|
85
105
|
/** One registry choice as served by '/api/pet/pets'. */
|
|
86
|
-
|
|
87
|
-
id: string
|
|
88
|
-
displayName: string
|
|
89
|
-
}
|
|
106
|
+
type PetChoice = PetPreviewDefinition
|
|
90
107
|
|
|
91
108
|
/** Fetch the registry list (the same data the sprite renders from). */
|
|
92
109
|
async function fetchPetChoices(): Promise<PetChoice[]> {
|
|
93
|
-
|
|
110
|
+
// Never from cache: the list is exactly what changes when the plugin is
|
|
111
|
+
// switched on (the API only exists then) or a pet is installed.
|
|
112
|
+
const response = await fetch('/api/pet/pets', { cache: 'no-store' })
|
|
94
113
|
if (!response.ok) throw new Error('pet pets failed: ' + response.status)
|
|
95
114
|
return (await response.json()) as PetChoice[]
|
|
96
115
|
}
|
|
@@ -122,13 +141,18 @@ export class PetSettingsCardController {
|
|
|
122
141
|
// without rebuilding the form.
|
|
123
142
|
private readonly petChoices: string[] = []
|
|
124
143
|
private readonly petLabels = new Map<string, string>()
|
|
144
|
+
private petPreviews: PetPreviewDefinition[] = []
|
|
125
145
|
private selectedPetId: string | undefined
|
|
126
146
|
private selectedVisible: boolean | undefined
|
|
127
147
|
private stagedPetId: string | undefined
|
|
128
148
|
private stagedVisible: boolean | undefined
|
|
129
149
|
private savingPet = false
|
|
150
|
+
/** A fallback pick made while a write was in flight. */
|
|
151
|
+
private fallbackQueued = false
|
|
130
152
|
private petSaveFailed = false
|
|
131
153
|
private loaded = false
|
|
154
|
+
/** A registry request is in flight. */
|
|
155
|
+
private loading = false
|
|
132
156
|
private attempts = 0
|
|
133
157
|
private disposed = false
|
|
134
158
|
/** Pending deferred-load or retry timer; cancelled by dispose(). */
|
|
@@ -166,11 +190,13 @@ export class PetSettingsCardController {
|
|
|
166
190
|
|
|
167
191
|
/** Resolve the registry choices once (retried a few times on failure). */
|
|
168
192
|
private async loadPets(): Promise<void> {
|
|
169
|
-
if (this.loaded || this.disposed) return
|
|
193
|
+
if (this.loaded || this.disposed || this.loading) return
|
|
194
|
+
this.loading = true
|
|
170
195
|
try {
|
|
171
196
|
const list = await fetchPetChoices()
|
|
172
197
|
if (this.disposed) return
|
|
173
198
|
this.petChoices.splice(0, this.petChoices.length, ...list.map(choice => choice.id))
|
|
199
|
+
this.petPreviews = list
|
|
174
200
|
for (const choice of list) this.petLabels.set(choice.id, choice.displayName)
|
|
175
201
|
this.loaded = true
|
|
176
202
|
this.store.set(this.projection())
|
|
@@ -184,9 +210,24 @@ export class PetSettingsCardController {
|
|
|
184
210
|
void this.loadPets()
|
|
185
211
|
}, 3000)
|
|
186
212
|
}
|
|
213
|
+
} finally {
|
|
214
|
+
this.loading = false
|
|
187
215
|
}
|
|
188
216
|
}
|
|
189
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Re-read the registry on demand. The pet API is registered only while the
|
|
220
|
+
* plugin is enabled, so the first read can fail while the master switch is
|
|
221
|
+
* off; this lets the card try again the moment the switch opens instead of
|
|
222
|
+
* waiting for a page reload.
|
|
223
|
+
*/
|
|
224
|
+
refreshPets(): void {
|
|
225
|
+
if (this.disposed || this.loading) return
|
|
226
|
+
this.loaded = false
|
|
227
|
+
this.attempts = 0
|
|
228
|
+
void this.loadPets()
|
|
229
|
+
}
|
|
230
|
+
|
|
190
231
|
private async loadPetState(): Promise<void> {
|
|
191
232
|
try {
|
|
192
233
|
const state = await fetchPetState()
|
|
@@ -219,12 +260,16 @@ export class PetSettingsCardController {
|
|
|
219
260
|
* Persist the staged selection and visibility through the pet API — the only
|
|
220
261
|
* writer available when the aggregate shell serves this card, since there is
|
|
221
262
|
* no Host settings form to mutate — then confirm the read-back before the
|
|
222
|
-
* drafts are cleared.
|
|
263
|
+
* drafts are cleared. A refused write puts both picks back to what the pet
|
|
264
|
+
* persisted. A pick made while a write is in flight runs once it settles.
|
|
223
265
|
*/
|
|
224
266
|
private async saveFallback(): Promise<void> {
|
|
225
267
|
const petId = this.stagedPetId
|
|
226
268
|
const visible = this.stagedVisible
|
|
227
|
-
if (this.savingPet)
|
|
269
|
+
if (this.savingPet) {
|
|
270
|
+
this.fallbackQueued = true
|
|
271
|
+
return
|
|
272
|
+
}
|
|
228
273
|
if (petId === undefined && visible === undefined) return
|
|
229
274
|
if (petId !== undefined && !this.petChoices.includes(petId)) return
|
|
230
275
|
this.savingPet = true
|
|
@@ -259,10 +304,16 @@ export class PetSettingsCardController {
|
|
|
259
304
|
if (this.stagedVisible === visible) this.stagedVisible = undefined
|
|
260
305
|
} catch {
|
|
261
306
|
this.petSaveFailed = true
|
|
307
|
+
if (this.stagedPetId === petId) this.stagedPetId = undefined
|
|
308
|
+
if (this.stagedVisible === visible) this.stagedVisible = undefined
|
|
262
309
|
} finally {
|
|
263
310
|
this.savingPet = false
|
|
264
311
|
if (!this.disposed) this.store.set(this.projection())
|
|
265
312
|
}
|
|
313
|
+
if (this.fallbackQueued && !this.disposed) {
|
|
314
|
+
this.fallbackQueued = false
|
|
315
|
+
await this.saveFallback()
|
|
316
|
+
}
|
|
266
317
|
}
|
|
267
318
|
|
|
268
319
|
private projection(): PetSettingsCardState {
|
|
@@ -296,6 +347,7 @@ export class PetSettingsCardController {
|
|
|
296
347
|
? { ...configuredPet, text: this.selectedPetId }
|
|
297
348
|
: configuredPet,
|
|
298
349
|
petChoices: this.petChoices.map(id => ({ value: id, label: this.petLabels.get(id) ?? id })),
|
|
350
|
+
petPreviews: this.petPreviews,
|
|
299
351
|
}
|
|
300
352
|
}
|
|
301
353
|
|
|
@@ -307,6 +359,8 @@ export class PetSettingsCardController {
|
|
|
307
359
|
const actions = this.form.actions()
|
|
308
360
|
return {
|
|
309
361
|
hooks: { petSettingsCard: this.store },
|
|
362
|
+
// The fallback's two fields are both picks, so each is written through
|
|
363
|
+
// the pet API the moment it is made, as the form writes its own picks.
|
|
310
364
|
edit: (field, value) => {
|
|
311
365
|
if (!this.fallback()) return actions.edit(field, value)
|
|
312
366
|
if (field === 'petId') this.stagedPetId = value === '' ? undefined : value
|
|
@@ -314,6 +368,7 @@ export class PetSettingsCardController {
|
|
|
314
368
|
else return
|
|
315
369
|
this.petSaveFailed = false
|
|
316
370
|
this.store.set(this.projection())
|
|
371
|
+
void this.saveFallback()
|
|
317
372
|
},
|
|
318
373
|
resetField: (field) => {
|
|
319
374
|
if (!this.fallback()) return actions.resetField(field)
|
|
@@ -331,6 +386,7 @@ export class PetSettingsCardController {
|
|
|
331
386
|
this.petSaveFailed = false
|
|
332
387
|
this.store.set(this.projection())
|
|
333
388
|
},
|
|
389
|
+
refreshPets: () => { this.refreshPets() },
|
|
334
390
|
}
|
|
335
391
|
}
|
|
336
392
|
|
|
@@ -363,140 +419,221 @@ export function PetSettingsCard(props: PetSettingsCardProps) {
|
|
|
363
419
|
const { t } = props
|
|
364
420
|
const state = props.usePetSettingsCard(snapshot => snapshot)
|
|
365
421
|
const disabled = !state.writable
|
|
422
|
+
// The registry is read once, when the plugin starts; the pet API that serves
|
|
423
|
+
// it exists only while the master switch is on. A card that opened empty
|
|
424
|
+
// therefore asks again as soon as the switch is on, instead of leaving the
|
|
425
|
+
// picker blank until the page reloads (the deferred reads had already spent
|
|
426
|
+
// their retries while the API was absent).
|
|
427
|
+
const enabled = state.enabled.text !== 'false'
|
|
428
|
+
const hasChoices = state.petPreviews.length > 0
|
|
429
|
+
const { refreshPets } = props
|
|
430
|
+
useEffect(() => {
|
|
431
|
+
if (enabled && !hasChoices) refreshPets()
|
|
432
|
+
}, [enabled, hasChoices, refreshPets])
|
|
366
433
|
const fieldProps = {
|
|
367
434
|
overriddenLabel: t('settings.overridden'),
|
|
368
435
|
resetLabel: t('settings.reset'),
|
|
369
436
|
invalidLabel: t('settings.invalidNumber'),
|
|
370
437
|
disabled,
|
|
438
|
+
presentation: 'segment' as const,
|
|
371
439
|
}
|
|
440
|
+
// The master switch sits in the header, as the Workshop and Usage pages
|
|
441
|
+
// carry theirs; the fallback has no Host form to write it through.
|
|
442
|
+
const enabledSwitch = state.petSelectionFallback
|
|
443
|
+
? undefined
|
|
444
|
+
: (
|
|
445
|
+
<ToggleSwitch
|
|
446
|
+
labelledBy="settings-pet-title"
|
|
447
|
+
checked={state.enabled.text !== 'false'}
|
|
448
|
+
disabled={disabled}
|
|
449
|
+
onChange={(next) => { props.edit('enabled', String(next)) }}
|
|
450
|
+
/>
|
|
451
|
+
)
|
|
372
452
|
return (
|
|
373
453
|
<PluginSettingsCard
|
|
374
454
|
t={t}
|
|
375
455
|
titleKey="settings.title"
|
|
456
|
+
titleId="settings-pet-title"
|
|
376
457
|
descriptionKey="settings.description"
|
|
377
458
|
descriptionNode={state.petSelectionFallback ? t('settings.petHint') : undefined}
|
|
459
|
+
headerAction={enabledSwitch}
|
|
378
460
|
state={state}
|
|
379
461
|
onSave={props.save}
|
|
380
462
|
onDiscard={props.discard}
|
|
381
463
|
alwaysOpen
|
|
382
464
|
>
|
|
383
|
-
{
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
465
|
+
<div className={sectionCss.settingsLayout}>
|
|
466
|
+
<section className={sectionCss.selectionGroup}>
|
|
467
|
+
<div className={sectionCss.groupHeader}>
|
|
468
|
+
<h3 className={sectionCss.groupTitle} id="settings-pet-selection-title">{t('settings.pet')}</h3>
|
|
469
|
+
{state.petId.overridden
|
|
470
|
+
? (
|
|
471
|
+
<button
|
|
472
|
+
type="button"
|
|
473
|
+
className={sectionCss.textAction}
|
|
474
|
+
disabled={disabled}
|
|
475
|
+
onClick={() => { props.resetField('petId') }}
|
|
476
|
+
>
|
|
477
|
+
{t('settings.reset')}
|
|
478
|
+
</button>
|
|
479
|
+
)
|
|
480
|
+
: null}
|
|
481
|
+
</div>
|
|
482
|
+
<div
|
|
483
|
+
id="settings-pet-pet"
|
|
484
|
+
className={sectionCss.petGrid}
|
|
485
|
+
role="group"
|
|
486
|
+
aria-labelledby="settings-pet-selection-title"
|
|
487
|
+
>
|
|
488
|
+
{state.petPreviews.map(pet => {
|
|
489
|
+
const selected = state.petId.text === pet.id
|
|
490
|
+
return (
|
|
491
|
+
<button
|
|
492
|
+
key={pet.id}
|
|
493
|
+
type="button"
|
|
494
|
+
className={selected ? `${sectionCss.petChoice} ${sectionCss.petChoiceSelected}` : sectionCss.petChoice}
|
|
495
|
+
aria-pressed={selected}
|
|
496
|
+
title={pet.displayName}
|
|
497
|
+
disabled={disabled}
|
|
498
|
+
onClick={() => { props.edit('petId', pet.id) }}
|
|
499
|
+
>
|
|
500
|
+
<PetPreview pet={pet} />
|
|
501
|
+
<span className={sectionCss.petChoiceLabel}>{pet.displayName}</span>
|
|
502
|
+
</button>
|
|
503
|
+
)
|
|
504
|
+
})}
|
|
505
|
+
</div>
|
|
506
|
+
<p className={state.petId.invalid ? sectionCss.invalid : sectionCss.groupHint}>
|
|
507
|
+
{state.petId.invalid ? t('settings.invalidNumber') : t('settings.petHint')}
|
|
508
|
+
</p>
|
|
509
|
+
</section>
|
|
510
|
+
|
|
511
|
+
<div className={sectionCss.settingsColumn}>
|
|
512
|
+
<section className={sectionCss.settingsGroup}>
|
|
513
|
+
<div className={sectionCss.groupHeader}>
|
|
514
|
+
<h3 className={sectionCss.groupTitle} id="settings-pet-display-title">{t('settings.displayGroup')}</h3>
|
|
515
|
+
</div>
|
|
516
|
+
<div className={sectionCss.fields}>
|
|
517
|
+
<BooleanField
|
|
518
|
+
id="settings-pet-visible"
|
|
519
|
+
label={t('settings.visible')}
|
|
520
|
+
hint={t('settings.visibleHint')}
|
|
521
|
+
inheritLabel={t('settings.inherit')}
|
|
522
|
+
onLabel={t('settings.on')}
|
|
523
|
+
offLabel={t('settings.off')}
|
|
524
|
+
{...fieldProps}
|
|
525
|
+
{...state.visible}
|
|
526
|
+
onEdit={(text) => { props.edit('visible', text) }}
|
|
527
|
+
onReset={() => { props.resetField('visible') }}
|
|
528
|
+
/>
|
|
529
|
+
{state.petSelectionFallback ? null : <ValueField
|
|
530
|
+
id="settings-pet-size"
|
|
531
|
+
label={t('settings.size')}
|
|
532
|
+
hint={t('settings.sizeHint')}
|
|
533
|
+
numeric
|
|
534
|
+
range={SIZE_RANGE}
|
|
535
|
+
{...fieldProps}
|
|
536
|
+
{...state.size}
|
|
537
|
+
onEdit={(text) => { props.edit('size', text) }}
|
|
538
|
+
onReset={() => { props.resetField('size') }}
|
|
539
|
+
/>}
|
|
540
|
+
{state.petSelectionFallback ? null : <ValueField
|
|
541
|
+
id="settings-pet-right"
|
|
542
|
+
label={t('settings.right')}
|
|
543
|
+
hint={t('settings.rightHint')}
|
|
544
|
+
numeric
|
|
545
|
+
range={INSET_RANGE}
|
|
546
|
+
{...fieldProps}
|
|
547
|
+
{...state.right}
|
|
548
|
+
onEdit={(text) => { props.edit('right', text) }}
|
|
549
|
+
onReset={() => { props.resetField('right') }}
|
|
550
|
+
/>}
|
|
551
|
+
{state.petSelectionFallback ? null : <ValueField
|
|
552
|
+
id="settings-pet-bottom"
|
|
553
|
+
label={t('settings.bottom')}
|
|
554
|
+
hint={t('settings.bottomHint')}
|
|
555
|
+
numeric
|
|
556
|
+
range={INSET_RANGE}
|
|
557
|
+
{...fieldProps}
|
|
558
|
+
{...state.bottom}
|
|
559
|
+
onEdit={(text) => { props.edit('bottom', text) }}
|
|
560
|
+
onReset={() => { props.resetField('bottom') }}
|
|
561
|
+
/>}
|
|
562
|
+
</div>
|
|
563
|
+
</section>
|
|
564
|
+
|
|
565
|
+
{state.petSelectionFallback ? null : (
|
|
566
|
+
<section className={sectionCss.settingsGroup}>
|
|
567
|
+
<div className={sectionCss.groupHeader}>
|
|
568
|
+
<h3 className={sectionCss.groupTitle} id="settings-pet-behavior-title">{t('settings.bubbleGroup')}</h3>
|
|
569
|
+
</div>
|
|
570
|
+
<div className={sectionCss.fields}>
|
|
571
|
+
<BooleanField
|
|
572
|
+
id="settings-pet-decoration"
|
|
573
|
+
label={t('settings.decoration')}
|
|
574
|
+
hint={t('settings.decorationHint')}
|
|
575
|
+
inheritLabel={t('settings.inherit')}
|
|
576
|
+
onLabel={t('settings.on')}
|
|
577
|
+
offLabel={t('settings.off')}
|
|
578
|
+
{...fieldProps}
|
|
579
|
+
{...state.decorationEnabled}
|
|
580
|
+
onEdit={(text) => { props.edit('decorationEnabled', text) }}
|
|
581
|
+
onReset={() => { props.resetField('decorationEnabled') }}
|
|
582
|
+
/>
|
|
583
|
+
<ChoiceField
|
|
584
|
+
id="settings-pet-status-bubbles"
|
|
585
|
+
label={t('settings.statusBubbles')}
|
|
586
|
+
hint={t('settings.statusBubblesHint')}
|
|
587
|
+
inheritLabel={t('settings.inherit')}
|
|
588
|
+
{...fieldProps}
|
|
589
|
+
{...state.statusBubbles}
|
|
590
|
+
choices={[
|
|
591
|
+
{ value: STATUS_BUBBLE_CHOICES[0], label: t('settings.on') },
|
|
592
|
+
{ value: STATUS_BUBBLE_CHOICES[1], label: t('settings.off') },
|
|
593
|
+
]}
|
|
594
|
+
onEdit={(text) => { props.edit('statusBubbles', text) }}
|
|
595
|
+
onReset={() => { props.resetField('statusBubbles') }}
|
|
596
|
+
/>
|
|
597
|
+
<ValueField
|
|
598
|
+
id="settings-pet-bubble-scale"
|
|
599
|
+
label={t('settings.bubbleScale')}
|
|
600
|
+
hint={t('settings.bubbleScaleHint')}
|
|
601
|
+
numeric
|
|
602
|
+
range={BUBBLE_SCALE_RANGE}
|
|
603
|
+
{...fieldProps}
|
|
604
|
+
{...state.bubbleScale}
|
|
605
|
+
onEdit={(text) => { props.edit('bubbleScale', text) }}
|
|
606
|
+
onReset={() => { props.resetField('bubbleScale') }}
|
|
607
|
+
/>
|
|
608
|
+
</div>
|
|
609
|
+
</section>
|
|
610
|
+
)}
|
|
611
|
+
</div>
|
|
612
|
+
</div>
|
|
484
613
|
</PluginSettingsCard>
|
|
485
614
|
)
|
|
486
615
|
}
|
|
487
616
|
|
|
488
617
|
/** Props the settings section binds for the pet card page. */
|
|
489
618
|
export type PetSettingsSectionProps =
|
|
490
|
-
PropsRuntime<'settings.section'>
|
|
619
|
+
(PropsRuntime<'settings.section'> | PropsRuntime<'web-ui.extension'>)
|
|
491
620
|
& PropsLocale<'pet'>
|
|
492
621
|
& InjectFace<PetSettingsCardFace>
|
|
493
622
|
|
|
494
623
|
/** Render the pet settings card as a first-level settings page. */
|
|
495
624
|
export function PetSettingsSection(props: PetSettingsSectionProps): ReactNode {
|
|
496
|
-
const { t, usePetSettingsCard, save, discard, edit, resetField } = props
|
|
625
|
+
const { t, usePetSettingsCard, save, discard, edit, resetField, refreshPets } = props
|
|
497
626
|
return (
|
|
498
|
-
<ul className={sectionCss.sectionList}>
|
|
499
|
-
<PetSettingsCard
|
|
627
|
+
<ul className={sectionCss.sectionList} data-dsh-plugin="pet" data-dsh-part="panel">
|
|
628
|
+
<PetSettingsCard
|
|
629
|
+
t={t}
|
|
630
|
+
usePetSettingsCard={usePetSettingsCard}
|
|
631
|
+
save={save}
|
|
632
|
+
discard={discard}
|
|
633
|
+
edit={edit}
|
|
634
|
+
resetField={resetField}
|
|
635
|
+
refreshPets={refreshPets}
|
|
636
|
+
/>
|
|
500
637
|
</ul>
|
|
501
638
|
)
|
|
502
639
|
}
|