Show max length in item tooltips
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Maintainer-controlled web client version.
|
||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||
window.CHGRID_WEB_VERSION = "2026.02.22 R144";
|
||||
window.CHGRID_WEB_VERSION = "2026.02.22 R145";
|
||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||
|
||||
@@ -68,6 +68,7 @@ export type ItemPropertyValueType = 'boolean' | 'text' | 'number' | 'list' | 'so
|
||||
export type ItemPropertyMetadata = {
|
||||
valueType?: ItemPropertyValueType;
|
||||
tooltip?: string;
|
||||
maxLength?: number;
|
||||
range?: {
|
||||
min: number;
|
||||
max: number;
|
||||
@@ -140,6 +141,12 @@ function normalizePropertyMetadataRecord(raw: Record<string, unknown> | undefine
|
||||
if (typeof valueObj.tooltip === 'string' && valueObj.tooltip.trim().length > 0) {
|
||||
metadata.tooltip = valueObj.tooltip.trim();
|
||||
}
|
||||
if (valueObj.maxLength !== undefined) {
|
||||
const maxLength = Number(valueObj.maxLength);
|
||||
if (Number.isFinite(maxLength) && maxLength > 0) {
|
||||
metadata.maxLength = Math.floor(maxLength);
|
||||
}
|
||||
}
|
||||
const range = valueObj.range;
|
||||
if (range && typeof range === 'object') {
|
||||
const rangeObj = range as Record<string, unknown>;
|
||||
|
||||
@@ -819,6 +819,10 @@ function describeItemPropertyHelp(item: WorldItem, key: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata?.maxLength !== undefined) {
|
||||
parts.push(`Max length: ${metadata.maxLength} characters.`);
|
||||
}
|
||||
|
||||
parts.push(EDITABLE_ITEM_PROPERTY_KEYS.has(key) ? 'Editable.' : 'Read only.');
|
||||
return parts.join(' ');
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ export const welcomeMessageSchema = z.object({
|
||||
z.object({
|
||||
valueType: z.enum(['boolean', 'text', 'number', 'list', 'sound']).optional(),
|
||||
tooltip: z.string().optional(),
|
||||
maxLength: z.number().int().positive().optional(),
|
||||
range: z
|
||||
.object({
|
||||
min: z.number(),
|
||||
|
||||
Reference in New Issue
Block a user