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.css +76 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +182 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +182 -16
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +76 -0
- package/dist/styles.css.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,33 @@ export { default as TextArea } from './TextArea/index.js';
|
|
|
12
12
|
export { default as Toast } from './Toast/index.js';
|
|
13
13
|
export { default as Toaster } from './Toast/Toaster/index.js';
|
|
14
14
|
export { default as useToastStore } from './Toast/ToastStore/index.js';
|
|
15
|
+
import * as react from 'react';
|
|
16
|
+
import { ReactNode, InputHTMLAttributes } from 'react';
|
|
15
17
|
export { default as DropdownMenu, MenuContent as DropdownMenuContent, MenuItem as DropdownMenuItem, MenuLabel as DropdownMenuLabel, MenuSeparator as DropdownMenuSeparator, DropdownMenuTrigger } from './DropdownMenu/index.js';
|
|
16
18
|
import 'react/jsx-runtime';
|
|
17
|
-
import 'react';
|
|
18
19
|
import 'zustand';
|
|
20
|
+
|
|
21
|
+
declare const Input: react.ForwardRefExoticComponent<{
|
|
22
|
+
/** Label text displayed above the input */
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Helper text displayed below the input */
|
|
25
|
+
helperText?: string;
|
|
26
|
+
/** Error message displayed below the input */
|
|
27
|
+
errorMessage?: string;
|
|
28
|
+
/** Size of the input */
|
|
29
|
+
size?: "small" | "medium" | "large" | "extra-large";
|
|
30
|
+
/** Visual variant of the input */
|
|
31
|
+
variant?: "outlined" | "underlined" | "rounded";
|
|
32
|
+
/** Current state of the input */
|
|
33
|
+
state?: "default" | "error" | "disabled" | "read-only";
|
|
34
|
+
/** Icon to display on the left side of the input */
|
|
35
|
+
iconLeft?: ReactNode;
|
|
36
|
+
/** Icon to display on the right side of the input */
|
|
37
|
+
iconRight?: ReactNode;
|
|
38
|
+
/** Additional CSS classes to apply to the input */
|
|
39
|
+
className?: string;
|
|
40
|
+
/** Additional CSS classes to apply to the container */
|
|
41
|
+
containerClassName?: string;
|
|
42
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "size"> & react.RefAttributes<HTMLInputElement>>;
|
|
43
|
+
|
|
44
|
+
export { Input };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(src_exports, {
|
|
|
32
32
|
DropdownMenuTrigger: () => DropdownMenuTrigger,
|
|
33
33
|
IconButton: () => IconButton_default,
|
|
34
34
|
IconRoundedButton: () => IconRoundedButton_default,
|
|
35
|
+
Input: () => Input_default,
|
|
35
36
|
NavButton: () => NavButton_default,
|
|
36
37
|
SelectionButton: () => SelectionButton_default,
|
|
37
38
|
Table: () => Table_default,
|
|
@@ -1050,24 +1051,184 @@ var Toaster = () => {
|
|
|
1050
1051
|
};
|
|
1051
1052
|
var Toaster_default = Toaster;
|
|
1052
1053
|
|
|
1053
|
-
// src/components/
|
|
1054
|
+
// src/components/Input/Input.tsx
|
|
1055
|
+
var import_phosphor_react5 = require("phosphor-react");
|
|
1054
1056
|
var import_react7 = require("react");
|
|
1055
1057
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1056
|
-
var
|
|
1058
|
+
var SIZE_CLASSES5 = {
|
|
1059
|
+
small: "text-sm",
|
|
1060
|
+
medium: "text-md",
|
|
1061
|
+
large: "text-lg",
|
|
1062
|
+
"extra-large": "text-xl"
|
|
1063
|
+
};
|
|
1064
|
+
var STATE_CLASSES3 = {
|
|
1065
|
+
default: "border-border-300 placeholder:text-text-600 hover:border-border-400",
|
|
1066
|
+
error: "border-2 border-indicator-error placeholder:text-text-600",
|
|
1067
|
+
disabled: "border-border-300 placeholder:text-text-600 cursor-not-allowed opacity-40",
|
|
1068
|
+
"read-only": "border-border-300 !text-text-600 cursor-default focus:outline-none bg-background-50"
|
|
1069
|
+
};
|
|
1070
|
+
var VARIANT_CLASSES = {
|
|
1071
|
+
outlined: "border rounded-lg",
|
|
1072
|
+
underlined: "border-0 border-b rounded-none bg-transparent focus:outline-none focus:border-primary-950 focus:border-b-2",
|
|
1073
|
+
rounded: "border rounded-full"
|
|
1074
|
+
};
|
|
1075
|
+
var getActualState = (disabled, readOnly, errorMessage, state) => {
|
|
1076
|
+
if (disabled) return "disabled";
|
|
1077
|
+
if (readOnly) return "read-only";
|
|
1078
|
+
if (errorMessage) return "error";
|
|
1079
|
+
return state || "default";
|
|
1080
|
+
};
|
|
1081
|
+
var getIconSize = (size) => {
|
|
1082
|
+
const iconSizeClasses = {
|
|
1083
|
+
small: "w-4 h-4",
|
|
1084
|
+
medium: "w-5 h-5",
|
|
1085
|
+
large: "w-6 h-6",
|
|
1086
|
+
"extra-large": "w-7 h-7"
|
|
1087
|
+
};
|
|
1088
|
+
return iconSizeClasses[size] || iconSizeClasses.medium;
|
|
1089
|
+
};
|
|
1090
|
+
var getPasswordToggleConfig = (type, disabled, readOnly, showPassword, iconRight) => {
|
|
1091
|
+
const isPasswordType = type === "password";
|
|
1092
|
+
const shouldShowPasswordToggle = isPasswordType && !disabled && !readOnly;
|
|
1093
|
+
let actualIconRight = iconRight;
|
|
1094
|
+
let ariaLabel;
|
|
1095
|
+
if (shouldShowPasswordToggle) {
|
|
1096
|
+
actualIconRight = showPassword ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_phosphor_react5.EyeSlash, {}) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_phosphor_react5.Eye, {});
|
|
1097
|
+
ariaLabel = showPassword ? "Ocultar senha" : "Mostrar senha";
|
|
1098
|
+
}
|
|
1099
|
+
return { shouldShowPasswordToggle, actualIconRight, ariaLabel };
|
|
1100
|
+
};
|
|
1101
|
+
var getCombinedClasses = (actualState, variant) => {
|
|
1102
|
+
const stateClasses = STATE_CLASSES3[actualState];
|
|
1103
|
+
const variantClasses = VARIANT_CLASSES[variant];
|
|
1104
|
+
if (actualState === "error" && variant === "underlined") {
|
|
1105
|
+
return "border-0 border-b-2 border-indicator-error rounded-none bg-transparent focus:outline-none focus:border-primary-950 placeholder:text-text-600";
|
|
1106
|
+
}
|
|
1107
|
+
return `${stateClasses} ${variantClasses}`;
|
|
1108
|
+
};
|
|
1109
|
+
var Input = (0, import_react7.forwardRef)(
|
|
1110
|
+
({
|
|
1111
|
+
label,
|
|
1112
|
+
helperText,
|
|
1113
|
+
errorMessage,
|
|
1114
|
+
size = "medium",
|
|
1115
|
+
variant = "outlined",
|
|
1116
|
+
state = "default",
|
|
1117
|
+
iconLeft,
|
|
1118
|
+
iconRight,
|
|
1119
|
+
className = "",
|
|
1120
|
+
containerClassName = "",
|
|
1121
|
+
disabled,
|
|
1122
|
+
readOnly,
|
|
1123
|
+
id,
|
|
1124
|
+
type = "text",
|
|
1125
|
+
...props
|
|
1126
|
+
}, ref) => {
|
|
1127
|
+
const [showPassword, setShowPassword] = (0, import_react7.useState)(false);
|
|
1128
|
+
const isPasswordType = type === "password";
|
|
1129
|
+
const actualType = isPasswordType && showPassword ? "text" : type;
|
|
1130
|
+
const actualState = getActualState(disabled, readOnly, errorMessage, state);
|
|
1131
|
+
const sizeClasses = SIZE_CLASSES5[size];
|
|
1132
|
+
const combinedClasses = (0, import_react7.useMemo)(
|
|
1133
|
+
() => getCombinedClasses(actualState, variant),
|
|
1134
|
+
[actualState, variant]
|
|
1135
|
+
);
|
|
1136
|
+
const iconSize = getIconSize(size);
|
|
1137
|
+
const baseClasses = "bg-background w-full py-2 px-3 font-normal text-text-900 focus:outline-primary-950";
|
|
1138
|
+
const generatedId = (0, import_react7.useId)();
|
|
1139
|
+
const inputId = id ?? `input-${generatedId}`;
|
|
1140
|
+
const togglePasswordVisibility = () => setShowPassword(!showPassword);
|
|
1141
|
+
const { shouldShowPasswordToggle, actualIconRight, ariaLabel } = getPasswordToggleConfig(
|
|
1142
|
+
type,
|
|
1143
|
+
disabled,
|
|
1144
|
+
readOnly,
|
|
1145
|
+
showPassword,
|
|
1146
|
+
iconRight
|
|
1147
|
+
);
|
|
1148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `${containerClassName}`, children: [
|
|
1149
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1150
|
+
"label",
|
|
1151
|
+
{
|
|
1152
|
+
htmlFor: inputId,
|
|
1153
|
+
className: `block font-bold text-text-900 mb-1.5 ${sizeClasses}`,
|
|
1154
|
+
children: label
|
|
1155
|
+
}
|
|
1156
|
+
),
|
|
1157
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative", children: [
|
|
1158
|
+
iconLeft && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1159
|
+
"span",
|
|
1160
|
+
{
|
|
1161
|
+
className: `${iconSize} text-text-400 flex items-center justify-center`,
|
|
1162
|
+
children: iconLeft
|
|
1163
|
+
}
|
|
1164
|
+
) }),
|
|
1165
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1166
|
+
"input",
|
|
1167
|
+
{
|
|
1168
|
+
ref,
|
|
1169
|
+
id: inputId,
|
|
1170
|
+
type: actualType,
|
|
1171
|
+
className: `${baseClasses} ${sizeClasses} ${combinedClasses} ${iconLeft ? "pl-10" : ""} ${actualIconRight ? "pr-10" : ""} ${className}`,
|
|
1172
|
+
disabled,
|
|
1173
|
+
readOnly,
|
|
1174
|
+
"aria-invalid": actualState === "error" ? "true" : void 0,
|
|
1175
|
+
...props
|
|
1176
|
+
}
|
|
1177
|
+
),
|
|
1178
|
+
actualIconRight && (shouldShowPasswordToggle ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1179
|
+
"button",
|
|
1180
|
+
{
|
|
1181
|
+
type: "button",
|
|
1182
|
+
className: "absolute right-3 top-1/2 transform -translate-y-1/2 cursor-pointer border-0 bg-transparent p-0",
|
|
1183
|
+
onClick: togglePasswordVisibility,
|
|
1184
|
+
"aria-label": ariaLabel,
|
|
1185
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1186
|
+
"span",
|
|
1187
|
+
{
|
|
1188
|
+
className: `${iconSize} text-text-400 flex items-center justify-center hover:text-text-600 transition-colors`,
|
|
1189
|
+
children: actualIconRight
|
|
1190
|
+
}
|
|
1191
|
+
)
|
|
1192
|
+
}
|
|
1193
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "absolute right-3 top-1/2 transform -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1194
|
+
"span",
|
|
1195
|
+
{
|
|
1196
|
+
className: `${iconSize} text-text-400 flex items-center justify-center`,
|
|
1197
|
+
children: actualIconRight
|
|
1198
|
+
}
|
|
1199
|
+
) }))
|
|
1200
|
+
] }),
|
|
1201
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mt-1.5 gap-1.5", children: [
|
|
1202
|
+
helperText && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-sm text-text-500", children: helperText }),
|
|
1203
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "flex gap-1 items-center text-sm text-indicator-error", children: [
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_phosphor_react5.WarningCircle, { size: 16 }),
|
|
1205
|
+
" ",
|
|
1206
|
+
errorMessage
|
|
1207
|
+
] })
|
|
1208
|
+
] })
|
|
1209
|
+
] });
|
|
1210
|
+
}
|
|
1211
|
+
);
|
|
1212
|
+
var Input_default = Input;
|
|
1213
|
+
|
|
1214
|
+
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
1215
|
+
var import_react8 = require("react");
|
|
1216
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1217
|
+
var DropdownMenuContext = (0, import_react8.createContext)(
|
|
1057
1218
|
void 0
|
|
1058
1219
|
);
|
|
1059
1220
|
var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
1060
|
-
const [internalOpen, setInternalOpen] = (0,
|
|
1221
|
+
const [internalOpen, setInternalOpen] = (0, import_react8.useState)(false);
|
|
1061
1222
|
const isControlled = open !== void 0;
|
|
1062
1223
|
const currentOpen = isControlled ? open : internalOpen;
|
|
1063
|
-
const setOpen = (0,
|
|
1224
|
+
const setOpen = (0, import_react8.useCallback)(
|
|
1064
1225
|
(newOpen) => {
|
|
1065
1226
|
if (onOpenChange) onOpenChange(newOpen);
|
|
1066
1227
|
if (!isControlled) setInternalOpen(newOpen);
|
|
1067
1228
|
},
|
|
1068
1229
|
[isControlled, onOpenChange]
|
|
1069
1230
|
);
|
|
1070
|
-
const menuRef = (0,
|
|
1231
|
+
const menuRef = (0, import_react8.useRef)(null);
|
|
1071
1232
|
const handleArrowDownOrArrowUp = (event) => {
|
|
1072
1233
|
const menuContent = menuRef.current?.querySelector('[role="menu"]');
|
|
1073
1234
|
if (menuContent) {
|
|
@@ -1101,7 +1262,7 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
|
1101
1262
|
setOpen(false);
|
|
1102
1263
|
}
|
|
1103
1264
|
};
|
|
1104
|
-
(0,
|
|
1265
|
+
(0, import_react8.useEffect)(() => {
|
|
1105
1266
|
if (currentOpen) {
|
|
1106
1267
|
document.addEventListener("mousedown", handleClickOutside);
|
|
1107
1268
|
document.addEventListener("keydown", handleDownkey);
|
|
@@ -1111,18 +1272,18 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
|
1111
1272
|
document.removeEventListener("keydown", handleDownkey);
|
|
1112
1273
|
};
|
|
1113
1274
|
}, [currentOpen]);
|
|
1114
|
-
const value = (0,
|
|
1275
|
+
const value = (0, import_react8.useMemo)(
|
|
1115
1276
|
() => ({ open: currentOpen, setOpen }),
|
|
1116
1277
|
[currentOpen, setOpen]
|
|
1117
1278
|
);
|
|
1118
|
-
return /* @__PURE__ */ (0,
|
|
1279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "relative", ref: menuRef, children }) });
|
|
1119
1280
|
};
|
|
1120
|
-
var DropdownMenuTrigger = (0,
|
|
1121
|
-
const context = (0,
|
|
1281
|
+
var DropdownMenuTrigger = (0, import_react8.forwardRef)(({ className, children, onClick, ...props }, ref) => {
|
|
1282
|
+
const context = (0, import_react8.useContext)(DropdownMenuContext);
|
|
1122
1283
|
if (!context)
|
|
1123
1284
|
throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
|
|
1124
1285
|
const { open, setOpen } = context;
|
|
1125
|
-
return /* @__PURE__ */ (0,
|
|
1286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1126
1287
|
"button",
|
|
1127
1288
|
{
|
|
1128
1289
|
ref,
|
|
@@ -1154,7 +1315,7 @@ var ALIGN_CLASSES = {
|
|
|
1154
1315
|
center: "left-1/2 -translate-x-1/2",
|
|
1155
1316
|
end: "right-0"
|
|
1156
1317
|
};
|
|
1157
|
-
var MenuLabel = (0,
|
|
1318
|
+
var MenuLabel = (0, import_react8.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1158
1319
|
"fieldset",
|
|
1159
1320
|
{
|
|
1160
1321
|
ref,
|
|
@@ -1164,7 +1325,7 @@ var MenuLabel = (0, import_react7.forwardRef)(({ className, inset, ...props }, r
|
|
|
1164
1325
|
}
|
|
1165
1326
|
));
|
|
1166
1327
|
MenuLabel.displayName = "MenuLabel";
|
|
1167
|
-
var MenuContent = (0,
|
|
1328
|
+
var MenuContent = (0, import_react8.forwardRef)(
|
|
1168
1329
|
({
|
|
1169
1330
|
className,
|
|
1170
1331
|
align = "start",
|
|
@@ -1173,9 +1334,9 @@ var MenuContent = (0, import_react7.forwardRef)(
|
|
|
1173
1334
|
children,
|
|
1174
1335
|
...props
|
|
1175
1336
|
}, ref) => {
|
|
1176
|
-
const { open } = (0,
|
|
1177
|
-
const [isVisible, setIsVisible] = (0,
|
|
1178
|
-
(0,
|
|
1337
|
+
const { open } = (0, import_react8.useContext)(DropdownMenuContext);
|
|
1338
|
+
const [isVisible, setIsVisible] = (0, import_react8.useState)(open);
|
|
1339
|
+
(0, import_react8.useEffect)(() => {
|
|
1179
1340
|
if (open) {
|
|
1180
1341
|
setIsVisible(true);
|
|
1181
1342
|
} else {
|
|
@@ -1189,7 +1350,7 @@ var MenuContent = (0, import_react7.forwardRef)(
|
|
|
1189
1350
|
const horizontal = ALIGN_CLASSES[align];
|
|
1190
1351
|
return `absolute ${vertical} ${horizontal}`;
|
|
1191
1352
|
};
|
|
1192
|
-
return /* @__PURE__ */ (0,
|
|
1353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1193
1354
|
"div",
|
|
1194
1355
|
{
|
|
1195
1356
|
ref,
|
|
@@ -1213,7 +1374,7 @@ var MenuContent = (0, import_react7.forwardRef)(
|
|
|
1213
1374
|
}
|
|
1214
1375
|
);
|
|
1215
1376
|
MenuContent.displayName = "MenuContent";
|
|
1216
|
-
var MenuItem = (0,
|
|
1377
|
+
var MenuItem = (0, import_react8.forwardRef)(
|
|
1217
1378
|
({
|
|
1218
1379
|
className,
|
|
1219
1380
|
inset,
|
|
@@ -1234,7 +1395,7 @@ var MenuItem = (0, import_react7.forwardRef)(
|
|
|
1234
1395
|
}
|
|
1235
1396
|
onClick?.(e);
|
|
1236
1397
|
};
|
|
1237
|
-
return /* @__PURE__ */ (0,
|
|
1398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1238
1399
|
"div",
|
|
1239
1400
|
{
|
|
1240
1401
|
ref,
|
|
@@ -1264,7 +1425,7 @@ var MenuItem = (0, import_react7.forwardRef)(
|
|
|
1264
1425
|
}
|
|
1265
1426
|
);
|
|
1266
1427
|
MenuItem.displayName = "MenuItem";
|
|
1267
|
-
var MenuSeparator = (0,
|
|
1428
|
+
var MenuSeparator = (0, import_react8.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1268
1429
|
"div",
|
|
1269
1430
|
{
|
|
1270
1431
|
ref,
|
|
@@ -1288,6 +1449,7 @@ var DropdownMenu_default = DropdownMenu;
|
|
|
1288
1449
|
DropdownMenuTrigger,
|
|
1289
1450
|
IconButton,
|
|
1290
1451
|
IconRoundedButton,
|
|
1452
|
+
Input,
|
|
1291
1453
|
NavButton,
|
|
1292
1454
|
SelectionButton,
|
|
1293
1455
|
Table,
|