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.
@@ -633,7 +633,10 @@ import { useEffect, useMemo, useRef as useRef2, useState as useState3 } from "re
633
633
  import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
634
634
  var CheckboxGroup = ({
635
635
  categories,
636
- onCategoriesChange
636
+ onCategoriesChange,
637
+ compactSingleItem = true,
638
+ showDivider = true,
639
+ showSingleItem = false
637
640
  }) => {
638
641
  const [openAccordion, setOpenAccordion] = useState3("");
639
642
  const autoSelectionAppliedRef = useRef2(false);
@@ -992,16 +995,43 @@ var CheckboxGroup = ({
992
995
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
993
996
  })() })
994
997
  ] });
998
+ const renderCompactSingleItem = (category) => {
999
+ const formattedItems = getFormattedItems(category.key);
1000
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1001
+ if (allItems.length !== 1) {
1002
+ return null;
1003
+ }
1004
+ const singleItem = allItems[0];
1005
+ return /* @__PURE__ */ jsxs6(
1006
+ "div",
1007
+ {
1008
+ className: "flex items-center justify-between w-full px-3 py-2",
1009
+ children: [
1010
+ /* @__PURE__ */ jsx7(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
1011
+ /* @__PURE__ */ jsx7(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
1012
+ ]
1013
+ },
1014
+ category.key
1015
+ );
1016
+ };
995
1017
  const renderCategoryAccordion = (category) => {
996
1018
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
997
1019
  const depCat = categories.find((c) => c.key === depKey);
998
1020
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
999
1021
  });
1000
1022
  const hasOnlyOneItem = category.itens?.length === 1;
1001
- if (hasOnlyOneItem) {
1023
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
1002
1024
  return null;
1003
1025
  }
1004
1026
  const formattedItems = getFormattedItems(category.key);
1027
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1028
+ const hasOnlyOneAvailableItem = allItems.length === 1;
1029
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
1030
+ return /* @__PURE__ */ jsxs6("div", { children: [
1031
+ renderCompactSingleItem(category),
1032
+ showDivider && /* @__PURE__ */ jsx7(Divider_default, {})
1033
+ ] }, category.key);
1034
+ }
1005
1035
  const hasNoItems = formattedItems.every(
1006
1036
  (group) => !group.itens || group.itens.length === 0
1007
1037
  );
@@ -1021,7 +1051,7 @@ var CheckboxGroup = ({
1021
1051
  ) })
1022
1052
  }
1023
1053
  ),
1024
- openAccordion !== category.key && /* @__PURE__ */ jsx7(Divider_default, {})
1054
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ jsx7(Divider_default, {})
1025
1055
  ] }, category.key);
1026
1056
  };
1027
1057
  useEffect(() => {