analytica-frontend-lib 1.2.28 → 1.2.30

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.
@@ -548,7 +548,10 @@ var import_react3 = require("react");
548
548
  var import_jsx_runtime6 = require("react/jsx-runtime");
549
549
  var CheckboxGroup = ({
550
550
  categories,
551
- onCategoriesChange
551
+ onCategoriesChange,
552
+ compactSingleItem = true,
553
+ showDivider = true,
554
+ showSingleItem = false
552
555
  }) => {
553
556
  const [openAccordion, setOpenAccordion] = (0, import_react3.useState)("");
554
557
  const autoSelectionAppliedRef = (0, import_react3.useRef)(false);
@@ -907,16 +910,43 @@ var CheckboxGroup = ({
907
910
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
908
911
  })() })
909
912
  ] });
913
+ const renderCompactSingleItem = (category) => {
914
+ const formattedItems = getFormattedItems(category.key);
915
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
916
+ if (allItems.length !== 1) {
917
+ return null;
918
+ }
919
+ const singleItem = allItems[0];
920
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
921
+ "div",
922
+ {
923
+ className: "flex items-center justify-between w-full px-3 py-2",
924
+ children: [
925
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
926
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
927
+ ]
928
+ },
929
+ category.key
930
+ );
931
+ };
910
932
  const renderCategoryAccordion = (category) => {
911
933
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
912
934
  const depCat = categories.find((c) => c.key === depKey);
913
935
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
914
936
  });
915
937
  const hasOnlyOneItem = category.itens?.length === 1;
916
- if (hasOnlyOneItem) {
938
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
917
939
  return null;
918
940
  }
919
941
  const formattedItems = getFormattedItems(category.key);
942
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
943
+ const hasOnlyOneAvailableItem = allItems.length === 1;
944
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
945
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
946
+ renderCompactSingleItem(category),
947
+ showDivider && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Divider_default, {})
948
+ ] }, category.key);
949
+ }
920
950
  const hasNoItems = formattedItems.every(
921
951
  (group) => !group.itens || group.itens.length === 0
922
952
  );
@@ -936,7 +966,7 @@ var CheckboxGroup = ({
936
966
  ) })
937
967
  }
938
968
  ),
939
- openAccordion !== category.key && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Divider_default, {})
969
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Divider_default, {})
940
970
  ] }, category.key);
941
971
  };
942
972
  (0, import_react3.useEffect)(() => {