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.
@@ -4748,7 +4748,10 @@ AccordionGroup.displayName = "AccordionGroup";
4748
4748
  import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
4749
4749
  var CheckboxGroup = ({
4750
4750
  categories,
4751
- onCategoriesChange
4751
+ onCategoriesChange,
4752
+ compactSingleItem = true,
4753
+ showDivider = true,
4754
+ showSingleItem = false
4752
4755
  }) => {
4753
4756
  const [openAccordion, setOpenAccordion] = useState10("");
4754
4757
  const autoSelectionAppliedRef = useRef5(false);
@@ -5107,16 +5110,43 @@ var CheckboxGroup = ({
5107
5110
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
5108
5111
  })() })
5109
5112
  ] });
5113
+ const renderCompactSingleItem = (category) => {
5114
+ const formattedItems = getFormattedItems(category.key);
5115
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
5116
+ if (allItems.length !== 1) {
5117
+ return null;
5118
+ }
5119
+ const singleItem = allItems[0];
5120
+ return /* @__PURE__ */ jsxs19(
5121
+ "div",
5122
+ {
5123
+ className: "flex items-center justify-between w-full px-3 py-2",
5124
+ children: [
5125
+ /* @__PURE__ */ jsx24(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
5126
+ /* @__PURE__ */ jsx24(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
5127
+ ]
5128
+ },
5129
+ category.key
5130
+ );
5131
+ };
5110
5132
  const renderCategoryAccordion = (category) => {
5111
5133
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
5112
5134
  const depCat = categories.find((c) => c.key === depKey);
5113
5135
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
5114
5136
  });
5115
5137
  const hasOnlyOneItem = category.itens?.length === 1;
5116
- if (hasOnlyOneItem) {
5138
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
5117
5139
  return null;
5118
5140
  }
5119
5141
  const formattedItems = getFormattedItems(category.key);
5142
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
5143
+ const hasOnlyOneAvailableItem = allItems.length === 1;
5144
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
5145
+ return /* @__PURE__ */ jsxs19("div", { children: [
5146
+ renderCompactSingleItem(category),
5147
+ showDivider && /* @__PURE__ */ jsx24(Divider_default, {})
5148
+ ] }, category.key);
5149
+ }
5120
5150
  const hasNoItems = formattedItems.every(
5121
5151
  (group) => !group.itens || group.itens.length === 0
5122
5152
  );
@@ -5136,7 +5166,7 @@ var CheckboxGroup = ({
5136
5166
  ) })
5137
5167
  }
5138
5168
  ),
5139
- openAccordion !== category.key && /* @__PURE__ */ jsx24(Divider_default, {})
5169
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ jsx24(Divider_default, {})
5140
5170
  ] }, category.key);
5141
5171
  };
5142
5172
  useEffect11(() => {