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.js CHANGED
@@ -1405,7 +1405,10 @@ var import_react7 = require("react");
1405
1405
  var import_jsx_runtime13 = require("react/jsx-runtime");
1406
1406
  var CheckboxGroup = ({
1407
1407
  categories,
1408
- onCategoriesChange
1408
+ onCategoriesChange,
1409
+ compactSingleItem = true,
1410
+ showDivider = true,
1411
+ showSingleItem = false
1409
1412
  }) => {
1410
1413
  const [openAccordion, setOpenAccordion] = (0, import_react7.useState)("");
1411
1414
  const autoSelectionAppliedRef = (0, import_react7.useRef)(false);
@@ -1764,16 +1767,43 @@ var CheckboxGroup = ({
1764
1767
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
1765
1768
  })() })
1766
1769
  ] });
1770
+ const renderCompactSingleItem = (category) => {
1771
+ const formattedItems = getFormattedItems(category.key);
1772
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1773
+ if (allItems.length !== 1) {
1774
+ return null;
1775
+ }
1776
+ const singleItem = allItems[0];
1777
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1778
+ "div",
1779
+ {
1780
+ className: "flex items-center justify-between w-full px-3 py-2",
1781
+ children: [
1782
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
1783
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
1784
+ ]
1785
+ },
1786
+ category.key
1787
+ );
1788
+ };
1767
1789
  const renderCategoryAccordion = (category) => {
1768
1790
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
1769
1791
  const depCat = categories.find((c) => c.key === depKey);
1770
1792
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
1771
1793
  });
1772
1794
  const hasOnlyOneItem = category.itens?.length === 1;
1773
- if (hasOnlyOneItem) {
1795
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
1774
1796
  return null;
1775
1797
  }
1776
1798
  const formattedItems = getFormattedItems(category.key);
1799
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1800
+ const hasOnlyOneAvailableItem = allItems.length === 1;
1801
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
1802
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
1803
+ renderCompactSingleItem(category),
1804
+ showDivider && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Divider_default, {})
1805
+ ] }, category.key);
1806
+ }
1777
1807
  const hasNoItems = formattedItems.every(
1778
1808
  (group) => !group.itens || group.itens.length === 0
1779
1809
  );
@@ -1793,7 +1823,7 @@ var CheckboxGroup = ({
1793
1823
  ) })
1794
1824
  }
1795
1825
  ),
1796
- openAccordion !== category.key && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Divider_default, {})
1826
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Divider_default, {})
1797
1827
  ] }, category.key);
1798
1828
  };
1799
1829
  (0, import_react7.useEffect)(() => {