@giro-ds/react 3.0.2 → 3.0.4
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.cjs +29 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +29 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -685,8 +685,19 @@ const TextField = forwardRef(({ className, value = '', label, placeholder, type
|
|
|
685
685
|
const generatedId = useId();
|
|
686
686
|
const componentId = id || generatedId;
|
|
687
687
|
useEffect(() => {
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
const newValue = normalizeValue(value);
|
|
689
|
+
setInputValue(newValue);
|
|
690
|
+
// Reavaliar erro quando valor muda externamente (ex: DatePicker atualiza o campo)
|
|
691
|
+
if (inputError) {
|
|
692
|
+
const error = validateInput({
|
|
693
|
+
value: newValue,
|
|
694
|
+
maxLength,
|
|
695
|
+
errorMessage,
|
|
696
|
+
required,
|
|
697
|
+
});
|
|
698
|
+
setInputError(error);
|
|
699
|
+
}
|
|
700
|
+
}, [value, inputError, type, maxLength, errorMessage, required]);
|
|
690
701
|
const handleChange = useCallback((e) => {
|
|
691
702
|
const newValue = e.target.value;
|
|
692
703
|
if (!disabled && (!maxLength || newValue.length <= maxLength)) {
|
|
@@ -2531,7 +2542,7 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
|
|
|
2531
2542
|
}
|
|
2532
2543
|
}, [state.isOpen, enableApiSearch, onApiSearch]);
|
|
2533
2544
|
useEffect(() => {
|
|
2534
|
-
if (enableApiSearch && state.
|
|
2545
|
+
if (enableApiSearch && state.isOpen) {
|
|
2535
2546
|
if (lastSearchTermRef.current !== state.searchTerm) {
|
|
2536
2547
|
debouncedApiSearch(state.searchTerm);
|
|
2537
2548
|
}
|
|
@@ -2722,25 +2733,28 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
2722
2733
|
maxWidth: maxWidth ? `${maxWidth}px` : undefined,
|
|
2723
2734
|
}), [maxWidth]);
|
|
2724
2735
|
const handleSearchChange = (e) => {
|
|
2725
|
-
|
|
2736
|
+
const value = e.target.value;
|
|
2737
|
+
actions.setSearchInput(value);
|
|
2738
|
+
if (enableApiSearch) {
|
|
2739
|
+
actions.setSearchTerm(value);
|
|
2740
|
+
}
|
|
2726
2741
|
};
|
|
2727
2742
|
const handleSearchKeyDown = (e) => {
|
|
2743
|
+
const isNavigationKey = ['ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'].includes(e.key);
|
|
2744
|
+
if (!isNavigationKey) {
|
|
2745
|
+
e.stopPropagation();
|
|
2746
|
+
return;
|
|
2747
|
+
}
|
|
2728
2748
|
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
if (!hasSelection) {
|
|
2732
|
-
e.preventDefault();
|
|
2733
|
-
return;
|
|
2734
|
-
}
|
|
2749
|
+
e.currentTarget.blur();
|
|
2750
|
+
return;
|
|
2735
2751
|
}
|
|
2736
2752
|
if (e.key === 'Enter') {
|
|
2737
|
-
e.
|
|
2738
|
-
|
|
2739
|
-
actions.setSearchTerm(state.searchInput);
|
|
2753
|
+
e.currentTarget.blur();
|
|
2754
|
+
return;
|
|
2740
2755
|
}
|
|
2741
|
-
if (e.key === 'Escape') {
|
|
2756
|
+
else if (e.key === 'Escape') {
|
|
2742
2757
|
e.preventDefault();
|
|
2743
|
-
e.stopPropagation();
|
|
2744
2758
|
actions.resetSearch();
|
|
2745
2759
|
}
|
|
2746
2760
|
};
|