analytica-frontend-lib 1.1.72 → 1.1.73
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/Search/index.js +73 -27
- package/dist/Search/index.js.map +1 -1
- package/dist/Search/index.mjs +74 -28
- package/dist/Search/index.mjs.map +1 -1
- package/dist/index.js +73 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1815,7 +1815,7 @@ var Input = forwardRef9(
|
|
|
1815
1815
|
var Input_default = Input;
|
|
1816
1816
|
|
|
1817
1817
|
// src/components/Search/Search.tsx
|
|
1818
|
-
import {
|
|
1818
|
+
import { X as X3, MagnifyingGlass } from "phosphor-react";
|
|
1819
1819
|
import {
|
|
1820
1820
|
forwardRef as forwardRef11,
|
|
1821
1821
|
useState as useState7,
|
|
@@ -2731,11 +2731,15 @@ var Search = forwardRef11(
|
|
|
2731
2731
|
value,
|
|
2732
2732
|
onChange,
|
|
2733
2733
|
placeholder = "Buscar...",
|
|
2734
|
+
onKeyDown: userOnKeyDown,
|
|
2734
2735
|
...props
|
|
2735
2736
|
}, ref) => {
|
|
2736
2737
|
const [dropdownOpen, setDropdownOpen] = useState7(false);
|
|
2738
|
+
const [forceClose, setForceClose] = useState7(false);
|
|
2739
|
+
const justSelectedRef = useRef4(false);
|
|
2737
2740
|
const dropdownStore = useRef4(createDropdownStore()).current;
|
|
2738
2741
|
const dropdownRef = useRef4(null);
|
|
2742
|
+
const inputElRef = useRef4(null);
|
|
2739
2743
|
const filteredOptions = useMemo2(() => {
|
|
2740
2744
|
if (!options.length) {
|
|
2741
2745
|
return [];
|
|
@@ -2743,24 +2747,35 @@ var Search = forwardRef11(
|
|
|
2743
2747
|
const filtered = filterOptions(options, value || "");
|
|
2744
2748
|
return filtered;
|
|
2745
2749
|
}, [options, value]);
|
|
2746
|
-
const showDropdown = controlledShowDropdown ?? (dropdownOpen && value && String(value).length > 0);
|
|
2750
|
+
const showDropdown = !forceClose && (controlledShowDropdown ?? (dropdownOpen && value && String(value).length > 0));
|
|
2751
|
+
const setOpenAndNotify = (open) => {
|
|
2752
|
+
setDropdownOpen(open);
|
|
2753
|
+
dropdownStore.setState({ open });
|
|
2754
|
+
onDropdownChange?.(open);
|
|
2755
|
+
};
|
|
2747
2756
|
useEffect7(() => {
|
|
2757
|
+
if (justSelectedRef.current) {
|
|
2758
|
+
justSelectedRef.current = false;
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
if (forceClose) {
|
|
2762
|
+
setOpenAndNotify(false);
|
|
2763
|
+
return;
|
|
2764
|
+
}
|
|
2748
2765
|
const shouldShow = Boolean(value && String(value).length > 0);
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
onDropdownChange?.(shouldShow);
|
|
2752
|
-
}, [value, onDropdownChange, dropdownStore]);
|
|
2766
|
+
setOpenAndNotify(shouldShow);
|
|
2767
|
+
}, [value, forceClose, onDropdownChange, dropdownStore]);
|
|
2753
2768
|
const handleSelectOption = (option) => {
|
|
2769
|
+
justSelectedRef.current = true;
|
|
2770
|
+
setForceClose(true);
|
|
2754
2771
|
onSelect?.(option);
|
|
2755
|
-
|
|
2756
|
-
dropdownStore.setState({ open: false });
|
|
2772
|
+
setOpenAndNotify(false);
|
|
2757
2773
|
updateInputValue(option, ref, onChange);
|
|
2758
2774
|
};
|
|
2759
2775
|
useEffect7(() => {
|
|
2760
2776
|
const handleClickOutside = (event) => {
|
|
2761
2777
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
2762
|
-
|
|
2763
|
-
dropdownStore.setState({ open: false });
|
|
2778
|
+
setOpenAndNotify(false);
|
|
2764
2779
|
}
|
|
2765
2780
|
};
|
|
2766
2781
|
if (showDropdown) {
|
|
@@ -2769,9 +2784,10 @@ var Search = forwardRef11(
|
|
|
2769
2784
|
return () => {
|
|
2770
2785
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
2771
2786
|
};
|
|
2772
|
-
}, [showDropdown, dropdownStore]);
|
|
2787
|
+
}, [showDropdown, dropdownStore, onDropdownChange]);
|
|
2773
2788
|
const generatedId = useId7();
|
|
2774
2789
|
const inputId = id ?? `search-${generatedId}`;
|
|
2790
|
+
const dropdownId = `${inputId}-dropdown`;
|
|
2775
2791
|
const handleClear = () => {
|
|
2776
2792
|
if (onClear) {
|
|
2777
2793
|
onClear();
|
|
@@ -2784,21 +2800,40 @@ var Search = forwardRef11(
|
|
|
2784
2800
|
e.stopPropagation();
|
|
2785
2801
|
handleClear();
|
|
2786
2802
|
};
|
|
2787
|
-
const
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2803
|
+
const handleSearchIconClick = (e) => {
|
|
2804
|
+
e.preventDefault();
|
|
2805
|
+
e.stopPropagation();
|
|
2806
|
+
setTimeout(() => {
|
|
2807
|
+
inputElRef.current?.focus();
|
|
2808
|
+
}, 0);
|
|
2791
2809
|
};
|
|
2792
2810
|
const handleInputChange = (e) => {
|
|
2811
|
+
setForceClose(false);
|
|
2793
2812
|
onChange?.(e);
|
|
2794
2813
|
onSearch?.(e.target.value);
|
|
2795
2814
|
};
|
|
2815
|
+
const handleKeyDown = (e) => {
|
|
2816
|
+
userOnKeyDown?.(e);
|
|
2817
|
+
if (e.defaultPrevented) return;
|
|
2818
|
+
if (e.key === "Enter") {
|
|
2819
|
+
e.preventDefault();
|
|
2820
|
+
if (showDropdown && filteredOptions.length > 0) {
|
|
2821
|
+
handleSelectOption(filteredOptions[0]);
|
|
2822
|
+
} else if (value) {
|
|
2823
|
+
onSearch?.(String(value));
|
|
2824
|
+
setForceClose(true);
|
|
2825
|
+
setOpenAndNotify(false);
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
};
|
|
2796
2829
|
const getInputStateClasses = (disabled2, readOnly2) => {
|
|
2797
2830
|
if (disabled2) return "cursor-not-allowed opacity-40";
|
|
2798
2831
|
if (readOnly2) return "cursor-default focus:outline-none !text-text-900";
|
|
2799
2832
|
return "hover:border-border-400";
|
|
2800
2833
|
};
|
|
2801
|
-
const
|
|
2834
|
+
const hasValue = String(value ?? "").length > 0;
|
|
2835
|
+
const showClearButton = hasValue && !disabled && !readOnly;
|
|
2836
|
+
const showSearchIcon = !hasValue && !disabled && !readOnly;
|
|
2802
2837
|
return /* @__PURE__ */ jsxs14(
|
|
2803
2838
|
"div",
|
|
2804
2839
|
{
|
|
@@ -2806,30 +2841,30 @@ var Search = forwardRef11(
|
|
|
2806
2841
|
className: `w-full max-w-lg md:w-[488px] ${containerClassName}`,
|
|
2807
2842
|
children: [
|
|
2808
2843
|
/* @__PURE__ */ jsxs14("div", { className: "relative flex items-center", children: [
|
|
2809
|
-
/* @__PURE__ */ jsx21("div", { className: "absolute left-3 top-1/2 transform -translate-y-1/2", children: /* @__PURE__ */ jsx21(
|
|
2810
|
-
"button",
|
|
2811
|
-
{
|
|
2812
|
-
type: "button",
|
|
2813
|
-
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",
|
|
2814
|
-
onClick: handleLeftIconClick,
|
|
2815
|
-
"aria-label": "Voltar",
|
|
2816
|
-
children: /* @__PURE__ */ jsx21(CaretLeft, {})
|
|
2817
|
-
}
|
|
2818
|
-
) }),
|
|
2819
2844
|
/* @__PURE__ */ jsx21(
|
|
2820
2845
|
"input",
|
|
2821
2846
|
{
|
|
2822
|
-
ref
|
|
2847
|
+
ref: (node) => {
|
|
2848
|
+
if (ref) {
|
|
2849
|
+
if (typeof ref === "function") ref(node);
|
|
2850
|
+
else
|
|
2851
|
+
ref.current = node;
|
|
2852
|
+
}
|
|
2853
|
+
inputElRef.current = node;
|
|
2854
|
+
},
|
|
2823
2855
|
id: inputId,
|
|
2824
2856
|
type: "text",
|
|
2825
|
-
className: `w-full py-0 px-4
|
|
2857
|
+
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}`,
|
|
2826
2858
|
value,
|
|
2827
2859
|
onChange: handleInputChange,
|
|
2860
|
+
onKeyDown: handleKeyDown,
|
|
2828
2861
|
disabled,
|
|
2829
2862
|
readOnly,
|
|
2830
2863
|
placeholder,
|
|
2831
2864
|
"aria-expanded": showDropdown ? "true" : void 0,
|
|
2832
2865
|
"aria-haspopup": options.length > 0 ? "listbox" : void 0,
|
|
2866
|
+
"aria-controls": showDropdown ? dropdownId : void 0,
|
|
2867
|
+
"aria-autocomplete": "list",
|
|
2833
2868
|
role: options.length > 0 ? "combobox" : void 0,
|
|
2834
2869
|
...props
|
|
2835
2870
|
}
|
|
@@ -2843,11 +2878,22 @@ var Search = forwardRef11(
|
|
|
2843
2878
|
"aria-label": "Limpar busca",
|
|
2844
2879
|
children: /* @__PURE__ */ jsx21("span", { className: "w-6 h-6 text-text-800 flex items-center justify-center hover:text-text-600 transition-colors", children: /* @__PURE__ */ jsx21(X3, {}) })
|
|
2845
2880
|
}
|
|
2881
|
+
) }),
|
|
2882
|
+
showSearchIcon && /* @__PURE__ */ jsx21("div", { className: "absolute right-3 top-1/2 transform -translate-y-1/2", children: /* @__PURE__ */ jsx21(
|
|
2883
|
+
"button",
|
|
2884
|
+
{
|
|
2885
|
+
type: "button",
|
|
2886
|
+
className: "p-0 border-0 bg-transparent cursor-pointer",
|
|
2887
|
+
onMouseDown: handleSearchIconClick,
|
|
2888
|
+
"aria-label": "Buscar",
|
|
2889
|
+
children: /* @__PURE__ */ jsx21("span", { className: "w-6 h-6 text-text-800 flex items-center justify-center hover:text-text-600 transition-colors", children: /* @__PURE__ */ jsx21(MagnifyingGlass, {}) })
|
|
2890
|
+
}
|
|
2846
2891
|
) })
|
|
2847
2892
|
] }),
|
|
2848
2893
|
showDropdown && /* @__PURE__ */ jsx21(DropdownMenu_default, { open: showDropdown, onOpenChange: setDropdownOpen, children: /* @__PURE__ */ jsx21(
|
|
2849
2894
|
DropdownMenuContent,
|
|
2850
2895
|
{
|
|
2896
|
+
id: dropdownId,
|
|
2851
2897
|
className: "w-full mt-1",
|
|
2852
2898
|
style: { maxHeight: dropdownMaxHeight },
|
|
2853
2899
|
align: "start",
|
|
@@ -7046,7 +7092,7 @@ import {
|
|
|
7046
7092
|
cloneElement as cloneElement6,
|
|
7047
7093
|
useState as useState14
|
|
7048
7094
|
} from "react";
|
|
7049
|
-
import { CaretLeft
|
|
7095
|
+
import { CaretLeft, CaretRight as CaretRight4 } from "phosphor-react";
|
|
7050
7096
|
import { jsx as jsx41, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
7051
7097
|
var createMenuStore = (onValueChange) => create7((set) => ({
|
|
7052
7098
|
value: "",
|
|
@@ -7312,7 +7358,7 @@ var MenuOverflow = ({
|
|
|
7312
7358
|
className: "absolute left-0 top-1/2 -translate-y-1/2 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-white shadow-md cursor-pointer",
|
|
7313
7359
|
"data-testid": "scroll-left-button",
|
|
7314
7360
|
children: [
|
|
7315
|
-
/* @__PURE__ */ jsx41(
|
|
7361
|
+
/* @__PURE__ */ jsx41(CaretLeft, { size: 16 }),
|
|
7316
7362
|
/* @__PURE__ */ jsx41("span", { className: "sr-only", children: "Scroll left" })
|
|
7317
7363
|
]
|
|
7318
7364
|
}
|
|
@@ -8795,7 +8841,7 @@ function useApiConfig(api) {
|
|
|
8795
8841
|
// src/components/Quiz/Quiz.tsx
|
|
8796
8842
|
import {
|
|
8797
8843
|
BookOpen,
|
|
8798
|
-
CaretLeft as
|
|
8844
|
+
CaretLeft as CaretLeft2,
|
|
8799
8845
|
CaretRight as CaretRight5,
|
|
8800
8846
|
Clock as Clock2,
|
|
8801
8847
|
SquaresFour
|
|
@@ -10255,7 +10301,7 @@ var QuizTitle = forwardRef20(
|
|
|
10255
10301
|
/* @__PURE__ */ jsx48(
|
|
10256
10302
|
IconButton_default,
|
|
10257
10303
|
{
|
|
10258
|
-
icon: /* @__PURE__ */ jsx48(
|
|
10304
|
+
icon: /* @__PURE__ */ jsx48(CaretLeft2, { size: 24 }),
|
|
10259
10305
|
size: "md",
|
|
10260
10306
|
"aria-label": "Voltar",
|
|
10261
10307
|
onClick: handleBackClick
|
|
@@ -10512,7 +10558,7 @@ var QuizFooter = forwardRef20(
|
|
|
10512
10558
|
size: "medium",
|
|
10513
10559
|
variant: "link",
|
|
10514
10560
|
action: "primary",
|
|
10515
|
-
iconLeft: /* @__PURE__ */ jsx48(
|
|
10561
|
+
iconLeft: /* @__PURE__ */ jsx48(CaretLeft2, { size: 18 }),
|
|
10516
10562
|
onClick: () => {
|
|
10517
10563
|
goToPreviousQuestion();
|
|
10518
10564
|
},
|