analytica-frontend-lib 1.0.28 → 1.0.30

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
@@ -1013,23 +1013,188 @@ var Toaster = () => {
1013
1013
  };
1014
1014
  var Toaster_default = Toaster;
1015
1015
 
1016
+ // src/components/Input/Input.tsx
1017
+ import { WarningCircle as WarningCircle3, Eye, EyeSlash } from "phosphor-react";
1018
+ import {
1019
+ forwardRef as forwardRef7,
1020
+ useState as useState3,
1021
+ useId as useId3,
1022
+ useMemo
1023
+ } from "react";
1024
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
1025
+ var SIZE_CLASSES5 = {
1026
+ small: "text-sm",
1027
+ medium: "text-md",
1028
+ large: "text-lg",
1029
+ "extra-large": "text-xl"
1030
+ };
1031
+ var STATE_CLASSES3 = {
1032
+ default: "border-border-300 placeholder:text-text-600 hover:border-border-400",
1033
+ error: "border-2 border-indicator-error placeholder:text-text-600",
1034
+ disabled: "border-border-300 placeholder:text-text-600 cursor-not-allowed opacity-40",
1035
+ "read-only": "border-border-300 !text-text-600 cursor-default focus:outline-none bg-background-50"
1036
+ };
1037
+ var VARIANT_CLASSES = {
1038
+ outlined: "border rounded-lg",
1039
+ underlined: "border-0 border-b rounded-none bg-transparent focus:outline-none focus:border-primary-950 focus:border-b-2",
1040
+ rounded: "border rounded-full"
1041
+ };
1042
+ var getActualState = (disabled, readOnly, errorMessage, state) => {
1043
+ if (disabled) return "disabled";
1044
+ if (readOnly) return "read-only";
1045
+ if (errorMessage) return "error";
1046
+ return state || "default";
1047
+ };
1048
+ var getIconSize = (size) => {
1049
+ const iconSizeClasses = {
1050
+ small: "w-4 h-4",
1051
+ medium: "w-5 h-5",
1052
+ large: "w-6 h-6",
1053
+ "extra-large": "w-7 h-7"
1054
+ };
1055
+ return iconSizeClasses[size] || iconSizeClasses.medium;
1056
+ };
1057
+ var getPasswordToggleConfig = (type, disabled, readOnly, showPassword, iconRight) => {
1058
+ const isPasswordType = type === "password";
1059
+ const shouldShowPasswordToggle = isPasswordType && !disabled && !readOnly;
1060
+ let actualIconRight = iconRight;
1061
+ let ariaLabel;
1062
+ if (shouldShowPasswordToggle) {
1063
+ actualIconRight = showPassword ? /* @__PURE__ */ jsx14(EyeSlash, {}) : /* @__PURE__ */ jsx14(Eye, {});
1064
+ ariaLabel = showPassword ? "Ocultar senha" : "Mostrar senha";
1065
+ }
1066
+ return { shouldShowPasswordToggle, actualIconRight, ariaLabel };
1067
+ };
1068
+ var getCombinedClasses = (actualState, variant) => {
1069
+ const stateClasses = STATE_CLASSES3[actualState];
1070
+ const variantClasses = VARIANT_CLASSES[variant];
1071
+ if (actualState === "error" && variant === "underlined") {
1072
+ return "border-0 border-b-2 border-indicator-error rounded-none bg-transparent focus:outline-none focus:border-primary-950 placeholder:text-text-600";
1073
+ }
1074
+ return `${stateClasses} ${variantClasses}`;
1075
+ };
1076
+ var Input = forwardRef7(
1077
+ ({
1078
+ label,
1079
+ helperText,
1080
+ errorMessage,
1081
+ size = "medium",
1082
+ variant = "outlined",
1083
+ state = "default",
1084
+ iconLeft,
1085
+ iconRight,
1086
+ className = "",
1087
+ containerClassName = "",
1088
+ disabled,
1089
+ readOnly,
1090
+ id,
1091
+ type = "text",
1092
+ ...props
1093
+ }, ref) => {
1094
+ const [showPassword, setShowPassword] = useState3(false);
1095
+ const isPasswordType = type === "password";
1096
+ const actualType = isPasswordType && showPassword ? "text" : type;
1097
+ const actualState = getActualState(disabled, readOnly, errorMessage, state);
1098
+ const sizeClasses = SIZE_CLASSES5[size];
1099
+ const combinedClasses = useMemo(
1100
+ () => getCombinedClasses(actualState, variant),
1101
+ [actualState, variant]
1102
+ );
1103
+ const iconSize = getIconSize(size);
1104
+ const baseClasses = "bg-background w-full py-2 px-3 font-normal text-text-900 focus:outline-primary-950";
1105
+ const generatedId = useId3();
1106
+ const inputId = id ?? `input-${generatedId}`;
1107
+ const togglePasswordVisibility = () => setShowPassword(!showPassword);
1108
+ const { shouldShowPasswordToggle, actualIconRight, ariaLabel } = getPasswordToggleConfig(
1109
+ type,
1110
+ disabled,
1111
+ readOnly,
1112
+ showPassword,
1113
+ iconRight
1114
+ );
1115
+ return /* @__PURE__ */ jsxs10("div", { className: `${containerClassName}`, children: [
1116
+ label && /* @__PURE__ */ jsx14(
1117
+ "label",
1118
+ {
1119
+ htmlFor: inputId,
1120
+ className: `block font-bold text-text-900 mb-1.5 ${sizeClasses}`,
1121
+ children: label
1122
+ }
1123
+ ),
1124
+ /* @__PURE__ */ jsxs10("div", { className: "relative", children: [
1125
+ iconLeft && /* @__PURE__ */ jsx14("div", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ jsx14(
1126
+ "span",
1127
+ {
1128
+ className: `${iconSize} text-text-400 flex items-center justify-center`,
1129
+ children: iconLeft
1130
+ }
1131
+ ) }),
1132
+ /* @__PURE__ */ jsx14(
1133
+ "input",
1134
+ {
1135
+ ref,
1136
+ id: inputId,
1137
+ type: actualType,
1138
+ className: `${baseClasses} ${sizeClasses} ${combinedClasses} ${iconLeft ? "pl-10" : ""} ${actualIconRight ? "pr-10" : ""} ${className}`,
1139
+ disabled,
1140
+ readOnly,
1141
+ "aria-invalid": actualState === "error" ? "true" : void 0,
1142
+ ...props
1143
+ }
1144
+ ),
1145
+ actualIconRight && (shouldShowPasswordToggle ? /* @__PURE__ */ jsx14(
1146
+ "button",
1147
+ {
1148
+ type: "button",
1149
+ className: "absolute right-3 top-1/2 transform -translate-y-1/2 cursor-pointer border-0 bg-transparent p-0",
1150
+ onClick: togglePasswordVisibility,
1151
+ "aria-label": ariaLabel,
1152
+ children: /* @__PURE__ */ jsx14(
1153
+ "span",
1154
+ {
1155
+ className: `${iconSize} text-text-400 flex items-center justify-center hover:text-text-600 transition-colors`,
1156
+ children: actualIconRight
1157
+ }
1158
+ )
1159
+ }
1160
+ ) : /* @__PURE__ */ jsx14("div", { className: "absolute right-3 top-1/2 transform -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ jsx14(
1161
+ "span",
1162
+ {
1163
+ className: `${iconSize} text-text-400 flex items-center justify-center`,
1164
+ children: actualIconRight
1165
+ }
1166
+ ) }))
1167
+ ] }),
1168
+ /* @__PURE__ */ jsxs10("div", { className: "mt-1.5 gap-1.5", children: [
1169
+ helperText && /* @__PURE__ */ jsx14("p", { className: "text-sm text-text-500", children: helperText }),
1170
+ errorMessage && /* @__PURE__ */ jsxs10("p", { className: "flex gap-1 items-center text-sm text-indicator-error", children: [
1171
+ /* @__PURE__ */ jsx14(WarningCircle3, { size: 16 }),
1172
+ " ",
1173
+ errorMessage
1174
+ ] })
1175
+ ] })
1176
+ ] });
1177
+ }
1178
+ );
1179
+ var Input_default = Input;
1180
+
1016
1181
  // src/components/DropdownMenu/DropdownMenu.tsx
