analytica-frontend-lib 1.1.72 → 1.1.74
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/DropdownMenu/index.d.mts +4 -1
- package/dist/DropdownMenu/index.d.ts +4 -1
- package/dist/DropdownMenu/index.js +39 -18
- package/dist/DropdownMenu/index.js.map +1 -1
- package/dist/DropdownMenu/index.mjs +39 -18
- package/dist/DropdownMenu/index.mjs.map +1 -1
- package/dist/NotificationCard/index.js +39 -18
- package/dist/NotificationCard/index.js.map +1 -1
- package/dist/NotificationCard/index.mjs +39 -18
- package/dist/NotificationCard/index.mjs.map +1 -1
- package/dist/Search/index.js +112 -45
- package/dist/Search/index.js.map +1 -1
- package/dist/Search/index.mjs +113 -46
- package/dist/Search/index.mjs.map +1 -1
- package/dist/index.js +112 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/Search/index.js
CHANGED
|
@@ -697,20 +697,19 @@ var DropdownMenu = ({
|
|
|
697
697
|
};
|
|
698
698
|
(0, import_react5.useEffect)(() => {
|
|
699
699
|
if (open) {
|
|
700
|
-
document.addEventListener("
|
|
700
|
+
document.addEventListener("pointerdown", handleClickOutside);
|
|
701
701
|
document.addEventListener("keydown", handleDownkey);
|
|
702
702
|
}
|
|
703
703
|
return () => {
|
|
704
|
-
document.removeEventListener("
|
|
704
|
+
document.removeEventListener("pointerdown", handleClickOutside);
|
|
705
705
|
document.removeEventListener("keydown", handleDownkey);
|
|
706
706
|
};
|
|
707
707
|
}, [open]);
|
|
708
708
|
(0, import_react5.useEffect)(() => {
|
|
709
|
-
setOpen(open);
|
|
710
709
|
onOpenChange?.(open);
|
|
711
710
|
}, [open, onOpenChange]);
|
|
712
711
|
(0, import_react5.useEffect)(() => {
|
|
713
|
-
if (propOpen) {
|
|
712
|
+
if (propOpen !== void 0) {
|
|
714
713
|
setOpen(propOpen);
|
|
715
714
|
}
|
|
716
715
|
}, [propOpen]);
|
|
@@ -837,6 +836,7 @@ var DropdownMenuItem = (0, import_react5.forwardRef)(
|
|
|
837
836
|
onClick,
|
|
838
837
|
variant = "menu",
|
|
839
838
|
store: externalStore,
|
|
839
|
+
preventClose = false,
|
|
840
840
|
...props
|
|
841
841
|
}, ref) => {
|
|
842
842
|
const store = useDropdownStore(externalStore);
|
|
@@ -848,8 +848,17 @@ var DropdownMenuItem = (0, import_react5.forwardRef)(
|
|
|
848
848
|
e.stopPropagation();
|
|
849
849
|
return;
|
|
850
850
|
}
|
|
851
|
-
|
|
852
|
-
|
|
851
|
+
if (e.type === "click") {
|
|
852
|
+
onClick?.(e);
|
|
853
|
+
} else if (e.type === "keydown") {
|
|
854
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
855
|
+
onClick?.(e);
|
|
856
|
+
}
|
|
857
|
+
props.onKeyDown?.(e);
|
|
858
|
+
}
|
|
859
|
+
if (!preventClose) {
|
|
860
|
+
setOpen(false);
|
|
861
|
+
}
|
|
853
862
|
};
|
|
854
863
|
const getVariantClasses = () => {
|
|
855
864
|
if (variant === "profile") {
|
|
@@ -876,7 +885,11 @@ var DropdownMenuItem = (0, import_react5.forwardRef)(
|
|
|
876
885
|
`,
|
|
877
886
|
onClick: handleClick,
|
|
878
887
|
onKeyDown: (e) => {
|
|
879
|
-
if (e.key === "Enter" || e.key === " ")
|
|
888
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
889
|
+
e.preventDefault();
|
|
890
|
+
e.stopPropagation();
|
|
891
|
+
handleClick(e);
|
|
892
|
+
}
|
|
880
893
|
},
|
|
881
894
|
tabIndex: disabled ? -1 : 0,
|
|
882
895
|
...props,
|
|
@@ -942,10 +955,17 @@ var ProfileMenuHeader = (0, import_react5.forwardRef)(({ className, name, email,
|
|
|
942
955
|
);
|
|
943
956
|
});
|
|
944
957
|
ProfileMenuHeader.displayName = "ProfileMenuHeader";
|
|
945
|
-
var ProfileToggleTheme = ({
|
|
958
|
+
var ProfileToggleTheme = ({
|
|
959
|
+
store: externalStore,
|
|
960
|
+
...props
|
|
961
|
+
}) => {
|
|
946
962
|
const { themeMode, setTheme } = useTheme();
|
|
947
963
|
const [modalThemeToggle, setModalThemeToggle] = (0, import_react5.useState)(false);
|
|
948
964
|
const [selectedTheme, setSelectedTheme] = (0, import_react5.useState)(themeMode);
|
|
965
|
+
const internalStoreRef = (0, import_react5.useRef)(null);
|
|
966
|
+
internalStoreRef.current ??= createDropdownStore();
|
|
967
|
+
const store = externalStore ?? internalStoreRef.current;
|
|
968
|
+
const setOpen = (0, import_zustand2.useStore)(store, (s) => s.setOpen);
|
|
949
969
|
const handleClick = (e) => {
|
|
950
970
|
e.preventDefault();
|
|
951
971
|
e.stopPropagation();
|
|
@@ -954,12 +974,20 @@ var ProfileToggleTheme = ({ ...props }) => {
|
|
|
954
974
|
const handleSave = () => {
|
|
955
975
|
setTheme(selectedTheme);
|
|
956
976
|
setModalThemeToggle(false);
|
|
977
|
+
setOpen(false);
|
|
978
|
+
};
|
|
979
|
+
const handleCancel = () => {
|
|
980
|
+
setSelectedTheme(themeMode);
|
|
981
|
+
setModalThemeToggle(false);
|
|
982
|
+
setOpen(false);
|
|
957
983
|
};
|
|
958
984
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
959
985
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
960
986
|
DropdownMenuItem,
|
|
961
987
|
{
|
|
962
988
|
variant: "profile",
|
|
989
|
+
preventClose: true,
|
|
990
|
+
store,
|
|
963
991
|
iconLeft: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
964
992
|
"svg",
|
|
965
993
|
{
|
|
@@ -994,19 +1022,12 @@ var ProfileToggleTheme = ({ ...props }) => {
|
|
|
994
1022
|
Modal_default,
|
|
995
1023
|
{
|
|
996
1024
|
isOpen: modalThemeToggle,
|
|
997
|
-
onClose:
|
|
1025
|
+
onClose: handleCancel,
|
|
998
1026
|
title: "Apar\xEAncia",
|
|
999
1027
|
size: "md",
|
|
1000
1028
|
footer: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex gap-3", children: [
|
|
1001
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1002
|
-
|
|
1003
|
-
{
|
|
1004
|
-
variant: "outline",
|
|
1005
|
-
onClick: () => setModalThemeToggle(false),
|
|
1006
|
-
children: "Cancelar"
|
|
1007
|
-
}
|
|
1008
|
-
),
|
|
1009
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button_default, { variant: "solid", onClick: () => handleSave(), children: "Salvar" })
|
|
1029
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button_default, { variant: "outline", onClick: handleCancel, children: "Cancelar" }),
|
|
1030
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button_default, { variant: "solid", onClick: handleSave, children: "Salvar" })
|
|
1010
1031
|
] }),
|
|
1011
1032
|
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-col", children: [
|
|
1012
1033
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-sm text-text-500", children: "Escolha o tema:" }),
|
|
@@ -1095,11 +1116,15 @@ var Search = (0, import_react6.forwardRef)(
|
|
|
1095
1116
|
value,
|
|
1096
1117
|
onChange,
|
|
1097
1118
|
placeholder = "Buscar...",
|
|
1119
|
+
onKeyDown: userOnKeyDown,
|
|
1098
1120
|
...props
|
|
1099
1121
|
}, ref) => {
|
|
1100
1122
|
const [dropdownOpen, setDropdownOpen] = (0, import_react6.useState)(false);
|
|
1123
|
+
const [forceClose, setForceClose] = (0, import_react6.useState)(false);
|
|
1124
|
+
const justSelectedRef = (0, import_react6.useRef)(false);
|
|
1101
1125
|
const dropdownStore = (0, import_react6.useRef)(createDropdownStore()).current;
|
|
1102
1126
|
const dropdownRef = (0, import_react6.useRef)(null);
|
|
1127
|
+
const inputElRef = (0, import_react6.useRef)(null);
|
|
1103
1128
|
const filteredOptions = (0, import_react6.useMemo)(() => {
|
|
1104
1129
|
if (!options.length) {
|
|
1105
1130
|
return [];
|
|
@@ -1107,24 +1132,35 @@ var Search = (0, import_react6.forwardRef)(
|
|
|
1107
1132
|
const filtered = filterOptions(options, value || "");
|
|
1108
1133
|
return filtered;
|
|
1109
1134
|
}, [options, value]);
|
|
1110
|
-
const showDropdown = controlledShowDropdown ?? (dropdownOpen && value && String(value).length > 0);
|
|
1135
|
+
const showDropdown = !forceClose && (controlledShowDropdown ?? (dropdownOpen && value && String(value).length > 0));
|
|
1136
|
+
const setOpenAndNotify = (open) => {
|
|
1137
|
+
setDropdownOpen(open);
|
|
1138
|
+
dropdownStore.setState({ open });
|
|
1139
|
+
onDropdownChange?.(open);
|
|
1140
|
+
};
|
|
1111
1141
|
(0, import_react6.useEffect)(() => {
|
|
1142
|
+
if (justSelectedRef.current) {
|
|
1143
|
+
justSelectedRef.current = false;
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
if (forceClose) {
|
|
1147
|
+
setOpenAndNotify(false);
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1112
1150
|
const shouldShow = Boolean(value && String(value).length > 0);
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
onDropdownChange?.(shouldShow);
|
|
1116
|
-
}, [value, onDropdownChange, dropdownStore]);
|
|
1151
|
+
setOpenAndNotify(shouldShow);
|
|
1152
|
+
}, [value, forceClose, onDropdownChange, dropdownStore]);
|
|
1117
1153
|
const handleSelectOption = (option) => {
|
|
1154
|
+
justSelectedRef.current = true;
|
|
1155
|
+
setForceClose(true);
|
|
1118
1156
|
onSelect?.(option);
|
|
1119
|
-
|
|
1120
|
-
dropdownStore.setState({ open: false });
|
|
1157
|
+
setOpenAndNotify(false);
|
|
1121
1158
|
updateInputValue(option, ref, onChange);
|
|
1122
1159
|
};
|
|
1123
1160
|
(0, import_react6.useEffect)(() => {
|
|
1124
1161
|
const handleClickOutside = (event) => {
|
|
1125
1162
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1126
|
-
|
|
1127
|
-
dropdownStore.setState({ open: false });
|
|
1163
|
+
setOpenAndNotify(false);
|
|
1128
1164
|
}
|
|
1129
1165
|
};
|
|
1130
1166
|
if (showDropdown) {
|
|
@@ -1133,9 +1169,10 @@ var Search = (0, import_react6.forwardRef)(
|
|
|
1133
1169
|
return () => {
|
|
1134
1170
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1135
1171
|
};
|
|
1136
|
-
}, [showDropdown, dropdownStore]);
|
|
1172
|
+
}, [showDropdown, dropdownStore, onDropdownChange]);
|
|
1137
1173
|
const generatedId = (0, import_react6.useId)();
|
|
1138
1174
|
const inputId = id ?? `search-${generatedId}`;
|
|
1175
|
+
const dropdownId = `${inputId}-dropdown`;
|
|
1139
1176
|
const handleClear = () => {
|
|
1140
1177
|
if (onClear) {
|
|
1141
1178
|
onClear();
|
|
@@ -1148,21 +1185,40 @@ var Search = (0, import_react6.forwardRef)(
|
|
|
1148
1185
|
e.stopPropagation();
|
|
1149
1186
|
handleClear();
|
|
1150
1187
|
};
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1188
|
+
const handleSearchIconClick = (e) => {
|
|
1189
|
+
e.preventDefault();
|
|
1190
|
+
e.stopPropagation();
|
|
1191
|
+
setTimeout(() => {
|
|
1192
|
+
inputElRef.current?.focus();
|
|
1193
|
+
}, 0);
|
|
1155
1194
|
};
|
|
1156
1195
|
const handleInputChange = (e) => {
|
|
1196
|
+
setForceClose(false);
|
|
1157
1197
|
onChange?.(e);
|
|
1158
1198
|
onSearch?.(e.target.value);
|
|
1159
1199
|
};
|
|
1200
|
+
const handleKeyDown = (e) => {
|
|
1201
|
+
userOnKeyDown?.(e);
|
|
1202
|
+
if (e.defaultPrevented) return;
|
|
1203
|
+
if (e.key === "Enter") {
|
|
1204
|
+
e.preventDefault();
|
|
1205
|
+
if (showDropdown && filteredOptions.length > 0) {
|
|
1206
|
+
handleSelectOption(filteredOptions[0]);
|
|
1207
|
+
} else if (value) {
|
|
1208
|
+
onSearch?.(String(value));
|
|
1209
|
+
setForceClose(true);
|
|
1210
|
+
setOpenAndNotify(false);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1160
1214
|
const getInputStateClasses = (disabled2, readOnly2) => {
|
|
1161
1215
|
if (disabled2) return "cursor-not-allowed opacity-40";
|
|
1162
1216
|
if (readOnly2) return "cursor-default focus:outline-none !text-text-900";
|
|
1163
1217
|
return "hover:border-border-400";
|
|
1164
1218
|
};
|
|
1165
|
-
const
|
|
1219
|
+
const hasValue = String(value ?? "").length > 0;
|
|
1220
|
+
const showClearButton = hasValue && !disabled && !readOnly;
|
|
1221
|
+
const showSearchIcon = !hasValue && !disabled && !readOnly;
|
|
1166
1222
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1167
1223
|
"div",
|
|
1168
1224
|
{
|
|
@@ -1170,30 +1226,30 @@ var Search = (0, import_react6.forwardRef)(
|
|
|
1170
1226
|
className: `w-full max-w-lg md:w-[488px] ${containerClassName}`,
|
|
1171
1227
|
children: [
|
|
1172
1228
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative flex items-center", children: [
|
|
1173
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute left-3 top-1/2 transform -translate-y-1/2", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1174
|
-
"button",
|
|
1175
|
-
{
|
|
1176
|
-
type: "button",
|
|
1177
|
-
className: "w-6 h-6 text-text-800 flex items-center justify-center bg-transparent border-0 p-0 cursor-pointer hover:text-text-600 transition-colors",
|
|
1178
|
-
onClick: handleLeftIconClick,
|
|
1179
|
-
"aria-label": "Voltar",
|
|
1180
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_phosphor_react4.CaretLeft, {})
|
|
1181
|
-
}
|
|
1182
|
-
) }),
|
|
1183
1229
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1184
1230
|
"input",
|
|
1185
1231
|
{
|
|
1186
|
-
ref
|
|
1232
|
+
ref: (node) => {
|
|
1233
|
+
if (ref) {
|
|
1234
|
+
if (typeof ref === "function") ref(node);
|
|
1235
|
+
else
|
|
1236
|
+
ref.current = node;
|
|
1237
|
+
}
|
|
1238
|
+
inputElRef.current = node;
|
|
1239
|
+
},
|
|
1187
1240
|
id: inputId,
|
|
1188
1241
|
type: "text",
|
|
1189
|
-
className: `w-full py-0 px-4
|
|
1242
|
+
className: `w-full py-0 px-4 pr-10 font-normal text-text-900 focus:outline-primary-950 border rounded-full bg-background focus:bg-primary-50 border-border-300 focus:border-2 focus:border-primary-950 h-10 placeholder:text-text-600 ${getInputStateClasses(disabled, readOnly)} ${className}`,
|
|
1190
1243
|
value,
|
|
1191
1244
|
onChange: handleInputChange,
|
|
1245
|
+
onKeyDown: handleKeyDown,
|
|
1192
1246
|
disabled,
|
|
1193
1247
|
readOnly,
|
|
1194
1248
|
placeholder,
|
|
1195
1249
|
"aria-expanded": showDropdown ? "true" : void 0,
|
|
1196
1250
|
"aria-haspopup": options.length > 0 ? "listbox" : void 0,
|
|
1251
|
+
"aria-controls": showDropdown ? dropdownId : void 0,
|
|
1252
|
+
"aria-autocomplete": "list",
|
|
1197
1253
|
role: options.length > 0 ? "combobox" : void 0,
|
|
1198
1254
|
...props
|
|
1199
1255
|
}
|
|
@@ -1207,11 +1263,22 @@ var Search = (0, import_react6.forwardRef)(
|
|
|
1207
1263
|
"aria-label": "Limpar busca",
|
|
1208
1264
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w-6 h-6 text-text-800 flex items-center justify-center hover:text-text-600 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_phosphor_react4.X, {}) })
|
|
1209
1265
|
}
|
|
1266
|
+
) }),
|
|
1267
|
+
showSearchIcon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute right-3 top-1/2 transform -translate-y-1/2", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1268
|
+
"button",
|
|
1269
|
+
{
|
|
1270
|
+
type: "button",
|
|
1271
|
+
className: "p-0 border-0 bg-transparent cursor-pointer",
|
|
1272
|
+
onMouseDown: handleSearchIconClick,
|
|
1273
|
+
"aria-label": "Buscar",
|
|
1274
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w-6 h-6 text-text-800 flex items-center justify-center hover:text-text-600 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_phosphor_react4.MagnifyingGlass, {}) })
|
|
1275
|
+
}
|
|
1210
1276
|
) })
|
|
1211
1277
|
] }),
|
|
1212
1278
|
showDropdown && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenu_default, { open: showDropdown, onOpenChange: setDropdownOpen, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1213
1279
|
DropdownMenuContent,
|
|
1214
1280
|
{
|
|
1281
|
+
id: dropdownId,
|
|
1215
1282
|
className: "w-full mt-1",
|
|
1216
1283
|
style: { maxHeight: dropdownMaxHeight },
|
|
1217
1284
|
align: "start",
|