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.
@@ -657,7 +657,10 @@ var import_react4 = require("react");
657
657
  var import_jsx_runtime7 = require("react/jsx-runtime");
658
658
  var CheckboxGroup = ({
659
659
  categories,
660
- onCategoriesChange
660
+ onCategoriesChange,
661
+ compactSingleItem = true,
662
+ showDivider = true,
663
+ showSingleItem = false
661
664
  }) => {
662
665
  const [openAccordion, setOpenAccordion] = (0, import_react4.useState)("");
663
666
  const autoSelectionAppliedRef = (0, import_react4.useRef)(false);
@@ -1016,16 +1019,43 @@ var CheckboxGroup = ({
1016
1019
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
1017
1020
  })() })
1018
1021
  ] });
1022
+ const renderCompactSingleItem = (category) => {
1023
+ const formattedItems = getFormattedItems(category.key);
1024
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1025
+ if (allItems.length !== 1) {
1026
+ return null;
1027
+ }
1028
+ const singleItem = allItems[0];
1029
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1030
+ "div",
1031
+ {
1032
+ className: "flex items-center justify-between w-full px-3 py-2",
1033
+ children: [
1034
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
1035
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
1036
+ ]
1037
+ },
1038
+ category.key
1039
+ );
1040
+ };
1019
1041
  const renderCategoryAccordion = (category) => {
1020
1042
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
1021
1043
  const depCat = categories.find((c) => c.key === depKey);
1022
1044
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
1023
1045
  });
1024
1046
  const hasOnlyOneItem = category.itens?.length === 1;
1025
- if (hasOnlyOneItem) {
1047
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
1026
1048
  return null;
1027
1049
  }
1028
1050
  const formattedItems = getFormattedItems(category.key);
1051
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
1052
+ const hasOnlyOneAvailableItem = allItems.length === 1;
1053
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
1054
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1055
+ renderCompactSingleItem(category),
1056
+ showDivider && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Divider_default, {})
1057
+ ] }, category.key);
1058
+ }
1029
1059
  const hasNoItems = formattedItems.every(
1030
1060
  (group) => !group.itens || group.itens.length === 0
1031
1061
  );
@@ -1045,7 +1075,7 @@ var CheckboxGroup = ({
1045
1075
  ) })
1046
1076
  }
1047
1077
  ),
1048
- openAccordion !== category.key && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Divider_default, {})
1078
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Divider_default, {})
1049
1079
  ] }, category.key);
1050
1080
  };
1051
1081
  (0, import_react4.useEffect)(() => {