analytica-frontend-lib 1.2.28 → 1.2.29

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.mjs CHANGED
@@ -1188,7 +1188,10 @@ import { useEffect as useEffect2, useMemo, useRef as useRef3, useState as useSta
1188
1188
  import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
1189
1189
  var CheckboxGroup = ({
1190
1190
  categories,
1191
- onCategoriesChange
1191
+ onCategoriesChange,
1192
+ compactSingleItem = true,
1193
+ showDivider = true,
1194
+ showSingleItem = false
1192
1195
  }) => {
1193
1196
  const [openAccordion, setOpenAccordion] = useState3("");
1194
1197
  const autoSelectionAppliedRef = useRef3(false);
@@ -1547,16 +1550,43 @@ var CheckboxGroup = ({
1547
1550
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
1548
1551
  })() })
1549
1552
  ] });
1553
+ const renderCompactSingleItem = (category) => {
1554
+ const formattedItems = getFormattedItems(category.key);
1555
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1556
+ if (allItems.length !== 1) {
1557
+ return null;
1558
+ }
1559
+ const singleItem = allItems[0];
1560
+ return /* @__PURE__ */ jsxs9(
1561
+ "div",
1562
+ {
1563
+ className: "flex items-center justify-between w-full px-3 py-2",
1564
+ children: [
1565
+ /* @__PURE__ */ jsx13(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
1566
+ /* @__PURE__ */ jsx13(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
1567
+ ]
1568
+ },
1569
+ category.key
1570
+ );
1571
+ };
1550
1572
  const renderCategoryAccordion = (category) => {
1551
1573
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
1552
1574
  const depCat = categories.find((c) => c.key === depKey);
1553
1575
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
1554
1576
  });
1555
1577
  const hasOnlyOneItem = category.itens?.length === 1;
1556
- if (hasOnlyOneItem) {
1578
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
1557
1579
  return null;
1558
1580
  }
1559
1581
  const formattedItems = getFormattedItems(category.key);
1582
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1583
+ const hasOnlyOneAvailableItem = allItems.length === 1;
1584
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
1585
+ return /* @__PURE__ */ jsxs9("div", { children: [
1586
+ renderCompactSingleItem(category),
1587
+ showDivider && /* @__PURE__ */ jsx13(Divider_default, {})
1588
+ ] }, category.key);
1589
+ }
1560
1590
  const hasNoItems = formattedItems.every(
1561
1591
  (group) => !group.itens || group.itens.length === 0
1562
1592
  );
@@ -1576,7 +1606,7 @@ var CheckboxGroup = ({
1576
1606
  ) })
1577
1607
  }
1578
1608
  ),
1579
- openAccordion !== category.key && /* @__PURE__ */ jsx13(Divider_default, {})
1609
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ jsx13(Divider_default, {})
1580
1610
  ] }, category.key);
1581
1611
  };
1582
1612
  useEffect2(() => {