@charlesgomes/leafcode-shared-lib-react 1.0.72 → 1.0.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/index.d.mts CHANGED
@@ -102,7 +102,7 @@ interface PaginatedResponse$1 {
102
102
  interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
103
103
  name: string;
104
104
  label?: string;
105
- value?: string | number | readonly string[] | undefined;
105
+ value?: string;
106
106
  onChange?: (value: any) => void;
107
107
  onSelect: (item: any) => void;
108
108
  error?: FieldError;
package/dist/index.d.ts CHANGED
@@ -102,7 +102,7 @@ interface PaginatedResponse$1 {
102
102
  interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
103
103
  name: string;
104
104
  label?: string;
105
- value?: string | number | readonly string[] | undefined;
105
+ value?: string;
106
106
  onChange?: (value: any) => void;
107
107
  onSelect: (item: any) => void;
108
108
  error?: FieldError;
package/dist/index.js CHANGED
@@ -723,6 +723,7 @@ var InputBase3 = ({
723
723
  error,
724
724
  onChange,
725
725
  onSelect,
726
+ value,
726
727
  defaultValue,
727
728
  inputAutocompleteActive,
728
729
  queryKey,
@@ -750,7 +751,6 @@ var InputBase3 = ({
750
751
  "--input-height": theme.components.input.sizes.height,
751
752
  "--input-border-radius": theme.components.input.sizes.radius
752
753
  };
753
- const [value, setValue] = (0, import_react12.useState)("");
754
754
  const [items, setItems] = (0, import_react12.useState)([]);
755
755
  const [pageNumber, setPageNumber] = (0, import_react12.useState)(1);
756
756
  const [search, setSearch] = (0, import_react12.useState)("");
@@ -770,24 +770,11 @@ var InputBase3 = ({
770
770
  (0, import_react12.useEffect)(() => {
771
771
  const debounced = import_lodash2.default.debounce(() => {
772
772
  setPageNumber(1);
773
- setItems([]);
774
- setSearch(value);
773
+ setSearch(value ?? "");
775
774
  }, 600);
776
775
  debounced();
777
776
  return () => debounced.cancel();
778
777
  }, [value]);
779
- (0, import_react12.useEffect)(() => {
780
- if (!defaultValue) return;
781
- setValue(defaultValue.label ?? defaultValue);
782
- }, [defaultValue]);
783
- (0, import_react12.useEffect)(() => {
784
- if (typeof rest.value === "string") {
785
- setValue(rest.value);
786
- }
787
- if (rest.value === null || rest.value === void 0) {
788
- setValue("");
789
- }
790
- }, [rest.value]);
791
778
  const handleScroll = () => {
792
779
  if (!listRef.current || !data) return;
793
780
  const { scrollTop, clientHeight, scrollHeight } = listRef.current;
@@ -796,7 +783,7 @@ var InputBase3 = ({
796
783
  }
797
784
  };
798
785
  const handleSelect = (item) => {
799
- setValue(item.nome);
786
+ onChange?.(item.nome);
800
787
  setIsOpen(false);
801
788
  onSelect(item);
802
789
  };
@@ -848,7 +835,6 @@ var InputBase3 = ({
848
835
  value: value ?? "",
849
836
  onChange: (e) => {
850
837
  const val = e.target.value;
851
- setValue(val);
852
838
  onChange?.(val);
853
839
  setIsOpen(true);
854
840
  },
@@ -861,8 +847,6 @@ var InputBase3 = ({
861
847
  {
862
848
  type: "button",
863
849
  onClick: () => {
864
- setValue("");
865
- setItems([]);
866
850
  setPageNumber(1);
867
851
  onChange?.("");
868
852
  onSelect(null);
package/dist/index.mjs CHANGED
@@ -673,6 +673,7 @@ var InputBase3 = ({
673
673
  error,
674
674
  onChange,
675
675
  onSelect,
676
+ value,
676
677
  defaultValue,
677
678
  inputAutocompleteActive,
678
679
  queryKey,
@@ -700,7 +701,6 @@ var InputBase3 = ({
700
701
  "--input-height": theme.components.input.sizes.height,
701
702
  "--input-border-radius": theme.components.input.sizes.radius
702
703
  };
703
- const [value, setValue] = useState4("");
704
704
  const [items, setItems] = useState4([]);
705
705
  const [pageNumber, setPageNumber] = useState4(1);
706
706
  const [search, setSearch] = useState4("");
@@ -720,24 +720,11 @@ var InputBase3 = ({
720
720
  useEffect4(() => {
721
721
  const debounced = _.debounce(() => {
722
722
  setPageNumber(1);
723
- setItems([]);
724
- setSearch(value);
723
+ setSearch(value ?? "");
725
724
  }, 600);
726
725
  debounced();
727
726
  return () => debounced.cancel();
728
727
  }, [value]);
729
- useEffect4(() => {
730
- if (!defaultValue) return;
731
- setValue(defaultValue.label ?? defaultValue);
732
- }, [defaultValue]);
733
- useEffect4(() => {
734
- if (typeof rest.value === "string") {
735
- setValue(rest.value);
736
- }
737
- if (rest.value === null || rest.value === void 0) {
738
- setValue("");
739
- }
740
- }, [rest.value]);
741
728
  const handleScroll = () => {
742
729
  if (!listRef.current || !data) return;
743
730
  const { scrollTop, clientHeight, scrollHeight } = listRef.current;
@@ -746,7 +733,7 @@ var InputBase3 = ({
746
733
  }
747
734
  };
748
735
  const handleSelect = (item) => {
749
- setValue(item.nome);
736
+ onChange?.(item.nome);
750
737
  setIsOpen(false);
751
738
  onSelect(item);
752
739
  };
@@ -798,7 +785,6 @@ var InputBase3 = ({
798
785
  value: value ?? "",
799
786
  onChange: (e) => {
800
787
  const val = e.target.value;
801
- setValue(val);
802
788
  onChange?.(val);
803
789
  setIsOpen(true);
804
790
  },
@@ -811,8 +797,6 @@ var InputBase3 = ({
811
797
  {
812
798
  type: "button",
813
799
  onClick: () => {
814
- setValue("");
815
- setItems([]);
816
800
  setPageNumber(1);
817
801
  onChange?.("");
818
802
  onSelect(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charlesgomes/leafcode-shared-lib-react",
3
- "version": "1.0.72",
3
+ "version": "1.0.74",
4
4
  "description": "Lib de componentes react",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",