analytica-frontend-lib 1.0.57 → 1.0.59
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/Card/index.d.mts +28 -1
- package/dist/Card/index.d.ts +28 -1
- package/dist/Card/index.js +403 -56
- package/dist/Card/index.js.map +1 -1
- package/dist/Card/index.mjs +412 -57
- package/dist/Card/index.mjs.map +1 -1
- package/dist/Menu/index.js +13 -6
- package/dist/Menu/index.js.map +1 -1
- package/dist/Menu/index.mjs +13 -6
- package/dist/Menu/index.mjs.map +1 -1
- package/dist/Skeleton/index.d.mts +39 -0
- package/dist/Skeleton/index.d.ts +39 -0
- package/dist/Skeleton/index.js +191 -0
- package/dist/Skeleton/index.js.map +1 -0
- package/dist/Skeleton/index.mjs +159 -0
- package/dist/Skeleton/index.mjs.map +1 -0
- package/dist/index.css +92 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +577 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +580 -63
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +92 -2
- package/dist/styles.css.map +1 -1
- package/package.json +2 -1
package/dist/Card/index.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// src/components/Card/Card.tsx
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
Fragment as Fragment2,
|
|
5
|
+
useState,
|
|
6
|
+
useRef
|
|
7
|
+
} from "react";
|
|
3
8
|
|
|
4
9
|
// src/components/Button/Button.tsx
|
|
5
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -641,9 +646,66 @@ import {
|
|
|
641
646
|
CaretRight,
|
|
642
647
|
ChatCircleText,
|
|
643
648
|
CheckCircle,
|
|
649
|
+
DotsThreeVertical,
|
|
650
|
+
Play,
|
|
651
|
+
SpeakerHigh,
|
|
652
|
+
SpeakerLow,
|
|
653
|
+
SpeakerSimpleX,
|
|
644
654
|
XCircle
|
|
645
655
|
} from "phosphor-react";
|
|
646
656
|
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
657
|
+
var CARD_BASE_CLASSES = {
|
|
658
|
+
default: "w-full bg-background border border-border-50 rounded-xl",
|
|
659
|
+
compact: "w-full bg-background border border-border-50 rounded-lg",
|
|
660
|
+
minimal: "w-full bg-background border border-border-100 rounded-md"
|
|
661
|
+
};
|
|
662
|
+
var CARD_PADDING_CLASSES = {
|
|
663
|
+
none: "",
|
|
664
|
+
small: "p-2",
|
|
665
|
+
medium: "p-4",
|
|
666
|
+
large: "p-6"
|
|
667
|
+
};
|
|
668
|
+
var CARD_MIN_HEIGHT_CLASSES = {
|
|
669
|
+
none: "",
|
|
670
|
+
small: "min-h-16",
|
|
671
|
+
medium: "min-h-20",
|
|
672
|
+
large: "min-h-24"
|
|
673
|
+
};
|
|
674
|
+
var CARD_LAYOUT_CLASSES = {
|
|
675
|
+
horizontal: "flex flex-row",
|
|
676
|
+
vertical: "flex flex-col"
|
|
677
|
+
};
|
|
678
|
+
var CARD_CURSOR_CLASSES = {
|
|
679
|
+
default: "",
|
|
680
|
+
pointer: "cursor-pointer"
|
|
681
|
+
};
|
|
682
|
+
var CardBase = forwardRef(
|
|
683
|
+
({
|
|
684
|
+
children,
|
|
685
|
+
variant = "default",
|
|
686
|
+
layout = "horizontal",
|
|
687
|
+
padding = "medium",
|
|
688
|
+
minHeight = "medium",
|
|
689
|
+
cursor = "default",
|
|
690
|
+
className = "",
|
|
691
|
+
...props
|
|
692
|
+
}, ref) => {
|
|
693
|
+
const baseClasses = CARD_BASE_CLASSES[variant];
|
|
694
|
+
const paddingClasses = CARD_PADDING_CLASSES[padding];
|
|
695
|
+
const minHeightClasses = CARD_MIN_HEIGHT_CLASSES[minHeight];
|
|
696
|
+
const layoutClasses = CARD_LAYOUT_CLASSES[layout];
|
|
697
|
+
const cursorClasses = CARD_CURSOR_CLASSES[cursor];
|
|
698
|
+
const combinedClasses = [
|
|
699
|
+
baseClasses,
|
|
700
|
+
paddingClasses,
|
|
701
|
+
minHeightClasses,
|
|
702
|
+
layoutClasses,
|
|
703
|
+
cursorClasses,
|
|
704
|
+
className
|
|
705
|
+
].filter(Boolean).join(" ");
|
|
706
|
+
return /* @__PURE__ */ jsx5("div", { ref, className: combinedClasses, ...props, children });
|
|
707
|
+
}
|
|
708
|
+
);
|
|
647
709
|
var ACTION_CARD_CLASSES = {
|
|
648
710
|
warning: "bg-warning-background",
|
|
649
711
|
success: "bg-success-300",
|
|
@@ -706,7 +768,7 @@ var CardActivesResults = forwardRef(
|
|
|
706
768
|
children: icon
|
|
707
769
|
}
|
|
708
770
|
),
|
|
709
|
-
/* @__PURE__ */ jsx5("
|
|
771
|
+
/* @__PURE__ */ jsx5(Text_default, { size: "2xs", weight: "medium", className: "text-text-800 uppercase", children: title }),
|
|
710
772
|
/* @__PURE__ */ jsx5("p", { className: `text-lg font-bold ${actionSubTitleClasses}`, children: subTitle })
|
|
711
773
|
]
|
|
712
774
|
}
|
|
@@ -739,13 +801,13 @@ var CardQuestions = forwardRef(
|
|
|
739
801
|
const stateLabel = isDone ? "Realizado" : "N\xE3o Realizado";
|
|
740
802
|
const buttonLabel = isDone ? "Ver Quest\xE3o" : "Responder";
|
|
741
803
|
return /* @__PURE__ */ jsxs4(
|
|
742
|
-
|
|
804
|
+
CardBase,
|
|
743
805
|
{
|
|
744
806
|
ref,
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
`,
|
|
807
|
+
layout: "horizontal",
|
|
808
|
+
padding: "medium",
|
|
809
|
+
minHeight: "medium",
|
|
810
|
+
className: `justify-between gap-4 ${className}`,
|
|
749
811
|
...props,
|
|
750
812
|
children: [
|
|
751
813
|
/* @__PURE__ */ jsxs4("section", { className: "flex flex-col gap-1", children: [
|
|
@@ -805,35 +867,48 @@ var CardProgress = forwardRef(
|
|
|
805
867
|
/* @__PURE__ */ jsx5("p", { className: "text-text-600", children: endDate })
|
|
806
868
|
] })
|
|
807
869
|
] }),
|
|
808
|
-
/* @__PURE__ */
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
870
|
+
/* @__PURE__ */ jsxs4("span", { className: "grid grid-cols-[1fr_auto] items-center gap-2", children: [
|
|
871
|
+
/* @__PURE__ */ jsx5(
|
|
872
|
+
ProgressBar_default,
|
|
873
|
+
{
|
|
874
|
+
size: "small",
|
|
875
|
+
value: progress,
|
|
876
|
+
"data-testid": "progress-bar"
|
|
877
|
+
}
|
|
878
|
+
),
|
|
879
|
+
/* @__PURE__ */ jsxs4(
|
|
880
|
+
Text_default,
|
|
881
|
+
{
|
|
882
|
+
size: "xs",
|
|
883
|
+
weight: "medium",
|
|
884
|
+
className: `text-text-950 leading-none tracking-normal text-center flex-none`,
|
|
885
|
+
children: [
|
|
886
|
+
Math.round(progress),
|
|
887
|
+
"%"
|
|
888
|
+
]
|
|
889
|
+
}
|
|
890
|
+
)
|
|
891
|
+
] })
|
|
817
892
|
] }),
|
|
818
893
|
vertical: /* @__PURE__ */ jsx5("p", { className: "text-sm text-text-800", children: subhead })
|
|
819
894
|
};
|
|
820
895
|
return /* @__PURE__ */ jsxs4(
|
|
821
|
-
|
|
896
|
+
CardBase,
|
|
822
897
|
{
|
|
823
898
|
ref,
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
`,
|
|
899
|
+
layout: isHorizontal ? "horizontal" : "vertical",
|
|
900
|
+
padding: "none",
|
|
901
|
+
minHeight: "medium",
|
|
902
|
+
cursor: "pointer",
|
|
903
|
+
className: `${isHorizontal ? "h-20" : ""} ${className}`,
|
|
829
904
|
...props,
|
|
830
905
|
children: [
|
|
831
906
|
/* @__PURE__ */ jsx5(
|
|
832
907
|
"div",
|
|
833
908
|
{
|
|
834
909
|
className: `
|
|
835
|
-
flex justify-center items-center [&>svg]:size-
|
|
836
|
-
${isHorizontal ? "w-
|
|
910
|
+
flex justify-center items-center [&>svg]:size-6 text-text-950
|
|
911
|
+
${isHorizontal ? "min-w-[80px] min-h-[80px] rounded-l-xl" : "min-h-[50px] w-full rounded-t-xl"}
|
|
837
912
|
`,
|
|
838
913
|
style: {
|
|
839
914
|
backgroundColor: color
|
|
@@ -849,7 +924,7 @@ var CardProgress = forwardRef(
|
|
|
849
924
|
${!isHorizontal && "gap-4"}
|
|
850
925
|
`,
|
|
851
926
|
children: [
|
|
852
|
-
/* @__PURE__ */ jsx5(
|
|
927
|
+
/* @__PURE__ */ jsx5(Text_default, { size: "sm", weight: "bold", className: "text-text-950", children: header }),
|
|
853
928
|
contentComponent[direction]
|
|
854
929
|
]
|
|
855
930
|
}
|
|
@@ -869,18 +944,43 @@ var CardTopic = forwardRef(
|
|
|
869
944
|
...props
|
|
870
945
|
}, ref) => {
|
|
871
946
|
return /* @__PURE__ */ jsxs4(
|
|
872
|
-
|
|
947
|
+
CardBase,
|
|
873
948
|
{
|
|
874
949
|
ref,
|
|
875
|
-
|
|
950
|
+
layout: "vertical",
|
|
951
|
+
padding: "small",
|
|
952
|
+
minHeight: "medium",
|
|
953
|
+
cursor: "pointer",
|
|
954
|
+
className: `justify-center gap-2 py-2 px-4 ${className}`,
|
|
876
955
|
...props,
|
|
877
956
|
children: [
|
|
878
957
|
subHead && /* @__PURE__ */ jsx5("span", { className: "text-text-600 text-2xs flex flex-row gap-1", children: subHead.map((text, index) => /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
879
958
|
/* @__PURE__ */ jsx5("p", { children: text }),
|
|
880
959
|
index < subHead.length - 1 && /* @__PURE__ */ jsx5("p", { children: "\u2022" })
|
|
881
960
|
] }, `${text} - ${index}`)) }),
|
|
882
|
-
/* @__PURE__ */ jsx5("p", { className: "text-
|
|
883
|
-
/* @__PURE__ */
|
|
961
|
+
/* @__PURE__ */ jsx5("p", { className: "text-sm text-text-950 font-bold", children: header }),
|
|
962
|
+
/* @__PURE__ */ jsxs4("span", { className: "grid grid-cols-[1fr_auto] items-center gap-2", children: [
|
|
963
|
+
/* @__PURE__ */ jsx5(
|
|
964
|
+
ProgressBar_default,
|
|
965
|
+
{
|
|
966
|
+
size: "small",
|
|
967
|
+
value: progress,
|
|
968
|
+
"data-testid": "progress-bar"
|
|
969
|
+
}
|
|
970
|
+
),
|
|
971
|
+
showPercentage && /* @__PURE__ */ jsxs4(
|
|
972
|
+
Text_default,
|
|
973
|
+
{
|
|
974
|
+
size: "xs",
|
|
975
|
+
weight: "medium",
|
|
976
|
+
className: `text-text-950 leading-none tracking-normal text-center flex-none`,
|
|
977
|
+
children: [
|
|
978
|
+
Math.round(progress),
|
|
979
|
+
"%"
|
|
980
|
+
]
|
|
981
|
+
}
|
|
982
|
+
)
|
|
983
|
+
] })
|
|
884
984
|
]
|
|
885
985
|
}
|
|
886
986
|
);
|
|
@@ -898,15 +998,18 @@ var CardPerformance = forwardRef(
|
|
|
898
998
|
}, ref) => {
|
|
899
999
|
const hasProgress = progress !== void 0;
|
|
900
1000
|
return /* @__PURE__ */ jsxs4(
|
|
901
|
-
|
|
1001
|
+
CardBase,
|
|
902
1002
|
{
|
|
903
1003
|
ref,
|
|
904
|
-
|
|
1004
|
+
layout: "horizontal",
|
|
1005
|
+
padding: "medium",
|
|
1006
|
+
minHeight: "large",
|
|
1007
|
+
className: `justify-between gap-2 ${className}`,
|
|
905
1008
|
...props,
|
|
906
1009
|
children: [
|
|
907
1010
|
/* @__PURE__ */ jsxs4("div", { className: "w-full flex flex-col justify-between gap-2", children: [
|
|
908
1011
|
/* @__PURE__ */ jsxs4("div", { className: "flex flex-row justify-between items-center", children: [
|
|
909
|
-
/* @__PURE__ */ jsx5("p", { className: "text-
|
|
1012
|
+
/* @__PURE__ */ jsx5("p", { className: "text-lg font-bold text-text-950", children: header }),
|
|
910
1013
|
hasProgress && /* @__PURE__ */ jsx5(
|
|
911
1014
|
Button_default,
|
|
912
1015
|
{
|
|
@@ -922,7 +1025,7 @@ var CardPerformance = forwardRef(
|
|
|
922
1025
|
!hasProgress && /* @__PURE__ */ jsx5(
|
|
923
1026
|
CaretRight,
|
|
924
1027
|
{
|
|
925
|
-
className: "size-4.5 text-text-800",
|
|
1028
|
+
className: "size-4.5 text-text-800 cursor-pointer",
|
|
926
1029
|
"data-testid": "caret-icon",
|
|
927
1030
|
onClick: () => onClickButton?.(valueButton)
|
|
928
1031
|
}
|
|
@@ -945,13 +1048,13 @@ var CardResults = forwardRef(
|
|
|
945
1048
|
}, ref) => {
|
|
946
1049
|
const isRow = direction == "row";
|
|
947
1050
|
return /* @__PURE__ */ jsxs4(
|
|
948
|
-
|
|
1051
|
+
CardBase,
|
|
949
1052
|
{
|
|
950
1053
|
ref,
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
`,
|
|
1054
|
+
layout: "horizontal",
|
|
1055
|
+
padding: "none",
|
|
1056
|
+
minHeight: "medium",
|
|
1057
|
+
className: `items-center pr-4 ${className}`,
|
|
955
1058
|
...props,
|
|
956
1059
|
children: [
|
|
957
1060
|
/* @__PURE__ */ jsx5(
|
|
@@ -974,7 +1077,7 @@ var CardResults = forwardRef(
|
|
|
974
1077
|
${isRow ? "flex-row items-center" : "flex-col"}
|
|
975
1078
|
`,
|
|
976
1079
|
children: [
|
|
977
|
-
/* @__PURE__ */ jsx5("p", { className: "text-
|
|
1080
|
+
/* @__PURE__ */ jsx5("p", { className: "text-sm font-bold text-text-950", children: header }),
|
|
978
1081
|
/* @__PURE__ */ jsxs4("span", { className: "flex flex-row gap-1 items-center", children: [
|
|
979
1082
|
/* @__PURE__ */ jsxs4(
|
|
980
1083
|
Badge_default,
|
|
@@ -1006,7 +1109,7 @@ var CardResults = forwardRef(
|
|
|
1006
1109
|
]
|
|
1007
1110
|
}
|
|
1008
1111
|
),
|
|
1009
|
-
/* @__PURE__ */ jsx5(CaretRight, { className: "min-w-6 min-h-6 text-text-800" })
|
|
1112
|
+
/* @__PURE__ */ jsx5(CaretRight, { className: "min-w-6 min-h-6 text-text-800 cursor-pointer" })
|
|
1010
1113
|
]
|
|
1011
1114
|
}
|
|
1012
1115
|
);
|
|
@@ -1015,13 +1118,13 @@ var CardResults = forwardRef(
|
|
|
1015
1118
|
var CardStatus = forwardRef(
|
|
1016
1119
|
({ header, className, status, ...props }, ref) => {
|
|
1017
1120
|
return /* @__PURE__ */ jsxs4(
|
|
1018
|
-
|
|
1121
|
+
CardBase,
|
|
1019
1122
|
{
|
|
1020
1123
|
ref,
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
`,
|
|
1124
|
+
layout: "horizontal",
|
|
1125
|
+
padding: "none",
|
|
1126
|
+
minHeight: "medium",
|
|
1127
|
+
className: `items-center pr-4 ${className}`,
|
|
1025
1128
|
...props,
|
|
1026
1129
|
children: [
|
|
1027
1130
|
/* @__PURE__ */ jsxs4(
|
|
@@ -1031,7 +1134,7 @@ var CardStatus = forwardRef(
|
|
|
1031
1134
|
p-4 flex justify-between w-full h-full flex-row items-center
|
|
1032
1135
|
`,
|
|
1033
1136
|
children: [
|
|
1034
|
-
/* @__PURE__ */ jsx5("p", { className: "text-
|
|
1137
|
+
/* @__PURE__ */ jsx5("p", { className: "text-sm font-bold text-text-950", children: header }),
|
|
1035
1138
|
status && /* @__PURE__ */ jsxs4("span", { className: "flex flex-row gap-1 items-center", children: [
|
|
1036
1139
|
/* @__PURE__ */ jsx5(
|
|
1037
1140
|
Badge_default,
|
|
@@ -1048,7 +1151,7 @@ var CardStatus = forwardRef(
|
|
|
1048
1151
|
]
|
|
1049
1152
|
}
|
|
1050
1153
|
),
|
|
1051
|
-
/* @__PURE__ */ jsx5(CaretRight, { className: "min-w-6 min-h-6 text-text-800" })
|
|
1154
|
+
/* @__PURE__ */ jsx5(CaretRight, { className: "min-w-6 min-h-6 text-text-800 cursor-pointer" })
|
|
1052
1155
|
]
|
|
1053
1156
|
}
|
|
1054
1157
|
);
|
|
@@ -1057,15 +1160,18 @@ var CardStatus = forwardRef(
|
|
|
1057
1160
|
var CardSettings = forwardRef(
|
|
1058
1161
|
({ header, className, icon, ...props }, ref) => {
|
|
1059
1162
|
return /* @__PURE__ */ jsxs4(
|
|
1060
|
-
|
|
1163
|
+
CardBase,
|
|
1061
1164
|
{
|
|
1062
1165
|
ref,
|
|
1063
|
-
|
|
1166
|
+
layout: "horizontal",
|
|
1167
|
+
padding: "small",
|
|
1168
|
+
minHeight: "none",
|
|
1169
|
+
className: `border-none items-center gap-2 text-text-700 ${className}`,
|
|
1064
1170
|
...props,
|
|
1065
1171
|
children: [
|
|
1066
1172
|
/* @__PURE__ */ jsx5("span", { className: "[&>svg]:size-6", children: icon }),
|
|
1067
|
-
/* @__PURE__ */ jsx5("p", { className: "w-full text-
|
|
1068
|
-
/* @__PURE__ */ jsx5(CaretRight, { size: 24 })
|
|
1173
|
+
/* @__PURE__ */ jsx5("p", { className: "w-full text-sm", children: header }),
|
|
1174
|
+
/* @__PURE__ */ jsx5(CaretRight, { size: 24, className: "cursor-pointer" })
|
|
1069
1175
|
]
|
|
1070
1176
|
}
|
|
1071
1177
|
);
|
|
@@ -1074,10 +1180,13 @@ var CardSettings = forwardRef(
|
|
|
1074
1180
|
var CardSupport = forwardRef(
|
|
1075
1181
|
({ header, className, direction = "col", children, ...props }, ref) => {
|
|
1076
1182
|
return /* @__PURE__ */ jsxs4(
|
|
1077
|
-
|
|
1183
|
+
CardBase,
|
|
1078
1184
|
{
|
|
1079
1185
|
ref,
|
|
1080
|
-
|
|
1186
|
+
layout: "horizontal",
|
|
1187
|
+
padding: "medium",
|
|
1188
|
+
minHeight: "none",
|
|
1189
|
+
className: `border-none items-center gap-2 text-text-700 ${className}`,
|
|
1081
1190
|
...props,
|
|
1082
1191
|
children: [
|
|
1083
1192
|
/* @__PURE__ */ jsxs4(
|
|
@@ -1087,12 +1196,12 @@ var CardSupport = forwardRef(
|
|
|
1087
1196
|
w-full flex ${direction == "col" ? "flex-col" : "flex-row items-center"} gap-2
|
|
1088
1197
|
`,
|
|
1089
1198
|
children: [
|
|
1090
|
-
/* @__PURE__ */ jsx5("span", { className: "w-full", children: /* @__PURE__ */ jsx5("p", { className: "text-
|
|
1199
|
+
/* @__PURE__ */ jsx5("span", { className: "w-full", children: /* @__PURE__ */ jsx5("p", { className: "text-sm text-text-950 font-bold", children: header }) }),
|
|
1091
1200
|
/* @__PURE__ */ jsx5("span", { className: "flex flex-row gap-1", children })
|
|
1092
1201
|
]
|
|
1093
1202
|
}
|
|
1094
1203
|
),
|
|
1095
|
-
/* @__PURE__ */ jsx5(CaretRight, { className: "text-text-800", size: 24 })
|
|
1204
|
+
/* @__PURE__ */ jsx5(CaretRight, { className: "text-text-800 cursor-pointer", size: 24 })
|
|
1096
1205
|
]
|
|
1097
1206
|
}
|
|
1098
1207
|
);
|
|
@@ -1113,10 +1222,14 @@ var CardForum = forwardRef(
|
|
|
1113
1222
|
...props
|
|
1114
1223
|
}, ref) => {
|
|
1115
1224
|
return /* @__PURE__ */ jsxs4(
|
|
1116
|
-
|
|
1225
|
+
CardBase,
|
|
1117
1226
|
{
|
|
1118
1227
|
ref,
|
|
1119
|
-
|
|
1228
|
+
layout: "horizontal",
|
|
1229
|
+
padding: "medium",
|
|
1230
|
+
minHeight: "none",
|
|
1231
|
+
variant: "minimal",
|
|
1232
|
+
className: `w-auto h-auto gap-3 ${className}`,
|
|
1120
1233
|
...props,
|
|
1121
1234
|
children: [
|
|
1122
1235
|
/* @__PURE__ */ jsx5(
|
|
@@ -1161,8 +1274,250 @@ var CardForum = forwardRef(
|
|
|
1161
1274
|
);
|
|
1162
1275
|
}
|
|
1163
1276
|
);
|
|
1277
|
+
var CardAudio = forwardRef(
|
|
1278
|
+
({
|
|
1279
|
+
src,
|
|
1280
|
+
title,
|
|
1281
|
+
onPlay,
|
|
1282
|
+
onPause,
|
|
1283
|
+
onEnded,
|
|
1284
|
+
onAudioTimeUpdate,
|
|
1285
|
+
loop = false,
|
|
1286
|
+
preload = "metadata",
|
|
1287
|
+
tracks,
|
|
1288
|
+
className,
|
|
1289
|
+
...props
|
|
1290
|
+
}, ref) => {
|
|
1291
|
+
const [isPlaying, setIsPlaying] = useState(false);
|
|
1292
|
+
const [currentTime, setCurrentTime] = useState(0);
|
|
1293
|
+
const [duration, setDuration] = useState(0);
|
|
1294
|
+
const [volume, setVolume] = useState(1);
|
|
1295
|
+
const [showVolumeControl, setShowVolumeControl] = useState(false);
|
|
1296
|
+
const audioRef = useRef(null);
|
|
1297
|
+
const formatTime = (time) => {
|
|
1298
|
+
const minutes = Math.floor(time / 60);
|
|
1299
|
+
const seconds = Math.floor(time % 60);
|
|
1300
|
+
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
|
1301
|
+
};
|
|
1302
|
+
const handlePlayPause = () => {
|
|
1303
|
+
if (isPlaying) {
|
|
1304
|
+
audioRef.current?.pause();
|
|
1305
|
+
setIsPlaying(false);
|
|
1306
|
+
onPause?.();
|
|
1307
|
+
} else {
|
|
1308
|
+
audioRef.current?.play();
|
|
1309
|
+
setIsPlaying(true);
|
|
1310
|
+
onPlay?.();
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
const handleTimeUpdate = () => {
|
|
1314
|
+
const current = audioRef.current?.currentTime ?? 0;
|
|
1315
|
+
const total = audioRef.current?.duration ?? 0;
|
|
1316
|
+
setCurrentTime(current);
|
|
1317
|
+
setDuration(total);
|
|
1318
|
+
onAudioTimeUpdate?.(current, total);
|
|
1319
|
+
};
|
|
1320
|
+
const handleLoadedMetadata = () => {
|
|
1321
|
+
setDuration(audioRef.current?.duration ?? 0);
|
|
1322
|
+
};
|
|
1323
|
+
const handleEnded = () => {
|
|
1324
|
+
setIsPlaying(false);
|
|
1325
|
+
setCurrentTime(0);
|
|
1326
|
+
onEnded?.();
|
|
1327
|
+
};
|
|
1328
|
+
const handleProgressClick = (e) => {
|
|
1329
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1330
|
+
const clickX = e.clientX - rect.left;
|
|
1331
|
+
const width = rect.width;
|
|
1332
|
+
const percentage = clickX / width;
|
|
1333
|
+
const newTime = percentage * duration;
|
|
1334
|
+
if (audioRef.current) {
|
|
1335
|
+
audioRef.current.currentTime = newTime;
|
|
1336
|
+
}
|
|
1337
|
+
setCurrentTime(newTime);
|
|
1338
|
+
};
|
|
1339
|
+
const handleVolumeChange = (e) => {
|
|
1340
|
+
const newVolume = parseFloat(e.target.value);
|
|
1341
|
+
setVolume(newVolume);
|
|
1342
|
+
if (audioRef.current) {
|
|
1343
|
+
audioRef.current.volume = newVolume;
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
const toggleVolumeControl = () => {
|
|
1347
|
+
setShowVolumeControl(!showVolumeControl);
|
|
1348
|
+
};
|
|
1349
|
+
const getVolumeIcon = () => {
|
|
1350
|
+
if (volume === 0) {
|
|
1351
|
+
return /* @__PURE__ */ jsx5(SpeakerSimpleX, {});
|
|
1352
|
+
}
|
|
1353
|
+
if (volume < 0.5) {
|
|
1354
|
+
return /* @__PURE__ */ jsx5(SpeakerLow, {});
|
|
1355
|
+
}
|
|
1356
|
+
return /* @__PURE__ */ jsx5(SpeakerHigh, {});
|
|
1357
|
+
};
|
|
1358
|
+
return /* @__PURE__ */ jsxs4(
|
|
1359
|
+
CardBase,
|
|
1360
|
+
{
|
|
1361
|
+
ref,
|
|
1362
|
+
layout: "horizontal",
|
|
1363
|
+
padding: "medium",
|
|
1364
|
+
minHeight: "none",
|
|
1365
|
+
className: `w-auto h-14 items-center gap-2 border-none ${className}`,
|
|
1366
|
+
...props,
|
|
1367
|
+
children: [
|
|
1368
|
+
/* @__PURE__ */ jsx5(
|
|
1369
|
+
"audio",
|
|
1370
|
+
{
|
|
1371
|
+
ref: audioRef,
|
|
1372
|
+
src,
|
|
1373
|
+
loop,
|
|
1374
|
+
preload,
|
|
1375
|
+
onTimeUpdate: handleTimeUpdate,
|
|
1376
|
+
onLoadedMetadata: handleLoadedMetadata,
|
|
1377
|
+
onEnded: handleEnded,
|
|
1378
|
+
"data-testid": "audio-element",
|
|
1379
|
+
"aria-label": title,
|
|
1380
|
+
children: tracks ? tracks.map((track) => /* @__PURE__ */ jsx5(
|
|
1381
|
+
"track",
|
|
1382
|
+
{
|
|
1383
|
+
kind: track.kind,
|
|
1384
|
+
src: track.src,
|
|
1385
|
+
srcLang: track.srcLang,
|
|
1386
|
+
label: track.label,
|
|
1387
|
+
default: track.default
|
|
1388
|
+
},
|
|
1389
|
+
track.src
|
|
1390
|
+
)) : /* @__PURE__ */ jsx5(
|
|
1391
|
+
"track",
|
|
1392
|
+
{
|
|
1393
|
+
kind: "captions",
|
|
1394
|
+
src: "data:text/vtt;base64,",
|
|
1395
|
+
srcLang: "pt",
|
|
1396
|
+
label: "Sem legendas dispon\xEDveis"
|
|
1397
|
+
}
|
|
1398
|
+
)
|
|
1399
|
+
}
|
|
1400
|
+
),
|
|
1401
|
+
/* @__PURE__ */ jsx5(
|
|
1402
|
+
"button",
|
|
1403
|
+
{
|
|
1404
|
+
type: "button",
|
|
1405
|
+
onClick: handlePlayPause,
|
|
1406
|
+
disabled: !src,
|
|
1407
|
+
className: "cursor-pointer text-text-950 hover:text-primary-600 disabled:text-text-400 disabled:cursor-not-allowed",
|
|
1408
|
+
"aria-label": isPlaying ? "Pausar" : "Reproduzir",
|
|
1409
|
+
children: isPlaying ? /* @__PURE__ */ jsx5("div", { className: "w-6 h-6 flex items-center justify-center", children: /* @__PURE__ */ jsxs4("div", { className: "flex gap-0.5", children: [
|
|
1410
|
+
/* @__PURE__ */ jsx5("div", { className: "w-1 h-4 bg-current rounded-sm" }),
|
|
1411
|
+
/* @__PURE__ */ jsx5("div", { className: "w-1 h-4 bg-current rounded-sm" })
|
|
1412
|
+
] }) }) : /* @__PURE__ */ jsx5(Play, { size: 24 })
|
|
1413
|
+
}
|
|
1414
|
+
),
|
|
1415
|
+
/* @__PURE__ */ jsx5("p", { className: "text-text-800 text-sm font-medium min-w-[2.5rem]", children: formatTime(currentTime) }),
|
|
1416
|
+
/* @__PURE__ */ jsx5("div", { className: "flex-1 relative", "data-testid": "progress-bar", children: /* @__PURE__ */ jsx5(
|
|
1417
|
+
"button",
|
|
1418
|
+
{
|
|
1419
|
+
type: "button",
|
|
1420
|
+
className: "w-full h-2 bg-border-100 rounded-full cursor-pointer",
|
|
1421
|
+
onClick: handleProgressClick,
|
|
1422
|
+
onKeyDown: (e) => {
|
|
1423
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1424
|
+
e.preventDefault();
|
|
1425
|
+
handleProgressClick(
|
|
1426
|
+
e
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
"aria-label": "Barra de progresso do \xE1udio",
|
|
1431
|
+
children: /* @__PURE__ */ jsx5(
|
|
1432
|
+
"div",
|
|
1433
|
+
{
|
|
1434
|
+
className: "h-full bg-primary-600 rounded-full transition-all duration-100",
|
|
1435
|
+
style: {
|
|
1436
|
+
width: duration > 0 ? `${currentTime / duration * 100}%` : "0%"
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
)
|
|
1440
|
+
}
|
|
1441
|
+
) }),
|
|
1442
|
+
/* @__PURE__ */ jsx5("p", { className: "text-text-800 text-sm font-medium min-w-[2.5rem]", children: formatTime(duration) }),
|
|
1443
|
+
/* @__PURE__ */ jsxs4("div", { className: "relative", children: [
|
|
1444
|
+
/* @__PURE__ */ jsx5(
|
|
1445
|
+
"button",
|
|
1446
|
+
{
|
|
1447
|
+
type: "button",
|
|
1448
|
+
onClick: toggleVolumeControl,
|
|
1449
|
+
className: "cursor-pointer text-text-950 hover:text-primary-600",
|
|
1450
|
+
"aria-label": "Controle de volume",
|
|
1451
|
+
children: /* @__PURE__ */ jsx5("div", { className: "w-6 h-6 flex items-center justify-center", children: getVolumeIcon() })
|
|
1452
|
+
}
|
|
1453
|
+
),
|
|
1454
|
+
showVolumeControl && /* @__PURE__ */ jsx5(
|
|
1455
|
+
"button",
|
|
1456
|
+
{
|
|
1457
|
+
type: "button",
|
|
1458
|
+
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",
|
|
1459
|
+
onKeyDown: (e) => {
|
|
1460
|
+
if (e.key === "Escape") {
|
|
1461
|
+
setShowVolumeControl(false);
|
|
1462
|
+
}
|
|
1463
|
+
},
|
|
1464
|
+
children: /* @__PURE__ */ jsx5(
|
|
1465
|
+
"input",
|
|
1466
|
+
{
|
|
1467
|
+
type: "range",
|
|
1468
|
+
min: "0",
|
|
1469
|
+
max: "1",
|
|
1470
|
+
step: "0.1",
|
|
1471
|
+
value: volume,
|
|
1472
|
+
onChange: handleVolumeChange,
|
|
1473
|
+
onKeyDown: (e) => {
|
|
1474
|
+
if (e.key === "ArrowUp" || e.key === "ArrowRight") {
|
|
1475
|
+
e.preventDefault();
|
|
1476
|
+
const newVolume = Math.min(
|
|
1477
|
+
1,
|
|
1478
|
+
Math.round((volume + 0.1) * 10) / 10
|
|
1479
|
+
);
|
|
1480
|
+
setVolume(newVolume);
|
|
1481
|
+
if (audioRef.current) audioRef.current.volume = newVolume;
|
|
1482
|
+
} else if (e.key === "ArrowDown" || e.key === "ArrowLeft") {
|
|
1483
|
+
e.preventDefault();
|
|
1484
|
+
const newVolume = Math.max(
|
|
1485
|
+
0,
|
|
1486
|
+
Math.round((volume - 0.1) * 10) / 10
|
|
1487
|
+
);
|
|
1488
|
+
setVolume(newVolume);
|
|
1489
|
+
if (audioRef.current) audioRef.current.volume = newVolume;
|
|
1490
|
+
}
|
|
1491
|
+
},
|
|
1492
|
+
className: "w-20 h-2 bg-border-100 rounded-lg appearance-none cursor-pointer",
|
|
1493
|
+
style: {
|
|
1494
|
+
background: `linear-gradient(to right, #3b82f6 0%, #3b82f6 ${volume * 100}%, #e5e7eb ${volume * 100}%, #e5e7eb 100%)`
|
|
1495
|
+
},
|
|
1496
|
+
"aria-label": "Volume",
|
|
1497
|
+
"aria-valuenow": Math.round(volume * 100),
|
|
1498
|
+
"aria-valuemin": 0,
|
|
1499
|
+
"aria-valuemax": 100
|
|
1500
|
+
}
|
|
1501
|
+
)
|
|
1502
|
+
}
|
|
1503
|
+
)
|
|
1504
|
+
] }),
|
|
1505
|
+
/* @__PURE__ */ jsx5(
|
|
1506
|
+
DotsThreeVertical,
|
|
1507
|
+
{
|
|
1508
|
+
size: 24,
|
|
1509
|
+
className: "text-text-950 cursor-pointer hover:text-primary-600"
|
|
1510
|
+
}
|
|
1511
|
+
)
|
|
1512
|
+
]
|
|
1513
|
+
}
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
);
|
|
1164
1517
|
export {
|
|
1165
1518
|
CardActivesResults,
|
|
1519
|
+
CardAudio,
|
|
1520
|
+
CardBase,
|
|
1166
1521
|
CardForum,
|
|
1167
1522
|
CardPerformance,
|
|
1168
1523
|
CardProgress,
|