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.mjs CHANGED
@@ -3098,7 +3098,11 @@ var Modal = ({
3098
3098
  var Modal_default = Modal;
3099
3099
 
3100
3100
  // src/components/Accordation/Accordation.tsx
3101
- import { forwardRef as forwardRef10, useId as useId5, useState as useState7 } from "react";
3101
+ import {
3102
+ forwardRef as forwardRef10,
3103
+ useId as useId5,
3104
+ useState as useState7
3105
+ } from "react";
3102
3106
 
3103
3107
  // src/components/Card/Card.tsx
3104
3108
  import {
@@ -4163,7 +4167,7 @@ import { CaretRight as CaretRight2 } from "phosphor-react";
4163
4167
  import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
4164
4168
  var CardAccordation = forwardRef10(
4165
4169
  ({
4166
- title,
4170
+ trigger,
4167
4171
  children,
4168
4172
  className,
4169
4173
  defaultExpanded = false,
@@ -4177,6 +4181,12 @@ var CardAccordation = forwardRef10(
4177
4181
  setIsExpanded(newExpanded);
4178
4182
  onToggleExpanded?.(newExpanded);
4179
4183
  };
4184
+ const handleKeyDown = (event) => {
4185
+ if (event.key === "Enter" || event.key === " ") {
4186
+ event.preventDefault();
4187
+ handleToggle();
4188
+ }
4189
+ };
4180
4190
  return /* @__PURE__ */ jsxs19(
4181
4191
  CardBase,
4182
4192
  {
@@ -4191,19 +4201,12 @@ var CardAccordation = forwardRef10(
4191
4201
  "button",
4192
4202
  {
4193
4203
  onClick: handleToggle,
4194
- 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",
4204
+ onKeyDown: handleKeyDown,
4205
+ 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",
4195
4206
  "aria-expanded": isExpanded,
4196
4207
  "aria-controls": "accordion-content",
4197
4208
  children: [
4198
- /* @__PURE__ */ jsx24(
4199
- Text_default,
4200
- {
4201
- size: "sm",
4202
- weight: "bold",
4203
- className: "text-text-950 truncate flex-1",
4204
- children: title
4205
- }
4206
- ),
4209
+ trigger,
4207
4210
  /* @__PURE__ */ jsx24(
4208
4211
  CaretRight2,
4209
4212
  {
@@ -4232,7 +4235,7 @@ var CardAccordation = forwardRef10(
4232
4235
 
4233
4236
  // src/components/Alternative/Alternative.tsx
4234
4237
  import { CheckCircle as CheckCircle4, XCircle as XCircle3 } from "phosphor-react";
4235
- import { forwardRef as forwardRef11, useId as useId6 } from "react";
4238
+ import { forwardRef as forwardRef11, useId as useId6, useState as useState8 } from "react";
4236
4239
  import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
4237
4240
  var AlternativesList = ({
4238
4241
  alternatives,
@@ -4248,6 +4251,7 @@ var AlternativesList = ({
4248
4251
  }) => {
4249
4252
  const uniqueId = useId6();
4250
4253
  const groupName = name || `alternatives-${uniqueId}`;
4254
+ const [actualValue, setActualValue] = useState8(value);
4251
4255
  const isReadonly = mode === "readonly";
4252
4256
  const getStatusStyles = (status, isReadonly2) => {
4253
4257
  const hoverClass = isReadonly2 ? "" : "hover:bg-background-50";
@@ -4306,7 +4310,13 @@ var AlternativesList = ({
4306
4310
  /* @__PURE__ */ jsxs20("div", { className: "flex items-start gap-3 flex-1", children: [
4307
4311
  /* @__PURE__ */ jsx25("div", { className: "mt-1", children: renderRadio() }),
4308
4312
  /* @__PURE__ */ jsxs20("div", { className: "flex-1", children: [
4309
- /* @__PURE__ */ jsx25("p", { className: "block font-medium text-text-950", children: alternative.label }),
4313
+ /* @__PURE__ */ jsx25(
4314
+ "p",
4315
+ {
4316
+ className: `block font-medium ${selectedValue === alternative.value || statusBadge ? "text-primary-950" : "text-text-600"}`,
4317
+ children: alternative.label
4318
+ }
4319
+ ),
4310
4320
  alternative.description && /* @__PURE__ */ jsx25("p", { className: "text-sm text-text-600 mt-1", children: alternative.description })
4311
4321
  ] })
4312
4322
  ] }),
@@ -4323,7 +4333,13 @@ var AlternativesList = ({
4323
4333
  children: [
4324
4334
  /* @__PURE__ */ jsxs20("div", { className: "flex items-center gap-2 flex-1", children: [
4325
4335
  renderRadio(),
4326
- /* @__PURE__ */ jsx25("span", { className: "flex-1", children: alternative.label })
4336
+ /* @__PURE__ */ jsx25(
4337
+ "span",
4338
+ {
4339
+ className: `flex-1 ${selectedValue === alternative.value || statusBadge ? "text-primary-950" : "text-text-600"}`,
4340
+ children: alternative.label
4341
+ }
4342
+ )
4327
4343
  ] }),
4328
4344
  statusBadge && /* @__PURE__ */ jsx25("div", { className: "flex-shrink-0", children: statusBadge })
4329
4345
  ]
@@ -4348,7 +4364,10 @@ var AlternativesList = ({
4348
4364
  name: groupName,
4349
4365
  defaultValue,
4350
4366
  value,
4351
- onValueChange,
4367
+ onValueChange: (value2) => {
4368
+ setActualValue(value2);
4369
+ onValueChange?.(value2);
4370
+ },
4352
4371
  disabled,
4353
4372
  className: `flex flex-col ${getLayoutClasses()} ${className}`,
4354
4373
  children: alternatives.map((alternative, index) => {
@@ -4376,7 +4395,9 @@ var AlternativesList = ({
4376
4395
  "label",
4377
4396
  {
4378
4397
  htmlFor: alternativeId,
4379
- className: `block font-medium text-text-950 ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4398
+ className: `block font-medium
4399
+ ${actualValue === alternative.value ? "text-primary-950" : "text-text-600"}
4400
+ ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4380
4401
  children: alternative.label
4381
4402
  }
4382
4403
  ),
@@ -4407,7 +4428,9 @@ var AlternativesList = ({
4407
4428
  "label",
4408
4429
  {
4409
4430
  htmlFor: alternativeId,
4410
- className: `flex-1 ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4431
+ className: `flex-1
4432
+ ${actualValue === alternative.value ? "text-primary-950" : "text-text-600"}
4433
+ ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4411
4434
  children: alternative.label
4412
4435
  }
4413
4436
  )
@@ -4444,7 +4467,6 @@ var HeaderAlternative = forwardRef11(
4444
4467
  // src/components/AlertDialog/AlertDialog.tsx
4445
4468
  import {
4446
4469
  forwardRef as forwardRef12,
4447
- useState as useState8,
4448
4470
  useEffect as useEffect4
4449
4471
  } from "react";
4450
4472
  import { Fragment as Fragment5, jsx as jsx26, jsxs as jsxs21 } from "react/jsx-runtime";
@@ -4457,38 +4479,27 @@ var SIZE_CLASSES11 = {
4457
4479
  };
4458
4480
  var AlertDialog = forwardRef12(
4459
4481
  ({
4460
- trigger,
4461
4482
  description,
4462
4483
  cancelButtonLabel = "Cancelar",
4463
4484
  submitButtonLabel = "Deletar",
4464
4485
  title,
4465
- isOpen: controlledIsOpen,
4466
- onOpen,
4467
- onClose,
4486
+ isOpen,
4468
4487
  closeOnBackdropClick = true,
4469
4488
  closeOnEscape = true,
4470
4489
  className = "",
4471
4490
  onSubmit,
4491
+ onChangeOpen,
4472
4492
  submitValue,
4473
4493
  onCancel,
4474
4494
  cancelValue,
4475
4495
  size = "medium",
4476
4496
  ...props
4477
4497
  }, ref) => {
4478
- const [internalIsOpen, setInternalIsOpen] = useState8(false);
4479
- const isOpen = controlledIsOpen ?? internalIsOpen;
4480
- const setIsOpen = (open) => {
4481
- if (controlledIsOpen === void 0) {
4482
- setInternalIsOpen(open);
4483
- }
4484
- if (open && onOpen) onOpen();
4485
- if (!open && onClose) onClose();
4486
- };
4487
4498
  useEffect4(() => {
4488
4499
  if (!isOpen || !closeOnEscape) return;
4489
4500
  const handleEscape = (event) => {
4490
4501
  if (event.key === "Escape") {
4491
- setIsOpen(false);
4502
+ onChangeOpen(false);
4492
4503
  }
4493
4504
  };
4494
4505
  document.addEventListener("keydown", handleEscape);
@@ -4506,86 +4517,71 @@ var AlertDialog = forwardRef12(
4506
4517
  }, [isOpen]);
4507
4518
  const handleBackdropClick = (event) => {
4508
4519
  if (event.target === event.currentTarget && closeOnBackdropClick) {
4509
- setIsOpen(false);
4520
+ onChangeOpen(false);
4510
4521
  }
4511
4522
  };
4512
4523
  const handleBackdropKeyDown = (event) => {
4513
4524
  if (event.key === "Escape" && closeOnEscape) {
4514
- setIsOpen(false);
4525
+ onChangeOpen(false);
4515
4526
  }
4516
4527
  };
4517
- const handleTriggerClick = () => {
4518
- setIsOpen(true);
4519
- };
4520
4528
  const handleSubmit = () => {
4521
- setIsOpen(false);
4529
+ onChangeOpen(false);
4522
4530
  onSubmit?.(submitValue);
4523
4531
  };
4524
4532
  const handleCancel = () => {
4525
- setIsOpen(false);
4533
+ onChangeOpen(false);
4526
4534
  onCancel?.(cancelValue);
4527
4535
  };
4528
4536
  const sizeClasses = SIZE_CLASSES11[size];
4529
- return /* @__PURE__ */ jsxs21(Fragment5, { children: [
4530
- /* @__PURE__ */ jsx26(
4531
- "button",
4532
- {
4533
- onClick: handleTriggerClick,
4534
- "aria-label": "Open dialog",
4535
- type: "button",
4536
- className: "border-none bg-transparent p-0 cursor-pointer",
4537
- children: trigger
4538
- }
4539
- ),
4540
- isOpen && /* @__PURE__ */ jsx26(
4541
- "div",
4542
- {
4543
- className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",
4544
- onClick: handleBackdropClick,
4545
- onKeyDown: handleBackdropKeyDown,
4546
- "data-testid": "alert-dialog-overlay",
4547
- children: /* @__PURE__ */ jsxs21(
4548
- "div",
4549
- {
4550
- ref,
4551
- className: `bg-background border border-border-100 rounded-lg shadow-lg p-6 m-3 ${sizeClasses} ${className}`,
4552
- ...props,
4553
- children: [
4554
- /* @__PURE__ */ jsx26(
4555
- "h2",
4556
- {
4557
- id: "alert-dialog-title",
4558
- className: "pb-3 text-xl font-semibold",
4559
- children: title
4560
- }
4561
- ),
4537
+ return /* @__PURE__ */ jsx26(Fragment5, { children: isOpen && /* @__PURE__ */ jsx26(
4538
+ "div",
4539
+ {
4540
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",
4541
+ onClick: handleBackdropClick,
4542
+ onKeyDown: handleBackdropKeyDown,
4543
+ "data-testid": "alert-dialog-overlay",
4544
+ children: /* @__PURE__ */ jsxs21(
4545
+ "div",
4546
+ {
4547
+ ref,
4548
+ className: `bg-background border border-border-100 rounded-lg shadow-lg p-6 m-3 ${sizeClasses} ${className}`,
4549
+ ...props,
4550
+ children: [
4551
+ /* @__PURE__ */ jsx26(
4552
+ "h2",
4553
+ {
4554
+ id: "alert-dialog-title",
4555
+ className: "pb-3 text-xl font-semibold",
4556
+ children: title
4557
+ }
4558
+ ),
4559
+ /* @__PURE__ */ jsx26(
4560
+ "p",
4561
+ {
4562
+ id: "alert-dialog-description",
4563
+ className: "text-text-700 text-sm",
4564
+ children: description
4565
+ }
4566
+ ),
4567
+ /* @__PURE__ */ jsxs21("div", { className: "flex flex-row items-center justify-end pt-4 gap-3", children: [
4568
+ /* @__PURE__ */ jsx26(Button_default, { variant: "outline", size: "small", onClick: handleCancel, children: cancelButtonLabel }),
4562
4569
  /* @__PURE__ */ jsx26(
4563
- "p",
4570
+ Button_default,
4564
4571
  {
4565
- id: "alert-dialog-description",
4566
- className: "text-text-700 text-sm",
4567
- children: description
4572
+ variant: "solid",
4573
+ size: "small",
4574
+ action: "negative",
4575
+ onClick: handleSubmit,
4576
+ children: submitButtonLabel
4568
4577
  }
4569
- ),
4570
- /* @__PURE__ */ jsxs21("div", { className: "flex flex-row items-center justify-end pt-4 gap-3", children: [
4571
- /* @__PURE__ */ jsx26(Button_default, { variant: "outline", size: "small", onClick: handleCancel, children: cancelButtonLabel }),
4572
- /* @__PURE__ */ jsx26(
4573
- Button_default,
4574
- {
4575
- variant: "solid",
4576
- size: "small",
4577
- action: "negative",
4578
- onClick: handleSubmit,
4579
- children: submitButtonLabel
4580
- }
4581
- )
4582
- ] })
4583
- ]
4584
- }
4585
- )
4586
- }
4587
- )
4588
- ] });
4578
+ )
4579
+ ] })
4580
+ ]
4581
+ }
4582
+ )
4583
+ }
4584
+ ) });
4589
4585
  }
4590
4586
  );
4591
4587
  AlertDialog.displayName = "AlertDialog";