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.
@@ -6044,7 +6044,10 @@ var formatDateToBrazilian = (dateString) => {
6044
6044
  var import_jsx_runtime32 = require("react/jsx-runtime");
6045
6045
  var CheckboxGroup = ({
6046
6046
  categories,
6047
- onCategoriesChange
6047
+ onCategoriesChange,
6048
+ compactSingleItem = true,
6049
+ showDivider = true,
6050
+ showSingleItem = false
6048
6051
  }) => {
6049
6052
  const [openAccordion, setOpenAccordion] = (0, import_react20.useState)("");
6050
6053
  const autoSelectionAppliedRef = (0, import_react20.useRef)(false);
@@ -6403,16 +6406,43 @@ var CheckboxGroup = ({
6403
6406
  return `${selectedVisibleCount} de ${totalVisible} ${selectedVisibleCount === 1 ? "selecionado" : "selecionados"}`;
6404
6407
  })() })
6405
6408
  ] });
6409
+ const renderCompactSingleItem = (category) => {
6410
+ const formattedItems = getFormattedItems(category.key);
6411
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
6412
+ if (allItems.length !== 1) {
6413
+ return null;
6414
+ }
6415
+ const singleItem = allItems[0];
6416
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
6417
+ "div",
6418
+ {
6419
+ className: "flex items-center justify-between w-full px-3 py-2",
6420
+ children: [
6421
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-text-800", children: category.label }),
6422
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text_default, { size: "sm", className: "text-text-950", children: singleItem.name })
6423
+ ]
6424
+ },
6425
+ category.key
6426
+ );
6427
+ };
6406
6428
  const renderCategoryAccordion = (category) => {
6407
6429
  const isEnabled = !category.dependsOn || category.dependsOn.every((depKey) => {
6408
6430
  const depCat = categories.find((c) => c.key === depKey);
6409
6431
  return depCat?.selectedIds && depCat.selectedIds.length > 0;
6410
6432
  });
6411
6433
  const hasOnlyOneItem = category.itens?.length === 1;
6412
- if (hasOnlyOneItem) {
6434
+ if (hasOnlyOneItem && !compactSingleItem && !showSingleItem) {
6413
6435
  return null;
6414
6436
  }
6415
6437
  const formattedItems = getFormattedItems(category.key);
6438
+ const allItems = formattedItems.flatMap((group) => group.itens || []);
6439
+ const hasOnlyOneAvailableItem = allItems.length === 1;
6440
+ if (compactSingleItem && hasOnlyOneAvailableItem && isEnabled) {
6441
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { children: [
6442
+ renderCompactSingleItem(category),
6443
+ showDivider && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Divider_default, {})
6444
+ ] }, category.key);
6445
+ }
6416
6446
  const hasNoItems = formattedItems.every(
6417
6447
  (group) => !group.itens || group.itens.length === 0
6418
6448
  );
@@ -6432,7 +6462,7 @@ var CheckboxGroup = ({
6432
6462
  ) })
6433
6463
  }
6434
6464
  ),
6435
- openAccordion !== category.key && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Divider_default, {})
6465
+ openAccordion !== category.key && showDivider && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Divider_default, {})
6436
6466
  ] }, category.key);
6437
6467
  };
6438
6468
  (0, import_react20.useEffect)(() => {