analytica-frontend-lib 1.0.75 → 1.0.76

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.
package/dist/index.js CHANGED
@@ -4218,7 +4218,7 @@ var import_phosphor_react11 = require("phosphor-react");
4218
4218
  var import_jsx_runtime24 = require("react/jsx-runtime");
4219
4219
  var CardAccordation = (0, import_react12.forwardRef)(
4220
4220
  ({
4221
- title,
4221
+ trigger,
4222
4222
  children,
4223
4223
  className,
4224
4224
  defaultExpanded = false,
@@ -4232,6 +4232,12 @@ var CardAccordation = (0, import_react12.forwardRef)(
4232
4232
  setIsExpanded(newExpanded);
4233
4233
  onToggleExpanded?.(newExpanded);
4234
4234
  };
4235
+ const handleKeyDown = (event) => {
4236
+ if (event.key === "Enter" || event.key === " ") {
4237
+ event.preventDefault();
4238
+ handleToggle();
4239
+ }
4240
+ };
4235
4241
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
4236
4242
  CardBase,
4237
4243
  {
@@ -4246,19 +4252,12 @@ var CardAccordation = (0, import_react12.forwardRef)(
4246
4252
  "button",
4247
4253
  {
4248
4254
  onClick: handleToggle,
4249
- className: "w-full cursor-pointer p-4 flex items-center justify-between gap-3 text-left transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-inset",
4255
+ onKeyDown: handleKeyDown,
4256
+ className: "w-full cursor-pointer text-text-950 not-aria-expanded:rounded-xl aria-expanded:rounded-t-xl p-4 flex items-center justify-between gap-3 text-left transition-colors duration-200 focus:outline-none focus:border-2 focus:border-primary-950 focus:ring-inset",
4250
4257
  "aria-expanded": isExpanded,
4251
4258
  "aria-controls": "accordion-content",
4252
4259
  children: [
4253
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4254
- Text_default,
4255
- {
4256
- size: "sm",
4257
- weight: "bold",
4258
- className: "text-text-950 truncate flex-1",
4259
- children: title
4260
- }
4261
- ),
4260
+ trigger,
4262
4261
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4263
4262
  import_phosphor_react11.CaretRight,
4264
4263
  {
@@ -4303,6 +4302,7 @@ var AlternativesList = ({
4303
4302
  }) => {
4304
4303
  const uniqueId = (0, import_react13.useId)();
4305
4304
  const groupName = name || `alternatives-${uniqueId}`;
4305
+ const [actualValue, setActualValue] = (0, import_react13.useState)(value);
4306
4306
  const isReadonly = mode === "readonly";
4307
4307
  const getStatusStyles = (status, isReadonly2) => {
4308
4308
  const hoverClass = isReadonly2 ? "" : "hover:bg-background-50";
@@ -4361,7 +4361,13 @@ var AlternativesList = ({
4361
4361
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-start gap-3 flex-1", children: [
4362
4362
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "mt-1", children: renderRadio() }),
4363
4363
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex-1", children: [
4364
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "block font-medium text-text-950", children: alternative.label }),
4364
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4365
+ "p",
4366
+ {
4367
+ className: `block font-medium ${selectedValue === alternative.value || statusBadge ? "text-primary-950" : "text-text-600"}`,
4368
+ children: alternative.label
4369
+ }
4370
+ ),
4365
4371
  alternative.description && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm text-text-600 mt-1", children: alternative.description })
4366
4372
  ] })
4367
4373
  ] }),
@@ -4378,7 +4384,13 @@ var AlternativesList = ({
4378
4384
  children: [
4379
4385
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2 flex-1", children: [
4380
4386
  renderRadio(),
4381
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "flex-1", children: alternative.label })
4387
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4388
+ "span",
4389
+ {
4390
+ className: `flex-1 ${selectedValue === alternative.value || statusBadge ? "text-primary-950" : "text-text-600"}`,
4391
+ children: alternative.label
4392
+ }
4393
+ )
4382
4394
  ] }),
