pesona-ui 1.0.19 → 1.0.20

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.esm.js CHANGED
@@ -8588,13 +8588,11 @@ const SelectMultiple = forwardRef(({ name, label, selectLabel, floatingLabel = f
8588
8588
  });
8589
8589
  SelectMultiple.displayName = 'SelectMultiple';
8590
8590
 
8591
- const SelectWithSearch = forwardRef(({ name, label, selectLabel, size = 'md', floatingLabel = false, error, options, value = '', onChange, required, disabled, selectSearch, handleOptionSearch, }, ref) => {
8591
+ const SelectWithSearch = forwardRef(({ name, label, selectLabel, size = 'md', floatingLabel = false, error, options = [], value = '', onChange, required, disabled, selectSearch = '', setSelectSearch, isLoading = false, }, ref) => {
8592
8592
  const [isOpen, setIsOpen] = useState(false);
8593
- const [selectedValue, setSelectedValue] = useState(value || '');
8594
8593
  const dropdownRef = useRef(null);
8595
8594
  const dropdownOptionsRef = useRef(null);
8596
8595
  const handleOptionClick = (optionValue) => {
8597
- setSelectedValue(optionValue);
8598
8596
  if (onChange) {
8599
8597
  onChange({
8600
8598
  target: { name, value: optionValue },
@@ -8602,25 +8600,19 @@ const SelectWithSearch = forwardRef(({ name, label, selectLabel, size = 'md', fl
8602
8600
  }
8603
8601
  setIsOpen(false);
8604
8602
  };
8605
- useOutsideClick([dropdownRef], () => {
8606
- setIsOpen(false);
8607
- });
8603
+ useOutsideClick([dropdownRef], () => setIsOpen(false));
8608
8604
  useDropdownPositionAndScroll(isOpen, dropdownOptionsRef);
8609
8605
  useEffect(() => {
8610
- return () => {
8611
- setIsOpen(false);
8612
- };
8606
+ return () => setIsOpen(false);
8613
8607
  }, []);
8614
- // useEffect for value
8615
- useEffect(() => {
8616
- setSelectedValue(value);
8617
- }, [value]);
8618
- const displayText = selectedValue
8619
- ? options.find((option) => option.value === selectedValue)?.label
8608
+ const displayText = value
8609
+ ? options.find((option) => option.value === value)?.label
8620
8610
  : selectLabel || 'Select an option';
8611
+ console.log(isLoading);
8621
8612
  return (React.createElement(React.Fragment, null,
8622
8613
  label && !floatingLabel && (React.createElement("label", { htmlFor: name },
8623
8614
  label,
8615
+ " ",
8624
8616
  required && React.createElement("span", { className: "text-danger" }, "*"))),
8625
8617
  React.createElement("div", { className: `dropdown-select-container ${size}`, ref: dropdownRef },
8626
8618
  React.createElement("div", { className: `dropdown-header ${isOpen ? 'open' : ''} ${disabled ? 'disabled' : ''}`, onClick: () => !disabled && setIsOpen(!isOpen), ref: ref, "aria-haspopup": "listbox", "aria-expanded": isOpen },
@@ -8628,12 +8620,11 @@ const SelectWithSearch = forwardRef(({ name, label, selectLabel, size = 'md', fl
8628
8620
  React.createElement(FiChevronDown, { className: "arrow" })),
8629
8621
  isOpen && (React.createElement("div", { className: `dropdown-options scrollbar ${disabled ? 'disabled' : ''}`, ref: dropdownOptionsRef, role: "listbox" },
8630
8622
  React.createElement("div", { className: "search-input" },
8631
- React.createElement(Input, { name: "search", placeholder: "Ketik untuk mencari..", type: "search", tabIndex: 0, autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: false, role: "textbox", value: selectSearch, autoFocus: true, onChange: (e) => {
8632
- handleOptionSearch(e.currentTarget.value);
8633
- } })),
8634
- options.length > 0 ? (options.map((option, index) => (React.createElement("div", { key: `${option.value}-${index}`, className: `option ${selectedValue === option.value ? 'selected' : ''}`, onClick: () => !disabled && handleOptionClick(option.value), role: "option", "aria-selected": selectedValue === option.value }, option.label)))) : (React.createElement("div", { className: "option disabled", role: "option" }, "No results found"))))),
8623
+ React.createElement(Input, { name: "search", placeholder: "Ketik untuk mencari..", type: "search", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: false, role: "textbox", value: selectSearch, autoFocus: true, onChange: (e) => setSelectSearch && setSelectSearch(e.currentTarget.value) })),
8624
+ isLoading ? (React.createElement("div", { className: "loading-indicator" }, "Loading options...")) : options.length === 0 ? (React.createElement("div", { className: "empty-message" }, "Tidak ada hasil ditemukan")) : (options.map((option) => (React.createElement("div", { key: String(option.value), className: `option ${value === option.value ? 'selected' : ''}`, onClick: () => !disabled && handleOptionClick(String(option.value)), role: "option", "aria-selected": value === option.value }, option.label))))))),
8635
8625
  label && floatingLabel && (React.createElement("label", { htmlFor: name },
8636
8626
  label,
8627
+ " ",
8637
8628
  required && React.createElement("span", { className: "text-danger" }, "*"))),
8638
8629
  error && React.createElement("small", { className: "form-message" }, error)));
8639
8630
  });