1017
1182
  import {
1018
1183
  createContext,
1019
- useState as useState3,
1184
+ useState as useState4,
1020
1185
  useCallback,
1021
1186
  useContext,
1022
- forwardRef as forwardRef7,
1187
+ forwardRef as forwardRef8,
1023
1188
  useEffect,
1024
1189
  useRef,
1025
- useMemo
1190
+ useMemo as useMemo2
1026
1191
  } from "react";
1027
- import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
1192
+ import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
1028
1193
  var DropdownMenuContext = createContext(
1029
1194
  void 0
1030
1195
  );
1031
1196
  var DropdownMenu = ({ children, open, onOpenChange }) => {
1032
- const [internalOpen, setInternalOpen] = useState3(false);
1197
+ const [internalOpen, setInternalOpen] = useState4(false);
1033
1198
  const isControlled = open !== void 0;
1034
1199
  const currentOpen = isControlled ? open : internalOpen;
1035
1200
  const setOpen = useCallback(
@@ -1083,18 +1248,18 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
1083
1248
  document.removeEventListener("keydown", handleDownkey);
1084
1249
  };
1085
1250
  }, [currentOpen]);
1086
- const value = useMemo(
1251
+ const value = useMemo2(
1087
1252
  () => ({ open: currentOpen, setOpen }),
1088
1253
  [currentOpen, setOpen]
1089
1254
  );
1090
- return /* @__PURE__ */ jsx14(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ jsx14("div", { className: "relative", ref: menuRef, children }) });
1255
+ return /* @__PURE__ */ jsx15(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ jsx15("div", { className: "relative", ref: menuRef, children }) });
1091
1256
  };
