erp-pos-ecommerce-shared 0.2.11 → 0.2.12

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.
@@ -1,8 +1,8 @@
1
1
  import React$1, { ReactNode } from 'react';
2
- import { e as IField, b as IButton } from './form.interface-D72rc8aa.js';
2
+ import { e as IField, b as IButton } from './form.interface-91Dz2oFr.js';
3
3
  import { ReactFormExtendedApi, FormValidateOrFn, FormAsyncValidateOrFn } from '@tanstack/react-form';
4
4
  import { UseMutationResult, UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
5
- import { v as TblProductsImage, r as ITableFilterConfig, j as IFilterSelectOption } from './filters.interface-C9rkI_yn.js';
5
+ import { v as TblProductsImage, r as ITableFilterConfig, j as IFilterSelectOption } from './filters.interface-BwMi9FRP.js';
6
6
  import * as z from 'zod';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
8
  import { ColumnDef, useReactTable, Row } from '@tanstack/react-table';
@@ -215,8 +215,10 @@ interface FilterSelectProps {
215
215
  placeholder?: string;
216
216
  /** Icon to show in the button */
217
217
  Icon?: React.ElementType;
218
+ /** Enable search input inside dropdown */
219
+ searchable?: boolean;
218
220
  }
219
- declare const FilterSelect: ({ columnId, options, onChange, placeholder, Icon, }: FilterSelectProps) => react_jsx_runtime.JSX.Element;
221
+ declare const FilterSelect: ({ columnId, options, onChange, placeholder, Icon, searchable, }: FilterSelectProps) => react_jsx_runtime.JSX.Element;
220
222
 
221
223
  interface SearchInputProps {
222
224
  value: string;
@@ -1747,10 +1747,19 @@ var FilterSelect = ({
1747
1747
  options,
1748
1748
  onChange,
1749
1749
  placeholder = "Todos",
1750
- Icon = ListFilter
1750
+ Icon = ListFilter,
1751
+ searchable = false
1751
1752
  }) => {
1752
1753
  const [open, setOpen] = useState(false);
1753
1754
  const [selectedOption, setSelectedOption] = useState(null);
1755
+ const [search, setSearch] = useState("");
1756
+ const searchRef = useRef(null);
1757
+ const filteredOptions = useMemo(
1758
+ () => searchable && search ? options.filter(
1759
+ (o) => o.label.toLowerCase().includes(search.toLowerCase())
1760
+ ) : options,
1761
+ [options, search, searchable]
1762
+ );
1754
1763
  const handleClear = () => {
1755
1764
  setSelectedOption(null);
1756
1765
  onChange(columnId, null);
@@ -1768,7 +1777,15 @@ var FilterSelect = ({
1768
1777
  Menu,
1769
1778
  {
1770
1779
  opened: open,
1771
- onChange: setOpen,
1780
+ onChange: (opened) => {
1781
+ setOpen(opened);
1782
+ if (!opened) {
1783
+ setSearch("");
1784
+ }
1785
+ },
1786
+ onOpen: () => {
1787
+ setTimeout(() => searchRef.current?.focus(), 50);
1788
+ },
1772
1789
  styles: {
1773
1790
  dropdown: {
1774
1791
  minWidth: 180
@@ -1807,17 +1824,31 @@ var FilterSelect = ({
1807
1824
  children: selectedOption ? selectedOption.label : placeholder
1808
1825
  }
1809
1826
  ) }),
1810
- /* @__PURE__ */ jsx(Menu.Dropdown, { children: options.map((option) => /* @__PURE__ */ jsx(
1811
- Menu.Item,
1812
- {
1813
- leftSection: selectedOption?.value === option.value ? /* @__PURE__ */ jsx(Check, { size: 12 }) : null,
1814
- onClick: () => {
1815
- handleSelect(option);
1827
+ /* @__PURE__ */ jsxs(Menu.Dropdown, { children: [
1828
+ searchable && /* @__PURE__ */ jsx(
1829
+ TextInput,
1830
+ {
1831
+ ref: searchRef,
1832
+ variant: "unstyled",
1833
+ placeholder: "Buscar...",
1834
+ leftSection: /* @__PURE__ */ jsx(Search, { size: 14 }),
1835
+ value: search,
1836
+ onChange: (e) => setSearch(e.currentTarget.value)
1837
+ }
1838
+ ),
1839
+ filteredOptions.map((option) => /* @__PURE__ */ jsx(
1840
+ Menu.Item,
1841
+ {
1842
+ leftSection: selectedOption?.value === option.value ? /* @__PURE__ */ jsx(Check, { size: 12 }) : null,
1843
+ onClick: () => {
1844
+ handleSelect(option);
1845
+ },
1846
+ children: option.label
1816
1847
  },
1817
- children: option.label
1818
- },
1819
- option.value
1820
- )) })
1848
+ option.value
1849
+ )),
1850
+ searchable && filteredOptions.length === 0 && /* @__PURE__ */ jsx(Menu.Item, { disabled: true, children: "Sin resultados" })
1851
+ ] })
1821
1852
  ]
1822
1853
  }
1823
1854
  );
@@ -1982,7 +2013,8 @@ var DataTable = ({
1982
2013
  columnId: f.columnId,
1983
2014
  options: f.options ?? [],
1984
2015
  onChange: setColumnFilter,
1985
- placeholder: f.placeholder ?? "Todos"
2016
+ placeholder: f.placeholder ?? "Todos",
2017
+ searchable: f.searchable
1986
2018
  },
1987
2019
  f.columnId
1988
2020
  )