@charlesgomes/leafcode-shared-lib-react 1.0.71 → 1.0.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/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)("");
@@ -771,15 +771,11 @@ var InputBase3 = ({
771
771
  const debounced = import_lodash2.default.debounce(() => {
772
772
  setPageNumber(1);
773
773
  setItems([]);
774
- setSearch(value);
774
+ setSearch(value ?? "");
775
775
  }, 600);
776
776
  debounced();
777
777
  return () => debounced.cancel();
778
778
  }, [value]);
779
- (0, import_react12.useEffect)(() => {
780
- if (!defaultValue) return;
781
- setValue(defaultValue.label ?? defaultValue);
782
- }, [defaultValue]);
783
779
  const handleScroll = () => {
784
780
  if (!listRef.current || !data) return;
785
781
  const { scrollTop, clientHeight, scrollHeight } = listRef.current;
@@ -788,7 +784,7 @@ var InputBase3 = ({
788
784
  }
789
785
  };
790
786
  const handleSelect = (item) => {
791
- setValue(item.nome);
787
+ onChange?.(item.nome);
792
788
  setIsOpen(false);
793
789
  onSelect(item);
794
790
  };
@@ -814,7 +810,9 @@ var InputBase3 = ({
814
810
  className: "input-wrapper",
815
811
  style: styleVars,
816
812
  tabIndex: -1,
817
- onBlur: (e) => e.relatedTarget === null && setIsOpen(false),
813
+ onBlur: (e) => {
814
+ e.relatedTarget === null && setIsOpen(false);
815
+ },
818
816
  children: [
819
817
  label && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
820
818
  "label",
@@ -835,10 +833,10 @@ var InputBase3 = ({
835
833
  placeholder,
836
834
  autoComplete: "off",
837
835
  className: "input",
838
- value,
836
+ value: value ?? "",
839
837
  onChange: (e) => {
840
- setValue(e.target.value);
841
- onChange?.(e.target.value);
838
+ const val = e.target.value;
839
+ onChange?.(val);
842
840
  setIsOpen(true);
843
841
  },
844
842
  onFocus: () => setIsOpen(true),
@@ -850,10 +848,9 @@ var InputBase3 = ({
850
848
  {
851
849
  type: "button",
852
850
  onClick: () => {
853
- setValue("");
854
851
  setItems([]);
855
852
  setPageNumber(1);
856
- onChange?.(null);
853
+ onChange?.("");
857
854
  onSelect(null);
858
855
  },
859
856
  className: "dropdown-clear",
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("");
@@ -721,15 +721,11 @@ var InputBase3 = ({
721
721
  const debounced = _.debounce(() => {
722
722
  setPageNumber(1);
723
723
  setItems([]);
724
- setSearch(value);
724
+ setSearch(value ?? "");
725
725
  }, 600);
726
726
  debounced();
727
727
  return () => debounced.cancel();
728
728
  }, [value]);
729
- useEffect4(() => {
730
- if (!defaultValue) return;
731
- setValue(defaultValue.label ?? defaultValue);
732
- }, [defaultValue]);
733
729
  const handleScroll = () => {
734
730
  if (!listRef.current || !data) return;
735
731
  const { scrollTop, clientHeight, scrollHeight } = listRef.current;
@@ -738,7 +734,7 @@ var InputBase3 = ({
738
734
  }
739
735
  };
740
736
  const handleSelect = (item) => {
741
- setValue(item.nome);
737
+ onChange?.(item.nome);
742
738
  setIsOpen(false);
743
739
  onSelect(item);
744
740
  };
@@ -764,7 +760,9 @@ var InputBase3 = ({
764
760
  className: "input-wrapper",
765
761
  style: styleVars,
766
762
  tabIndex: -1,
767
- onBlur: (e) => e.relatedTarget === null && setIsOpen(false),
763
+ onBlur: (e) => {
764
+ e.relatedTarget === null && setIsOpen(false);
765
+ },
768
766
  children: [
769
767
  label && /* @__PURE__ */ jsx10(
770
768
  "label",
@@ -785,10 +783,10 @@ var InputBase3 = ({
785
783
  placeholder,
786
784
  autoComplete: "off",
787
785
  className: "input",
788
- value,
786
+ value: value ?? "",
789
787
  onChange: (e) => {
790
- setValue(e.target.value);
791
- onChange?.(e.target.value);
788
+ const val = e.target.value;
789
+ onChange?.(val);
792
790
  setIsOpen(true);
793
791
  },
794
792
  onFocus: () => setIsOpen(true),
@@ -800,10 +798,9 @@ var InputBase3 = ({
800
798
  {
801
799
  type: "button",
802
800
  onClick: () => {
803
- setValue("");
804
801
  setItems([]);
805
802
  setPageNumber(1);
806
- onChange?.(null);
803
+ onChange?.("");
807
804
  onSelect(null);
808
805
  },
809
806
  className: "dropdown-clear",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charlesgomes/leafcode-shared-lib-react",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "Lib de componentes react",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",