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.
@@ -6093,7 +6093,10 @@ var formatDateToBrazilian = (dateString) => {
6093
6093
  import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
6094
6094
  var CheckboxGroup = ({
6095
6095
  categories,
6096
- onCategoriesChange
6096
+ onCategoriesChange,
6097
+ compactSingleItem = true,
6098
+ showDivider = true,
6099
+ showSingleItem = false
6097
6100
  }) => {
6098
6101
  const [openAccordion, setOpenAccordion] = useState14("");
6099
6102
  const autoSelectionAppliedRef = useRef8(false);
@@ -6452,16 +6455,43 @@ var CheckboxGroup = ({
6452
6455
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
6453
6456
  })() })
6454
6457
  ] });
6458
+ const renderCompactSingleItem = (category) => {
6459
+ const formattedItems = getFormattedItems(category.key);
6460
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
6461
+ if (allItems.length !== 1) {
6462
+ return null;
6463
+ }
6464
+ const singleItem = allItems[0];
6465
+ return /* @__PURE__ */ jsxs23(
6466
+ "div",
6467
+ {
6468
+ className: "flex items-center justify-between w-full px-3 py-2",
6469
+ children: [
6470
+ /* @__PURE__ */ jsx32(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
6471
+ /* @__PURE__ */ jsx32(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
6472
+ ]
6473
+ },
6474
+ category.key
6475
+ );
6476
+ };
6455
6477
  const renderCategoryAccordion = (category) => {
6456
6478
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
6457
6479
  const depCat = categories.find((c) => c.key === depKey);
6458
6480
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
6459
6481
  });
6460
6482
  const hasOnlyOneItem = category.itens?.length === 1;
6461
- if (hasOnlyOneItem) {
6483
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
6462
6484
  return null;
6463
6485
  }
6464
6486
  const formattedItems = getFormattedItems(category.key);
6487
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
6488
+ const hasOnlyOneAvailableItem = allItems.length === 1;
6489
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
6490
+ return /* @__PURE__ */ jsxs23("div", { children: [
6491
+ renderCompactSingleItem(category),
6492
+ showDivider && /* @__PURE__ */ jsx32(Divider_default, {})
6493
+ ] }, category.key);
6494
+ }
6465
6495
  const hasNoItems = formattedItems.every(
6466
6496
  (group) => !group.itens || group.itens.length === 0
6467
6497
  );
@@ -6481,7 +6511,7 @@ var CheckboxGroup = ({
6481
6511
  ) })
6482
6512
  }
6483
6513
  ),
6484
- openAccordion !== category.key && /* @__PURE__ */ jsx32(Divider_default, {})
6514
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ jsx32(Divider_default, {})
6485
6515
  ] }, category.key);
6486
6516
  };
6487
6517
  useEffect14(() => {