/** * Inventory Rendering Module * Handles UI rendering for inventory v2 system */ import { extensionSettings, $inventoryContainer } from '../../core/state.js'; import { saveSettings } from '../../core/persistence.js'; import { getInventoryRenderOptions, restoreFormStates } from '../interaction/inventoryActions.js'; import { updateInventoryItem } from '../interaction/inventoryEdit.js'; import { parseItems } from '../../utils/itemParser.js'; import { isItemLocked, setItemLock } from '../generation/lockManager.js'; // Type imports /** @typedef {import('../../types/inventory.js').InventoryV2} InventoryV2 */ /** * Helper to generate lock icon HTML if setting is enabled * @param {string} tracker - Tracker name * @param {string} path - Item path * @returns {string} Lock icon HTML or empty string */ function getLockIconHtml(tracker, path) { const showLockIcons = extensionSettings.showLockIcons ?? true; if (!showLockIcons) return ''; const isLocked = isItemLocked(tracker, path); const lockIcon = isLocked ? '🔒' : '🔓'; const lockTitle = isLocked ? 'Locked' : 'Unlocked'; const lockedClass = isLocked ? ' locked' : ''; return ``; } /** * Converts a location name to a safe ID for use in HTML element IDs. * Must match the logic used in inventoryActions.js. * @param {string} locationName - The location name * @returns {string} Safe ID string */ export function getLocationId(locationName) { // Remove all non-alphanumeric characters except spaces, then replace spaces with hyphens return locationName.replace(/[^a-zA-Z0-9\s]/g, '').replace(/\s+/g, '-'); } /** * Renders the inventory sub-tab navigation (On Person, Clothing, Stored, Assets) * @param {string} activeTab - Currently active sub-tab ('onPerson', 'clothing', 'stored', 'assets') * @returns {string} HTML for sub-tab navigation */ export function renderInventorySubTabs(activeTab = 'onPerson') { return `