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