pesona-ui 1.0.18 → 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.cjs.js CHANGED
@@ -8590,13 +8590,11 @@ const SelectMultiple = React.forwardRef(({ name, label, selectLabel, floatingLab
8590
8590
  });
8591
8591
  SelectMultiple.displayName = 'SelectMultiple';
8592
8592
 
8593
- const SelectWithSearch = React.forwardRef(({ name, label, selectLabel, size = 'md', floatingLabel = false, error, options, value = '', onChange, required, disabled, selectSearch, handleOptionSearch, }, ref) => {
8593
+ const SelectWithSearch = React.forwardRef(({ name, label, selectLabel, size = 'md', floatingLabel = false, error, options = [], value = '', onChange, required, disabled, selectSearch = '', setSelectSearch, isLoading = false, }, ref) => {
8594
8594
  const [isOpen, setIsOpen] = React.useState(false);
8595
- const [selectedValue, setSelectedValue] = React.useState(value || '');
8596
8595
  const dropdownRef = React.useRef(null);
8597
8596
  const dropdownOptionsRef = React.useRef(null);
8598
8597
  const handleOptionClick = (optionValue) => {
8599
- setSelectedValue(optionValue);
8600
8598
  if (onChange) {
8601
8599
  onChange({
8602
8600
  target: { name, value: optionValue },
@@ -8604,25 +8602,19 @@ const SelectWithSearch = React.forwardRef(({ name, label, selectLabel, size = 'm
8604
8602
  }
8605
8603
  setIsOpen(false);
8606
8604
  };
8607
- useOutsideClick([dropdownRef], () => {
8608
- setIsOpen(false);
8609
- });
8605
+ useOutsideClick([dropdownRef], () => setIsOpen(false));
8610
8606
  useDropdownPositionAndScroll(isOpen, dropdownOptionsRef);
8611
8607
  React.useEffect(() => {
8612
- return () => {
8613
- setIsOpen(false);
8614
- };
8608
+ return () => setIsOpen(false);
8615
8609
  }, []);
8616
- // useEffect for value
8617
- React.useEffect(() => {
8618
- setSelectedValue(value);
8619
- }, [value]);
8620
- const displayText = selectedValue
8621
- ? options.find((option) => option.value === selectedValue)?.label
8610
+ const displayText = value
8611
+ ? options.find((option) => option.value === value)?.label
8622
8612
  : selectLabel || 'Select an option';
8613
+ console.log(isLoading);
8623
8614
  return (React.createElement(React.Fragment, null,
8624
8615
  label && !floatingLabel && (React.createElement("label", { htmlFor: name },
8625
8616
  label,
8617
+ " ",
8626
8618
  required && React.createElement("span", { className: "text-danger" }, "*"))),
8627
8619
  React.createElement("div", { className: `dropdown-select-container ${size}`, ref: dropdownRef },
8628
8620
  React.createElement("div", { className: `dropdown-header ${isOpen ? 'open' : ''} ${disabled ? 'disabled' : ''}`, onClick: () => !disabled && setIsOpen(!isOpen), ref: ref, "aria-haspopup": "listbox", "aria-expanded": isOpen },
@@ -8630,12 +8622,11 @@ const SelectWithSearch = React.forwardRef(({ name, label, selectLabel, size = 'm
8630
8622
  React.createElement(FiChevronDown, { className: "arrow" })),
8631
8623
  isOpen && (React.createElement("div", { className: `dropdown-options scrollbar ${disabled ? 'disabled' : ''}`, ref: dropdownOptionsRef, role: "listbox" },
8632
8624
  React.createElement("div", { className: "search-input" },
8633
- 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) => {
8634
- handleOptionSearch(e.currentTarget.value);
8635
- } })),
8636
- 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"))))),
8625
+ 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) })),
8626
+ 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))))))),
8637
8627
  label && floatingLabel && (React.createElement("label", { htmlFor: name },
8638
8628
  label,
8629
+ " ",
8639
8630
  required && React.createElement("span", { className: "text-danger" }, "*"))),
8640
8631
  error && React.createElement("small", { className: "form-message" }, error)));
8641
8632
  });