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.
@@ -4727,7 +4727,10 @@ AccordionGroup.displayName = "AccordionGroup";
4727
4727
  var import_jsx_runtime24 = require("react/jsx-runtime");
4728
4728
  var CheckboxGroup = ({
4729
4729
  categories,
4730
- onCategoriesChange
4730
+ onCategoriesChange,
4731
+ compactSingleItem = true,
4732
+ showDivider = true,
4733
+ showSingleItem = false
4731
4734
  }) => {
4732
4735
  const [openAccordion, setOpenAccordion] = (0, import_react15.useState)("");
4733
4736
  const autoSelectionAppliedRef = (0, import_react15.useRef)(false);
@@ -5086,16 +5089,43 @@ var CheckboxGroup = ({
5086
5089
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
5087
5090
  })() })
5088
5091
  ] });
5092
+ const renderCompactSingleItem = (category) => {
5093
+ const formattedItems = getFormattedItems(category.key);
5094
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
5095
+ if (allItems.length !== 1) {
5096
+ return null;
5097
+ }
5098
+ const singleItem = allItems[0];
5099
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
5100
+ "div",
5101
+ {
5102
+ className: "flex items-center justify-between w-full px-3 py-2",
5103
+ children: [
5104
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
5105
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
5106
+ ]
5107
+ },
5108
+ category.key
5109
+ );
5110
+ };
5089
5111
  const renderCategoryAccordion = (category) => {
5090
5112
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
5091
5113
  const depCat = categories.find((c) => c.key === depKey);
5092
5114
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
5093
5115
  });
5094
5116
  const hasOnlyOneItem = category.itens?.length === 1;
5095
- if (hasOnlyOneItem) {
5117
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
5096
5118
  return null;
5097
5119
  }
5098
5120
  const formattedItems = getFormattedItems(category.key);
5121
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
5122
+ const hasOnlyOneAvailableItem = allItems.length === 1;
5123
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
5124
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { children: [
5125
+ renderCompactSingleItem(category),
5126
+ showDivider && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Divider_default, {})
5127
+ ] }, category.key);
5128
+ }
5099
5129
  const hasNoItems = formattedItems.every(
5100
5130
  (group) => !group.itens || group.itens.length === 0
5101
5131
  );
@@ -5115,7 +5145,7 @@ var CheckboxGroup = ({
5115
5145
  ) })
5116
5146
  }
5117
5147
  ),
5118
- openAccordion !== category.key && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Divider_default, {})
5148
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Divider_default, {})
5119
5149
  ] }, category.key);
5120
5150
  };
5121
5151
  (0, import_react15.useEffect)(() => {