4383
4395
  statusBadge && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex-shrink-0", children: statusBadge })
4384
4396
  ]
@@ -4403,7 +4415,10 @@ var AlternativesList = ({
4403
4415
  name: groupName,
4404
4416
  defaultValue,
4405
4417
  value,
4406
- onValueChange,
4418
+ onValueChange: (value2) => {
4419
+ setActualValue(value2);
4420
+ onValueChange?.(value2);
4421
+ },
4407
4422
  disabled,
4408
4423
  className: `flex flex-col ${getLayoutClasses()} ${className}`,
4409
4424
  children: alternatives.map((alternative, index) => {
@@ -4431,7 +4446,9 @@ var AlternativesList = ({
4431
4446
  "label",
4432
4447
  {
4433
4448
  htmlFor: alternativeId,
4434
- className: `block font-medium text-text-950 ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4449
+ className: `block font-medium
4450
+ ${actualValue === alternative.value ? "text-primary-950" : "text-text-600"}
4451
+ ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4435
4452
  children: alternative.label
4436
4453
  }
4437
4454
  ),
@@ -4462,7 +4479,9 @@ var AlternativesList = ({
4462
4479
  "label",
4463
4480
  {
4464
4481
  htmlFor: alternativeId,
4465
- className: `flex-1 ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4482
+ className: `flex-1
4483
+ ${actualValue === alternative.value ? "text-primary-950" : "text-text-600"}
4484
+ ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4466
4485
  children: alternative.label
4467
4486
  }
4468
4487
  )
@@ -4508,38 +4527,27 @@ var SIZE_CLASSES11 = {
4508
4527
  };
4509
4528
  var AlertDialog = (0, import_react14.forwardRef)(
4510
4529
  ({
4511
- trigger,
4512
4530
  description,
4513
4531
  cancelButtonLabel = "Cancelar",
4514
4532
  submitButtonLabel = "Deletar",
4515
4533
  title,
4516
- isOpen: controlledIsOpen,
4517
- onOpen,
4518
- onClose,
4534
+ isOpen,
4519
4535
  closeOnBackdropClick = true,
4520
4536
  closeOnEscape = true,
4521
4537
  className = "",
4522
4538
  onSubmit,
4539
+ onChangeOpen,
4523
4540
  submitValue,
4524
4541
  onCancel,
4525
4542
  cancelValue,
4526
4543
  size = "medium",
4527
4544
  ...props
4528
4545
  }, ref) => {
4529
- const [internalIsOpen, setInternalIsOpen] = (0, import_react14.useState)(false);
4530
- const isOpen = controlledIsOpen ?? internalIsOpen;
4531
- const setIsOpen = (open) => {
4532
- if (controlledIsOpen === void 0) {
4533
- setInternalIsOpen(open);
4534
- }
4535
- if (open && onOpen) onOpen();
4536
- if (!open && onClose) onClose();
4537
- };
4538
4546
  (0, import_react14.useEffect)(() => {
4539
4547
  if (!isOpen || !closeOnEscape) return;
4540
4548
  const handleEscape = (event) => {
4541
4549
  if (event.key === "Escape") {
4542
- setIsOpen(false);
4550
+ onChangeOpen(false);
4543
4551
  }
4544
4552
  };
4545
4553
  document.addEventListener("keydown", handleEscape);
@@ -4557,86 +4565,71 @@ var AlertDialog = (0, import_react14.forwardRef)(
4557
4565
  }, [isOpen]);
4558
4566
  const handleBackdropClick = (event) => {
4559
4567
  if (event.target === event.currentTarget && closeOnBackdropClick) {
4560
- setIsOpen(false);
4568
+ onChangeOpen(false);
4561
4569
  }
4562
4570
  };
4563
4571
  const handleBackdropKeyDown = (event) => {
4564
4572
  if (event.key === "Escape" && closeOnEscape) {
4565
- setIsOpen(false);
4573
+ onChangeOpen(false);
4566
4574
  }
4567
4575
  };
4568
- const handleTriggerClick = () => {
4569
- setIsOpen(true);
4570
- };
4571
4576
  const handleSubmit = () => {
4572
- setIsOpen(false);
4577
+ onChangeOpen(false);
4573
4578
  onSubmit?.(submitValue);
4574
4579
  };
4575
4580
  const handleCancel = () => {
4576
- setIsOpen(false);
4581
+ onChangeOpen(false);
4577
4582
  onCancel?.(cancelValue);
4578
4583
  };
4579
4584
  const sizeClasses = SIZE_CLASSES11[size];
4580
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
4581
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4582
- "button",
4583
- {
4584
- onClick: handleTriggerClick,
4585
- "aria-label": "Open dialog",
4586
- type: "button",
4587
- className: "border-none bg-transparent p-0 cursor-pointer",
4588
- children: trigger
4589
- }
4590
- ),
4591
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4592
- "div",
4593
- {
4594
- className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",
4595
- onClick: handleBackdropClick,
4596
- onKeyDown: handleBackdropKeyDown,
4597
- "data-testid": "alert-dialog-overlay",
4598
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
4599
- "div",
4600
- {
4601
- ref,
4602
- className: `bg-background border border-border-100 rounded-lg shadow-lg p-6 m-3 ${sizeClasses} ${className}`,
4603
- ...props,
4604
- children: [
4605
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4606
- "h2",
4607
- {
4608
- id: "alert-dialog-title",
4609
- className: "pb-3 text-xl font-semibold",
4610
- children: title
4611
- }
4612
- ),
4585
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: isOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4586
+ "div",
4587
+ {
4588
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",
4589
+ onClick: handleBackdropClick,
4590
+ onKeyDown: handleBackdropKeyDown,
4591
+ "data-testid": "alert-dialog-overlay",
4592
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
4593
+ "div",
4594
+ {
4595
+ ref,
4596
+ className: `bg-background border border-border-100 rounded-lg shadow-lg p-6 m-3 ${sizeClasses} ${className}`,
4597
+ ...props,
4598
+ children: [
4599
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4600
+ "h2",
4601
+ {
4602
+ id: "alert-dialog-title",
4603
+ className: "pb-3 text-xl font-semibold",
4604
+ children: title
4605
+ }
4606
+ ),
4607
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4608
+ "p",
4609
+ {
4610
+ id: "alert-dialog-description",
4611
+ className: "text-text-700 text-sm",
4612
+ children: description
4613
+ }
4614
+ ),
4615
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-row items-center justify-end pt-4 gap-3", children: [
4616
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button_default, { variant: "outline", size: "small", onClick: handleCancel, children: cancelButtonLabel }),
4613
4617
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4614
- "p",
4618
+ Button_default,
4615
4619
  {
4616
- id: "alert-dialog-description",
4617
- className: "text-text-700 text-sm",
4618
- children: description
4620
+ variant: "solid",
4621
+ size: "small",
4622
+ action: "negative",
4623
+ onClick: handleSubmit,
4624
+ children: submitButtonLabel
4619
4625
  }
4620
- ),
4621
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-row items-center justify-end pt-4 gap-3", children: [
4622
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button_default, { variant: "outline", size: "small", onClick: handleCancel, children: cancelButtonLabel }),
4623
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4624
- Button_default,
4625
- {
4626
- variant: "solid",
4627
- size: "small",
4628
- action: "negative",
4629
- onClick: handleSubmit,
4630
- children: submitButtonLabel
4631
- }
4632
- )
4633
- ] })
4634
- ]
4635
- }
4636
- )
4637
- }
4638
- )
4639
- ] });
4626
+ )
4627
+ ] })
4628
+ ]
4629
+ }
4630
+ )
4631
+ }
4632
+ ) });
4640
4633
  }
4641
4634
  );
4642
4635
  AlertDialog.displayName = "AlertDialog";