5401// @ts-expect-error ST-2949_55402storeProduct.setAttribute('data-product-pack-y', pack_y);5403// @ts-expect-error ST-2949_55404storeProduct.setAttribute('data-product-pack-z', pack_z);5405storeProduct.setAttribute('data-product-url', productUrl);5406}5407}54085409/**5410* Adding the product options to the product5411*5412* @param {string} recid
* @param {object} product - options of product * @param {HTMLElement} productElement - the product element * @param {CatalogOptions} options **/function t_catalog_addProductOptions(recid, product, productElement, options) { var el_product = productElement; // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592) // @ts-expect-error ST-2949_4 if (window.jQuery && el_product instanceof jQuery) { // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 if (el_product.length === 0) { return; } // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 el_product = el_product[0]; } var optionsWrapper = el_product.querySelector('.js-product-controls-wrapper'); if (!optionsWrapper) return; optionsWrapper.querySelectorAll('.js-product-editions-wrapper, .js-product-options-wrapper').forEach(widgetContainer => { if (widgetContainer instanceof HTMLElement) t_catalog_unmountComponent(widgetContainer); }); optionsWrapper.innerHTML = ''; /* product edition — is a combination of parameters with separate quantity and price example: "Blue XS T-Shirt" */ t_catalog_product__initEditionsWidget(recid, product, el_product, options); t_catalog_product__initOptionsWidget(product, el_product, options);}/** * Инициализирует options widget в обертке опций товара. * * @param {object} product * @param {HTMLElement} productEl * @param {CatalogOptions} options */function t_catalog_product__initOptionsWidget(product, productEl, options) { const productControlsWrapper = productEl.querySelector('.js-product-controls-wrapper'); if (!productControlsWrapper) return; // Без модификаторов не монтируем пустой shell — иначе :has(*) даёт padding-top на t-catalog__card__prod-controls-wrapper // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 if (!product.properties || !product.properties.length) { // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592) // @ts-expect-error ST-2949_4 t_prod__updatePrice(productEl, options); return; } const optionsWidgetWrapper = document.createElement('div'); optionsWidgetWrapper.classList.add('js-product-options-wrapper'); productControlsWrapper.appendChild(optionsWidgetWrapper); const optionsState = t_catalog_createOptionsState({ product, onChange: () => { // Пересчет цены с учетом опций. // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592) // @ts-expect-error ST-2949_4 t_prod__updatePrice(productEl, options); }, }); t_catalog_mountComponent(t_catalog_OptionsWidget, optionsWidgetWrapper, { state: optionsState }); // @ts-expect-error ST-2949_4 t_prod__updatePrice(productEl, options);}/** * Returns the color value for a given option value. * * @param {Object} valuesObj - An object containing option values and their corresponding colors. * @param {string} value - The option value to get the color for. * @return {string} - The color value for the given option value. */function t_catalog_option_getColorValue(valuesObj, value) { var result = '#ffffff'; for (var key in valuesObj) { // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 var item = valuesObj[key]; if (!item || item.value == null) continue;