cr-ui-lib 1.1.96 → 1.1.99

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
@@ -250,9 +250,10 @@ declare type SingleSelectDropdownProps = {
250
250
  iconClass?: string;
251
251
  displayContainerClass?: string;
252
252
  selectedColorDropdownItem?: string;
253
+ uniqueSearch?: boolean;
253
254
  };
254
255
  declare function SingleSelectDropdown({ label, value, onChange, options, placeholder, onScrollToEnd, onSearch, hasMore, isLoading, searchable, searchDebounceMs, requiresSearch, minSearchLength, emptyMessage, loadingMessage, searchPlaceholder, disabled, hasIcon, buttonClass, labelClass, displayItemClass, displayMainClass, hasSearchIcon, searchInputClass, placeholderSearchClass, usePortal, // default true
255
- iconClass, placeholderClass, displayContainerClass, selectedColorDropdownItem, }: SingleSelectDropdownProps): JSX.Element;
256
+ iconClass, placeholderClass, displayContainerClass, selectedColorDropdownItem, uniqueSearch, }: SingleSelectDropdownProps): JSX.Element;
256
257
 
257
258
  interface SelectionButton {
258
259
  data: string[];
package/dist/index.d.ts CHANGED
@@ -250,9 +250,10 @@ declare type SingleSelectDropdownProps = {
250
250
  iconClass?: string;
251
251
  displayContainerClass?: string;
252
252
  selectedColorDropdownItem?: string;
253
+ uniqueSearch?: boolean;
253
254
  };
254
255
  declare function SingleSelectDropdown({ label, value, onChange, options, placeholder, onScrollToEnd, onSearch, hasMore, isLoading, searchable, searchDebounceMs, requiresSearch, minSearchLength, emptyMessage, loadingMessage, searchPlaceholder, disabled, hasIcon, buttonClass, labelClass, displayItemClass, displayMainClass, hasSearchIcon, searchInputClass, placeholderSearchClass, usePortal, // default true
255
- iconClass, placeholderClass, displayContainerClass, selectedColorDropdownItem, }: SingleSelectDropdownProps): JSX.Element;
256
+ iconClass, placeholderClass, displayContainerClass, selectedColorDropdownItem, uniqueSearch, }: SingleSelectDropdownProps): JSX.Element;
256
257
 
257
258
  interface SelectionButton {
258
259
  data: string[];
package/dist/index.js CHANGED
@@ -3484,7 +3484,8 @@ function SingleSelectDropdown({
3484
3484
  iconClass = "",
3485
3485
  placeholderClass = "",
3486
3486
  displayContainerClass = "",
3487
- selectedColorDropdownItem = "text-[#131414]"
3487
+ selectedColorDropdownItem = "text-[#131414]",
3488
+ uniqueSearch = false
3488
3489
  }) {
3489
3490
  const [isOpen, setIsOpen] = React.useState(false);
3490
3491
  const [searchTerm, setSearchTerm] = React.useState("");
@@ -3613,6 +3614,11 @@ function SingleSelectDropdown({
3613
3614
  setIsOpen(!isOpen);
3614
3615
  }
3615
3616
  };
3617
+ const openList = () => {
3618
+ if (!disabled) {
3619
+ setIsOpen(true);
3620
+ }
3621
+ };
3616
3622
  const DropdownMenu = /* @__PURE__ */ jsxRuntime.jsx(
3617
3623
  "div",
3618
3624
  {
@@ -3652,7 +3658,9 @@ function SingleSelectDropdown({
3652
3658
  searchInputClass
3653
3659
  ),
3654
3660
  value: searchTerm,
3655
- onChange: (e) => handleSearchChange(e.target.value)
3661
+ onChange: (e) => {
3662
+ handleSearchChange(e.target.value);
3663
+ }
3656
3664
  }
3657
3665
  ),
3658
3666
  !searchTerm && /* @__PURE__ */ jsxRuntime.jsx(
@@ -3692,6 +3700,15 @@ function SingleSelectDropdown({
3692
3700
  }
3693
3701
  )
3694
3702
  ] }),
3703
+ uniqueSearch && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsx(
3704
+ "div",
3705
+ {
3706
+ className: tailwindMerge.twMerge(
3707
+ "absolute right-2 top-1/2 transform -translate-y-1/2 pointer-events-none",
3708
+ hasSearchIcon ? "block" : "hidden"
3709
+ )
3710
+ }
3711
+ ) }),
3695
3712
  /* @__PURE__ */ jsxRuntime.jsxs(
3696
3713
  "div",
3697
3714
  {
@@ -3708,12 +3725,15 @@ function SingleSelectDropdown({
3708
3725
  "div",
3709
3726
  {
3710
3727
  className: tailwindMerge.twMerge(
3711
- `h-[40px] px-2 py-2 my-1 text-sm cursor-pointer select-none rounded-md hover:bg-gray-100 ${opt.id === value ? "bg-[#ECF3F7] font-semibold " + selectedColorDropdownItem : "text-[#131414]"}`,
3728
+ `h-[40px] px-2 py-2 my-1 text-sm cursor-pointer select-none rounded-md hover:bg-gray-100 ${opt.id === value ? "bg-[#ECF3F7] font-semibold" + selectedColorDropdownItem : "text-[#131414]"}`,
3712
3729
  displayItemClass
3713
3730
  ),
3714
3731
  onClick: () => {
3715
3732
  onChange(opt.id);
3716
3733
  setIsOpen(false);
3734
+ if (uniqueSearch) {
3735
+ setSearchTerm("");
3736
+ }
3717
3737
  },
3718
3738
  children: opt.name
3719
3739
  },
@@ -3744,7 +3764,7 @@ function SingleSelectDropdown({
3744
3764
  }
3745
3765
  ),
3746
3766
  /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: dropdownRef, className: "relative", children: [
3747
- /* @__PURE__ */ jsxRuntime.jsxs(
3767
+ !uniqueSearch ? /* @__PURE__ */ jsxRuntime.jsxs(
3748
3768
  "div",
3749
3769
  {
3750
3770
  onClick: handleToggle,
@@ -3796,6 +3816,21 @@ function SingleSelectDropdown({
3796
3816
  )
3797
3817
  ]
3798
3818
  }
3819
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
3820
+ "input",
3821
+ {
3822
+ type: "text",
3823
+ autoFocus: true,
3824
+ onClick: openList,
3825
+ className: tailwindMerge.twMerge(
3826
+ "input-placeholder-ellipsis w-full pr-[30px] h-[40px] px-2 py-1 rounded-md border border-gray-300 text-sm focus:border-1 focus:border-[#4683B4] focus:outline-none",
3827
+ searchInputClass,
3828
+ uniqueSearch && "placeholder:opacity-100 placeholder:text-[#131414]"
3829
+ ),
3830
+ value: searchTerm,
3831
+ placeholder: (selectedOption == null ? void 0 : selectedOption.name) || placeholder,
3832
+ onChange: (e) => handleSearchChange(e.target.value)
3833
+ }
3799
3834
  ),
3800
3835
  isOpen && !disabled && (usePortal ? reactDom.createPortal(DropdownMenu, document.body) : DropdownMenu)
3801
3836
  ] })