@asantemedia-org/edwardsvacuum-design-system 1.6.34 → 1.6.35

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/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useCallback, useMemo, useEffect } from 'react';
1
+ import React, { useState, useRef, useCallback, useMemo, useEffect } from 'react';
2
2
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
3
  import { faChevronDown, faChevronRight, faArrowRight } from '@fortawesome/pro-solid-svg-icons';
4
4
  import { v4 } from 'uuid';
@@ -239,8 +239,6 @@ function requireClassnames() {
239
239
  var classnamesExports = requireClassnames();
240
240
  var classnames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
241
241
 
242
- // Debug mode - set to true to enable console logging
243
- var DEBUG_ACCORDION = typeof window !== 'undefined' && window.__DEBUG_ACCORDION__;
244
242
  var AccordionSection = function (_a) {
245
243
  var title = _a.title,
246
244
  children = _a.children,
@@ -253,25 +251,26 @@ var AccordionSection = function (_a) {
253
251
  var _e = useState(defaultOpen),
254
252
  isOpen = _e[0],
255
253
  setIsOpen = _e[1];
256
- // Track if accordion has ever been opened (for lazy loading)
257
254
  var _f = useState(defaultOpen),
258
255
  hasBeenOpened = _f[0],
259
256
  setHasBeenOpened = _f[1];
257
+ // Prevent rapid clicks / infinite loops
258
+ var isToggling = useRef(false);
260
259
  var toggleAccordion = useCallback(function () {
261
- if (DEBUG_ACCORDION) {
262
- console.time("[AccordionSection] Toggle \"".concat(title, "\""));
263
- console.log("[AccordionSection] Toggle clicked for \"".concat(title, "\", lazyLoad=").concat(lazyLoad, ", hasBeenOpened=").concat(hasBeenOpened));
264
- }
260
+ // Prevent multiple rapid toggles
261
+ if (isToggling.current) return;
262
+ isToggling.current = true;
265
263
  setIsOpen(function (prev) {
266
- if (!prev && !hasBeenOpened) {
267
- setHasBeenOpened(true);
268
- }
269
- if (DEBUG_ACCORDION) {
270
- console.timeEnd("[AccordionSection] Toggle \"".concat(title, "\""));
271
- }
272
264
  return !prev;
273
265
  });
274
- }, [hasBeenOpened, title, lazyLoad]);
266
+ if (!hasBeenOpened) {
267
+ setHasBeenOpened(true);
268
+ }
269
+ // Reset toggle lock after animation
270
+ setTimeout(function () {
271
+ isToggling.current = false;
272
+ }, 350);
273
+ }, [hasBeenOpened]);
275
274
  var handleKeyDown = useCallback(function (e) {
276
275
  if (e.key === 'Enter' || e.key === ' ') {
277
276
  e.preventDefault();
@@ -438,10 +437,9 @@ var ProductCard = function (_a) {
438
437
  icon: faArrowRight
439
438
  }))))));
440
439
  };
441
- // Debug mode - set to true to enable console logging
442
- var DEBUG_CARD = typeof window !== 'undefined' && window.__DEBUG_ACCORDION__;
440
+ // Maximum spares to render to prevent browser freeze
441
+ var MAX_SPARES_TO_RENDER = 20;
443
442
  var ProductDetailsCard = function (_a) {
444
- var _b;
445
443
  var className = _a.className,
446
444
  title = _a.title;
447
445
  _a.imageUrl;
@@ -450,39 +448,32 @@ var ProductDetailsCard = function (_a) {
450
448
  _a.onClick;
451
449
  var hit = _a.hit,
452
450
  facets = _a.facets;
453
- if (DEBUG_CARD) {
454
- console.log("[ProductDetailsCard] Rendering, spares count: ".concat(((_b = hit === null || hit === void 0 ? void 0 : hit.spares) === null || _b === void 0 ? void 0 : _b.length) || 0));
455
- }
456
- // Memoize spares rendering to prevent re-computation
451
+ // Memoize spares rendering with a limit to prevent freeze
457
452
  var renderSpares = function () {
458
- if (!(hit === null || hit === void 0 ? void 0 : hit.spares) || hit.spares.length === 0) return null;
459
- if (DEBUG_CARD) {
460
- console.time('[ProductDetailsCard] Rendering spares');
461
- }
462
- var result = /*#__PURE__*/React.createElement("ul", {
453
+ if (!(hit === null || hit === void 0 ? void 0 : hit.spares) || !Array.isArray(hit.spares) || hit.spares.length === 0) return null;
454
+ // Limit the number of spares to prevent freeze
455
+ var sparesToRender = hit.spares.slice(0, MAX_SPARES_TO_RENDER);
456
+ return /*#__PURE__*/React.createElement("ul", {
463
457
  className: "folding-spares-list"
464
- }, hit.spares.map(function (spare, index) {
465
- if (DEBUG_CARD && index === 0) {
466
- console.log("[ProductDetailsCard] First spare:", spare);
467
- }
458
+ }, sparesToRender.map(function (spare, index) {
459
+ // Safety check - skip if spare is not a valid object
460
+ if (!spare || typeof spare !== 'object') return null;
468
461
  return /*#__PURE__*/React.createElement("li", {
469
- key: spare.objectID || spare.code || index
462
+ key: spare.objectID || spare.code || "spare-".concat(index)
470
463
  }, /*#__PURE__*/React.createElement(ProductCard, {
471
464
  cardStyle: "type-card-product",
472
465
  className: "cmp-card",
473
- title: spare.name,
474
- imageUrl: spare['img-product'] || spare.image,
475
- imageAlt: spare.name,
476
- productPrice: spare.priceValue || spare.price,
466
+ title: spare.name || 'Spare Part',
467
+ imageUrl: spare['img-product'] || spare.image || '',
468
+ imageAlt: spare.name || 'Spare Part',
469
+ productPrice: spare.priceValue || spare.price || '',
477
470
  showProductPrice: false,
478
- cardLink: spare.url || spare.link,
471
+ cardLink: spare.url || spare.link || '#',
479
472
  cta: "Go to webshop"
480
473
  }));
481
- }));
482
- if (DEBUG_CARD) {
483
- console.timeEnd('[ProductDetailsCard] Rendering spares');
484
- }
485
- return result;
474
+ }), hit.spares.length > MAX_SPARES_TO_RENDER && /*#__PURE__*/React.createElement("li", {
475
+ className: "folding-spares-list__more"
476
+ }, "+", hit.spares.length - MAX_SPARES_TO_RENDER, " more items"));
486
477
  };
487
478
  return /*#__PURE__*/React.createElement("div", {
488
479
  className: className