1092
- var DropdownMenuTrigger = forwardRef7(({ className, children, onClick, ...props }, ref) => {
1257
+ var DropdownMenuTrigger = forwardRef8(({ className, children, onClick, ...props }, ref) => {
1093
1258
  const context = useContext(DropdownMenuContext);
1094
1259
  if (!context)
1095
1260
  throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
1096
1261
  const { open, setOpen } = context;
1097
- return /* @__PURE__ */ jsx14(
1262
+ return /* @__PURE__ */ jsx15(
1098
1263
  "button",
1099
1264
  {
1100
1265
  ref,
@@ -1126,7 +1291,7 @@ var ALIGN_CLASSES = {
1126
1291
  center: "left-1/2 -translate-x-1/2",
1127
1292
  end: "right-0"
1128
1293
  };
1129
- var MenuLabel = forwardRef7(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx14(
1294
+ var MenuLabel = forwardRef8(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx15(
1130
1295
  "fieldset",
1131
1296
  {
1132
1297
  ref,
@@ -1136,7 +1301,7 @@ var MenuLabel = forwardRef7(({ className, inset, ...props }, ref) => /* @__PURE_
1136
1301
  }
1137
1302
  ));
1138
1303
  MenuLabel.displayName = "MenuLabel";
1139
- var MenuContent = forwardRef7(
1304
+ var MenuContent = forwardRef8(
1140
1305
  ({
1141
1306
  className,
1142
1307
  align = "start",
@@ -1146,7 +1311,7 @@ var MenuContent = forwardRef7(
1146
1311
  ...props
1147
1312
  }, ref) => {
1148
1313
  const { open } = useContext(DropdownMenuContext);
1149
- const [isVisible, setIsVisible] = useState3(open);
1314
+ const [isVisible, setIsVisible] = useState4(open);
1150
1315
  useEffect(() => {
1151
1316
  if (open) {
1152
1317
  setIsVisible(true);
@@ -1161,7 +1326,7 @@ var MenuContent = forwardRef7(
1161
1326
  const horizontal = ALIGN_CLASSES[align];
1162
1327
  return `absolute ${vertical} ${horizontal}`;
1163
1328
  };
1164
- return /* @__PURE__ */ jsx14(
1329
+ return /* @__PURE__ */ jsx15(
1165
1330
  "div",
1166
1331
  {
1167
1332
  ref,
@@ -1185,7 +1350,7 @@ var MenuContent = forwardRef7(
1185
1350
  }
1186
1351
  );
1187
1352
  MenuContent.displayName = "MenuContent";
1188
- var MenuItem = forwardRef7(
1353
+ var MenuItem = forwardRef8(
1189
1354
  ({
1190
1355
  className,
1191
1356
  inset,
@@ -1206,7 +1371,7 @@ var MenuItem = forwardRef7(
1206
1371
  }
1207
1372
  onClick?.(e);
1208
1373
  };
1209
- return /* @__PURE__ */ jsxs10(
1374
+ return /* @__PURE__ */ jsxs11(
1210
1375
  "div",
1211
1376
  {
1212
1377
  ref,
@@ -1236,7 +1401,7 @@ var MenuItem = forwardRef7(
1236
1401
  }
1237
1402
  );
1238
1403
  MenuItem.displayName = "MenuItem";
1239
- var MenuSeparator = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx14(
1404
+ var MenuSeparator = forwardRef8(({ className, ...props }, ref) => /* @__PURE__ */ jsx15(
1240
1405
  "div",
1241
1406
  {
1242
1407
  ref,
@@ -1259,6 +1424,7 @@ export {
1259
1424
  DropdownMenuTrigger,
1260
1425
  IconButton_default as IconButton,
1261
1426
  IconRoundedButton_default as IconRoundedButton,
1427
+ Input_default as Input,
1262
1428
  NavButton_default as NavButton,
1263
1429
  SelectionButton_default as SelectionButton,
1264
1430
  Table_default as Table,