analytica-frontend-lib 1.0.56 → 1.0.58

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
@@ -3724,9 +3724,16 @@ var Menu = (0, import_react13.forwardRef)(
3724
3724
  (0, import_react13.useEffect)(() => {
3725
3725
  setValue(propValue ?? defaultValue);
3726
3726
  }, [defaultValue, propValue, setValue]);
3727
+ const onValueChangeRef = (0, import_react13.useRef)(onValueChange);
3728
+ const isInitializedRef = (0, import_react13.useRef)(false);
3729
+ onValueChangeRef.current = onValueChange;
3727
3730
  (0, import_react13.useEffect)(() => {
3728
- onValueChange?.(value);
3729
- }, [value, onValueChange]);
3731
+ if (isInitializedRef.current) {
3732
+ onValueChangeRef.current?.(value);
3733
+ } else {
3734
+ isInitializedRef.current = true;
3735
+ }
3736
+ }, [value]);
3730
3737
  const baseClasses = "w-full py-2 px-6 flex flex-row items-center justify-center";
3731
3738
  const variantClasses = VARIANT_CLASSES5[variant];
3732
3739
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -3817,9 +3824,10 @@ var MenuItem = (0, import_react13.forwardRef)(
3817
3824
  {
3818
3825
  "data-variant": "menu2",
3819
3826
  className: `
3820
- flex flex-row items-center p-4 gap-2 border-b-2 border-transparent text-text-950 text-sx font-bold cursor-pointer focus:rounded-sm
3827
+ w-full flex flex-row items-center p-4 gap-2 border-b-4 border-transparent text-text-950 text-sx font-bold cursor-pointer focus:rounded-sm
3821
3828
  focus:outline-none focus:border-indicator-info focus:border-2
3822
3829
  ${selectedValue === value ? "border-b-primary-950" : ""}
3830
+ ${className ?? ""}
3823
3831
  `,
3824
3832
  ...commonProps,
3825
3833
  children
@@ -3830,9 +3838,9 @@ var MenuItem = (0, import_react13.forwardRef)(
3830
3838
  {
3831
3839
  "data-variant": "breadcrumb",
3832
3840
  className: `
3833
- p-2 rounded-lg hover:text-primary-600 cursor-pointer font-bold text-xs
3841
+ w-full p-2 rounded-lg hover:text-primary-600 cursor-pointer font-bold text-xs
3834
3842
  focus:outline-none focus:border-indicator-info focus:border-2
3835
- ${selectedValue === value ? "text-primary-950" : "text-text-600"}
3843
+ ${selectedValue === value ? "text-text-950" : "text-text-600"}
3836
3844
  ${className ?? ""}
3837
3845
  `,
3838
3846
  ...commonProps,
@@ -3840,8 +3848,8 @@ var MenuItem = (0, import_react13.forwardRef)(
3840
3848
  "span",
3841
3849
  {
3842
3850
  className: `
3843
- border-b border-text-600 hover:border-primary-600 text-inherit
3844
- ${selectedValue === value ? "border-b-primary-950" : "border-b-primary-600"}
3851
+ border-b border-text-600 hover:border-primary-600 text-inherit text-xs
3852
+ ${selectedValue === value ? "border-b-0 font-bold" : "border-b-primary-600"}
3845
3853
  `,
3846
3854
  children
3847
3855
  }
@@ -4143,7 +4151,7 @@ var CardProgress = (0, import_react14.forwardRef)(
4143
4151
  {
4144
4152
  ref,
4145
4153
  className: `
4146
- w-full flex border border-border-50 bg-background rounded-xl
4154
+ w-full flex border border-border-50 bg-background rounded-xl cursor-pointer
4147
4155
  ${isHorizontal ? "flex-row h-20" : "flex-col"}
4148
4156
  ${className}
4149
4157
  `,
@@ -4193,7 +4201,7 @@ var CardTopic = (0, import_react14.forwardRef)(
4193
4201
  "div",
4194
4202
  {
4195
4203
  ref,
4196
- className: `w-full py-2 px-4 flex flex-col justify-center gap-2 bg-background border border-border-50 rounded-xl min-h-20 ${className}`,
4204
+ className: `cursor-pointer w-full py-2 px-4 flex flex-col justify-center gap-2 bg-background border border-border-50 rounded-xl min-h-20 ${className}`,
4197
4205
  ...props,
4198
4206
  children: [
4199
4207
  subHead && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-text-600 text-2xs flex flex-row gap-1", children: subHead.map((text, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_react14.Fragment, { children: [
@@ -4243,7 +4251,7 @@ var CardPerformance = (0, import_react14.forwardRef)(
4243
4251
  !hasProgress && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4244
4252
  import_phosphor_react13.CaretRight,
4245
4253
  {
4246
- className: "size-4.5 text-text-800",
4254
+ className: "size-4.5 text-text-800 cursor-pointer",
4247
4255
  "data-testid": "caret-icon",
4248
4256
  onClick: () => onClickButton?.(valueButton)
4249
4257
  }
@@ -4327,7 +4335,7 @@ var CardResults = (0, import_react14.forwardRef)(
4327
4335
  ]
4328
4336
  }
4329
4337
  ),
4330
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { className: "min-w-6 min-h-6 text-text-800" })
4338
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { className: "min-w-6 min-h-6 text-text-800 cursor-pointer" })
4331
4339
  ]
4332
4340
  }
4333
4341
  );
@@ -4353,7 +4361,7 @@ var CardStatus = (0, import_react14.forwardRef)(
4353
4361
  `,
4354
4362
  children: [
4355
4363
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-xs font-bold text-text-950", children: header }),
4356
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "flex flex-row gap-1 items-center", children: [
4364
+ status && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "flex flex-row gap-1 items-center", children: [
4357
4365
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4358
4366
  Badge_default,
4359
4367
  {
@@ -4369,7 +4377,7 @@ var CardStatus = (0, import_react14.forwardRef)(
4369
4377
  ]
4370
4378
  }
4371
4379
  ),
4372
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { className: "min-w-6 min-h-6 text-text-800" })
4380
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { className: "min-w-6 min-h-6 text-text-800 cursor-pointer" })
4373
4381
  ]
4374
4382
  }
4375
4383
  );
@@ -4386,7 +4394,7 @@ var CardSettings = (0, import_react14.forwardRef)(
4386
4394
  children: [
4387
4395
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "[&>svg]:size-6", children: icon }),
4388
4396
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "w-full text-md", children: header }),
4389
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { size: 24 })
4397
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { size: 24, className: "cursor-pointer" })
4390
4398
  ]
4391
4399
  }
4392
4400
  );
@@ -4413,7 +4421,7 @@ var CardSupport = (0, import_react14.forwardRef)(
4413
4421
  ]
4414
4422
  }
4415
4423
  ),
4416
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { className: "text-text-800", size: 24 })
4424
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.CaretRight, { className: "text-text-800 cursor-pointer", size: 24 })
4417
4425
  ]
4418
4426
  }
4419
4427
  );
@@ -4482,6 +4490,243 @@ var CardForum = (0, import_react14.forwardRef)(
4482
4490
  );
4483
4491
  }
4484
4492
  );
4493
+ var CardAudio = (0, import_react14.forwardRef)(
4494
+ ({
4495
+ src,
4496
+ title,
4497
+ onPlay,
4498
+ onPause,
4499
+ onEnded,
4500
+ onAudioTimeUpdate,
4501
+ loop = false,
4502
+ preload = "metadata",
4503
+ tracks,
4504
+ className,
4505
+ ...props
4506
+ }, ref) => {
4507
+ const [isPlaying, setIsPlaying] = (0, import_react14.useState)(false);
4508
+ const [currentTime, setCurrentTime] = (0, import_react14.useState)(0);
4509
+ const [duration, setDuration] = (0, import_react14.useState)(0);
4510
+ const [volume, setVolume] = (0, import_react14.useState)(1);
4511
+ const [showVolumeControl, setShowVolumeControl] = (0, import_react14.useState)(false);
4512
+ const audioRef = (0, import_react14.useRef)(null);
4513
+ const formatTime = (time) => {
4514
+ const minutes = Math.floor(time / 60);
4515
+ const seconds = Math.floor(time % 60);
4516
+ return `${minutes}:${seconds.toString().padStart(2, "0")}`;
4517
+ };
4518
+ const handlePlayPause = () => {
4519
+ if (isPlaying) {
4520
+ audioRef.current?.pause();
4521
+ setIsPlaying(false);
4522
+ onPause?.();
4523
+ } else {
4524
+ audioRef.current?.play();
4525
+ setIsPlaying(true);
4526
+ onPlay?.();
4527
+ }
4528
+ };
4529
+ const handleTimeUpdate = () => {
4530
+ const current = audioRef.current?.currentTime ?? 0;
4531
+ const total = audioRef.current?.duration ?? 0;
4532
+ setCurrentTime(current);
4533
+ setDuration(total);
4534
+ onAudioTimeUpdate?.(current, total);
4535
+ };
4536
+ const handleLoadedMetadata = () => {
4537
+ setDuration(audioRef.current?.duration ?? 0);
4538
+ };
4539
+ const handleEnded = () => {
4540
+ setIsPlaying(false);
4541
+ setCurrentTime(0);
4542
+ onEnded?.();
4543
+ };
4544
+ const handleProgressClick = (e) => {
4545
+ const rect = e.currentTarget.getBoundingClientRect();
4546
+ const clickX = e.clientX - rect.left;
4547
+ const width = rect.width;
4548
+ const percentage = clickX / width;
4549
+ const newTime = percentage * duration;
4550
+ if (audioRef.current) {
4551
+ audioRef.current.currentTime = newTime;
4552
+ }
4553
+ setCurrentTime(newTime);
4554
+ };
4555
+ const handleVolumeChange = (e) => {
4556
+ const newVolume = parseFloat(e.target.value);
4557
+ setVolume(newVolume);
4558
+ if (audioRef.current) {
4559
+ audioRef.current.volume = newVolume;
4560
+ }
4561
+ };
4562
+ const toggleVolumeControl = () => {
4563
+ setShowVolumeControl(!showVolumeControl);
4564
+ };
4565
+ const getVolumeIcon = () => {
4566
+ if (volume === 0) {
4567
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.SpeakerSimpleX, {});
4568
+ }
4569
+ if (volume < 0.5) {
4570
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.SpeakerLow, {});
4571
+ }
4572
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.SpeakerHigh, {});
4573
+ };
4574
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
4575
+ "div",
4576
+ {
4577
+ ref,
4578
+ className: `w-auto h-14 p-4 flex flex-row bg-background items-center gap-2 ${className}`,
4579
+ ...props,
4580
+ children: [
4581
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4582
+ "audio",
4583
+ {
4584
+ ref: audioRef,
4585
+ src,
4586
+ loop,
4587
+ preload,
4588
+ onTimeUpdate: handleTimeUpdate,
4589
+ onLoadedMetadata: handleLoadedMetadata,
4590
+ onEnded: handleEnded,
4591
+ "data-testid": "audio-element",
4592
+ "aria-label": title,
4593
+ children: tracks ? tracks.map((track) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4594
+ "track",
4595
+ {
4596
+ kind: track.kind,
4597
+ src: track.src,
4598
+ srcLang: track.srcLang,
4599
+ label: track.label,
4600
+ default: track.default
4601
+ },
4602
+ track.src
4603
+ )) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4604
+ "track",
4605
+ {
4606
+ kind: "captions",
4607
+ src: "data:text/vtt;base64,",
4608
+ srcLang: "pt",
4609
+ label: "Sem legendas dispon\xEDveis"
4610
+ }
4611
+ )
4612
+ }
4613
+ ),
4614
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4615
+ "button",
4616
+ {
4617
+ type: "button",
4618
+ onClick: handlePlayPause,
4619
+ disabled: !src,
4620
+ className: "cursor-pointer text-text-950 hover:text-primary-600 disabled:text-text-400 disabled:cursor-not-allowed",
4621
+ "aria-label": isPlaying ? "Pausar" : "Reproduzir",
4622
+ children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-6 h-6 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex gap-0.5", children: [
4623
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-1 h-4 bg-current rounded-sm" }),
4624
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-1 h-4 bg-current rounded-sm" })
4625
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_phosphor_react13.Play, { size: 24 })
4626
+ }
4627
+ ),
4628
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-text-800 text-sm font-medium min-w-[2.5rem]", children: formatTime(currentTime) }),
4629
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex-1 relative", "data-testid": "progress-bar", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4630
+ "button",
4631
+ {
4632
+ type: "button",
4633
+ className: "w-full h-2 bg-border-100 rounded-full cursor-pointer",
4634
+ onClick: handleProgressClick,
4635
+ onKeyDown: (e) => {
4636
+ if (e.key === "Enter" || e.key === " ") {
4637
+ e.preventDefault();
4638
+ handleProgressClick(
4639
+ e
4640
+ );
4641
+ }
4642
+ },
4643
+ "aria-label": "Barra de progresso do \xE1udio",
4644
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4645
+ "div",
4646
+ {
4647
+ className: "h-full bg-primary-600 rounded-full transition-all duration-100",
4648
+ style: {
4649
+ width: duration > 0 ? `${currentTime / duration * 100}%` : "0%"
4650
+ }
4651
+ }
4652
+ )
4653
+ }
4654
+ ) }),
4655
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-text-800 text-sm font-medium min-w-[2.5rem]", children: formatTime(duration) }),
4656
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "relative", children: [
4657
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4658
+ "button",
4659
+ {
4660
+ type: "button",
4661
+ onClick: toggleVolumeControl,
4662
+ className: "cursor-pointer text-text-950 hover:text-primary-600",
4663
+ "aria-label": "Controle de volume",
4664
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-6 h-6 flex items-center justify-center", children: getVolumeIcon() })
4665
+ }
4666
+ ),
4667
+ showVolumeControl && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4668
+ "button",
4669
+ {
4670
+ type: "button",
4671
+ className: "absolute bottom-full right-0 mb-2 p-2 bg-background border border-border-100 rounded-lg shadow-lg focus:outline-none focus:ring-2 focus:ring-primary-500",
4672
+ onKeyDown: (e) => {
4673
+ if (e.key === "Escape") {
4674
+ setShowVolumeControl(false);
4675
+ }
4676
+ },
4677
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4678
+ "input",
4679
+ {
4680
+ type: "range",
4681
+ min: "0",
4682
+ max: "1",
4683
+ step: "0.1",
4684
+ value: volume,
4685
+ onChange: handleVolumeChange,
4686
+ onKeyDown: (e) => {
4687
+ if (e.key === "ArrowUp" || e.key === "ArrowRight") {
4688
+ e.preventDefault();
4689
+ const newVolume = Math.min(
4690
+ 1,
4691
+ Math.round((volume + 0.1) * 10) / 10
4692
+ );
4693
+ setVolume(newVolume);
4694
+ if (audioRef.current) audioRef.current.volume = newVolume;
4695
+ } else if (e.key === "ArrowDown" || e.key === "ArrowLeft") {
4696
+ e.preventDefault();
4697
+ const newVolume = Math.max(
4698
+ 0,
4699
+ Math.round((volume - 0.1) * 10) / 10
4700
+ );
4701
+ setVolume(newVolume);
4702
+ if (audioRef.current) audioRef.current.volume = newVolume;
4703
+ }
4704
+ },
4705
+ className: "w-20 h-2 bg-border-100 rounded-lg appearance-none cursor-pointer",
4706
+ style: {
4707
+ background: `linear-gradient(to right, #3b82f6 0%, #3b82f6 ${volume * 100}%, #e5e7eb ${volume * 100}%, #e5e7eb 100%)`
4708
+ },
4709
+ "aria-label": "Volume",
4710
+ "aria-valuenow": Math.round(volume * 100),
4711
+ "aria-valuemin": 0,
4712
+ "aria-valuemax": 100
4713
+ }
4714
+ )
4715
+ }
4716
+ )
4717
+ ] }),
4718
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4719
+ import_phosphor_react13.DotsThreeVertical,
4720
+ {
4721
+ size: 24,
4722
+ className: "text-text-950 cursor-pointer hover:text-primary-600"
4723
+ }
4724
+ )
4725
+ ]
4726
+ }
4727
+ );
4728
+ }
4729
+ );
4485
4730
  // Annotate the CommonJS export names for ESM import in node:
4486
4731
  0 && (module.exports = {
4487
4732
  Alert,