pixelon 0.3.23 → 0.3.25

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
@@ -1620,6 +1620,130 @@ function parseContent(content) {
1620
1620
 
1621
1621
  const DISPLAY_COMPONENTS = /* @__PURE__ */ new Set(["card", "badge"]);
1622
1622
 
1623
+ const useAppHeight$5 = () => {
1624
+ useEffect(() => {
1625
+ const setDrawerHeight = () => {
1626
+ const fullViewportHeight = window.innerHeight;
1627
+ const documentHeight = document.documentElement.clientHeight;
1628
+ const drawerHeight = Math.max(fullViewportHeight, documentHeight);
1629
+ document.documentElement.style.setProperty(
1630
+ "--app-height",
1631
+ `${drawerHeight}px`
1632
+ );
1633
+ document.documentElement.style.setProperty(
1634
+ "--drawer-height",
1635
+ `${drawerHeight}px`
1636
+ );
1637
+ document.documentElement.style.setProperty(
1638
+ "--viewport-height",
1639
+ `${fullViewportHeight}px`
1640
+ );
1641
+ };
1642
+ setDrawerHeight();
1643
+ window.addEventListener("resize", setDrawerHeight);
1644
+ window.addEventListener("orientationchange", setDrawerHeight);
1645
+ document.addEventListener("fullscreenchange", setDrawerHeight);
1646
+ return () => {
1647
+ window.removeEventListener("resize", setDrawerHeight);
1648
+ window.removeEventListener("orientationchange", setDrawerHeight);
1649
+ document.removeEventListener("fullscreenchange", setDrawerHeight);
1650
+ };
1651
+ }, []);
1652
+ };
1653
+
1654
+ const Drawer$1 = ({
1655
+ isOpen,
1656
+ onClose,
1657
+ children,
1658
+ title,
1659
+ headerExtra,
1660
+ footer,
1661
+ showCloseButton = true,
1662
+ closeOnOverlayClick = true,
1663
+ closeOnEscape = true,
1664
+ className = ""
1665
+ }) => {
1666
+ const [visible, setVisible] = useState(false);
1667
+ const [animating, setAnimating] = useState(false);
1668
+ const contentRef = useRef(null);
1669
+ useAppHeight$5();
1670
+ useEffect(() => {
1671
+ if (isOpen) {
1672
+ setVisible(true);
1673
+ requestAnimationFrame(() => {
1674
+ requestAnimationFrame(() => setAnimating(true));
1675
+ });
1676
+ } else {
1677
+ setAnimating(false);
1678
+ const timer = setTimeout(() => setVisible(false), 300);
1679
+ return () => clearTimeout(timer);
1680
+ }
1681
+ }, [isOpen]);
1682
+ useEffect(() => {
1683
+ if (isOpen) {
1684
+ document.body.style.overflow = "hidden";
1685
+ return () => {
1686
+ document.body.style.overflow = "";
1687
+ };
1688
+ }
1689
+ }, [isOpen]);
1690
+ useEffect(() => {
1691
+ if (!isOpen || !closeOnEscape) return;
1692
+ const handleEscape = (e) => {
1693
+ if (e.key === "Escape") onClose();
1694
+ };
1695
+ document.addEventListener("keydown", handleEscape);
1696
+ return () => document.removeEventListener("keydown", handleEscape);
1697
+ }, [isOpen, onClose, closeOnEscape]);
1698
+ const handleOverlayClick = useCallback((e) => {
1699
+ if (e.target === e.currentTarget && closeOnOverlayClick) {
1700
+ onClose();
1701
+ }
1702
+ }, [onClose, closeOnOverlayClick]);
1703
+ if (!visible) return null;
1704
+ const prefix = COMPONENT_PREFIX$1;
1705
+ const overlayClasses = [
1706
+ `${prefix}drawer-overlay`,
1707
+ animating && `${prefix}drawer-overlay--visible`
1708
+ ].filter(Boolean).join(" ");
1709
+ const drawerClasses = [
1710
+ `${prefix}drawer`,
1711
+ animating && `${prefix}drawer--open`,
1712
+ className
1713
+ ].filter(Boolean).join(" ");
1714
+ return createPortal(
1715
+ /* @__PURE__ */ jsx("div", { className: overlayClasses, onClick: handleOverlayClick, children: /* @__PURE__ */ jsxs(
1716
+ "div",
1717
+ {
1718
+ className: drawerClasses,
1719
+ role: "dialog",
1720
+ "aria-modal": "true",
1721
+ "aria-labelledby": title ? `${prefix}drawer-title` : void 0,
1722
+ children: [
1723
+ (title || showCloseButton || headerExtra) && /* @__PURE__ */ jsxs("div", { className: `${prefix}drawer__header`, children: [
1724
+ title && /* @__PURE__ */ jsx("h2", { id: `${prefix}drawer-title`, className: `${prefix}drawer__title`, children: title }),
1725
+ headerExtra && /* @__PURE__ */ jsx("div", { className: `${prefix}drawer__header-extra`, children: headerExtra }),
1726
+ showCloseButton && /* @__PURE__ */ jsx(
1727
+ "button",
1728
+ {
1729
+ type: "button",
1730
+ className: `${prefix}drawer__close`,
1731
+ onClick: onClose,
1732
+ "aria-label": "Cerrar",
1733
+ children: "\u2715"
1734
+ }
1735
+ )
1736
+ ] }),
1737
+ /* @__PURE__ */ jsx("div", { ref: contentRef, className: `${prefix}drawer__content`, children }),
1738
+ footer && /* @__PURE__ */ jsx("div", { className: `${prefix}drawer__footer`, children: footer })
1739
+ ]
1740
+ }
1741
+ ) }),
1742
+ document.body
1743
+ );
1744
+ };
1745
+ Drawer$1.displayName = "Drawer";
1746
+
1623
1747
  function createEventBus() {
1624
1748
  const handlers = {};
1625
1749
  let externalBridge = null;
@@ -1650,6 +1774,7 @@ const CHAT_EVENT = {
1650
1774
  RETRY_MESSAGE: "retryMessage",
1651
1775
  PLACEHOLDER_UPDATED: "placeholderUpdated",
1652
1776
  THINKING_UPDATED: "thinkingUpdated",
1777
+ INPUT_DISABLED: "inputDisabled",
1653
1778
  CLOSE: "close"
1654
1779
  };
1655
1780
  const chatEventBus = createEventBus();
@@ -1677,20 +1802,167 @@ function useComponentInteraction({
1677
1802
  return { emitInteraction, isConfirmed };
1678
1803
  }
1679
1804
 
1805
+ const MOBILE_BREAKPOINT$3 = 640;
1806
+ const useIsMobile$4 = () => {
1807
+ const [isMobile, setIsMobile] = useState(
1808
+ typeof window !== "undefined" ? window.innerWidth < MOBILE_BREAKPOINT$3 : false
1809
+ );
1810
+ useEffect(() => {
1811
+ const mq = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT$3 - 1}px)`);
1812
+ const handler = (e) => setIsMobile(e.matches);
1813
+ mq.addEventListener("change", handler);
1814
+ return () => mq.removeEventListener("change", handler);
1815
+ }, []);
1816
+ return isMobile;
1817
+ };
1680
1818
  const SelectWithConfirm = ({
1681
1819
  component,
1682
1820
  eventBus,
1683
1821
  assistantMessageId = ""
1684
1822
  }) => {
1685
1823
  const [selected, setSelected] = useState(null);
1824
+ const [isDrawerOpen, setIsDrawerOpen] = useState(false);
1825
+ const [searchValue, setSearchValue] = useState("");
1826
+ const searchInputRef = useRef(null);
1827
+ const isMobile = useIsMobile$4();
1686
1828
  const { field_name, value, ...componentProps } = component.props;
1829
+ const options = componentProps.options || [];
1830
+ const placeholder = componentProps.placeholder || "Seleccionar...";
1831
+ const label = componentProps.label || "";
1687
1832
  const { emitInteraction, isConfirmed } = useComponentInteraction({
1688
1833
  eventBus,
1689
1834
  fieldName: component.props.field_name,
1690
1835
  componentType: component.type,
1691
1836
  assistantMessageId
1692
1837
  });
1838
+ const handleConfirm = () => {
1839
+ if (selected) {
1840
+ emitInteraction(selected.value, selected.label);
1841
+ setIsDrawerOpen(false);
1842
+ }
1843
+ };
1844
+ const filteredOptions = searchValue ? options.filter((opt) => opt.label.toLowerCase().includes(searchValue.toLowerCase())) : options;
1845
+ useEffect(() => {
1846
+ if (isDrawerOpen && searchInputRef.current) {
1847
+ setTimeout(() => searchInputRef.current?.focus(), 350);
1848
+ }
1849
+ }, [isDrawerOpen]);
1693
1850
  if (isConfirmed) return null;
1851
+ if (isMobile) {
1852
+ return /* @__PURE__ */ jsxs("div", { className: "px-chat-select-with-confirm", children: [
1853
+ label && /* @__PURE__ */ jsx("label", { className: "px-chat-select-with-confirm__label", children: label }),
1854
+ /* @__PURE__ */ jsxs(
1855
+ "div",
1856
+ {
1857
+ className: `px-chat-select-with-confirm__trigger ${isDrawerOpen ? "px-chat-select-with-confirm__trigger--open" : ""}`,
1858
+ onClick: () => setIsDrawerOpen(true),
1859
+ role: "button",
1860
+ tabIndex: 0,
1861
+ onKeyDown: (e) => {
1862
+ if (e.key === "Enter" || e.key === " ") setIsDrawerOpen(true);
1863
+ },
1864
+ children: [
1865
+ /* @__PURE__ */ jsx("span", { className: `px-chat-select-with-confirm__trigger-text ${!selected ? "px-chat-select-with-confirm__trigger-text--placeholder" : ""}`, children: selected ? selected.label : placeholder }),
1866
+ selected && /* @__PURE__ */ jsx(
1867
+ "button",
1868
+ {
1869
+ type: "button",
1870
+ className: "px-chat-select-with-confirm__clear",
1871
+ onClick: (e) => {
1872
+ e.stopPropagation();
1873
+ setSelected(null);
1874
+ },
1875
+ "aria-label": "Limpiar selecci\xF3n",
1876
+ children: /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CLOSE, size: "small" })
1877
+ }
1878
+ ),
1879
+ /* @__PURE__ */ jsx("span", { className: "px-chat-select-with-confirm__chevron", children: /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CHEVRON_DOWN, size: "small" }) })
1880
+ ]
1881
+ }
1882
+ ),
1883
+ /* @__PURE__ */ jsx(
1884
+ Button$1,
1885
+ {
1886
+ variant: "primary",
1887
+ size: "small",
1888
+ disabled: !selected,
1889
+ onClick: handleConfirm,
1890
+ children: "Confirmar"
1891
+ }
1892
+ ),
1893
+ /* @__PURE__ */ jsx(
1894
+ Drawer$1,
1895
+ {
1896
+ isOpen: isDrawerOpen,
1897
+ onClose: () => {
1898
+ setIsDrawerOpen(false);
1899
+ setSearchValue("");
1900
+ },
1901
+ title: label || placeholder,
1902
+ footer: /* @__PURE__ */ jsx(
1903
+ Button$1,
1904
+ {
1905
+ variant: "primary",
1906
+ size: "medium",
1907
+ disabled: !selected,
1908
+ onClick: handleConfirm,
1909
+ fullWidth: true,
1910
+ children: "Confirmar"
1911
+ }
1912
+ ),
1913
+ children: /* @__PURE__ */ jsxs("div", { className: "px-chat-select-drawer", children: [
1914
+ /* @__PURE__ */ jsxs("div", { className: "px-chat-select-drawer__search", children: [
1915
+ /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.SEARCH, size: "small" }),
1916
+ /* @__PURE__ */ jsx(
1917
+ "input",
1918
+ {
1919
+ ref: searchInputRef,
1920
+ type: "text",
1921
+ className: "px-chat-select-drawer__search-input",
1922
+ value: searchValue,
1923
+ onChange: (e) => setSearchValue(e.target.value),
1924
+ placeholder: "Buscar..."
1925
+ }
1926
+ ),
1927
+ searchValue && /* @__PURE__ */ jsx(
1928
+ "button",
1929
+ {
1930
+ type: "button",
1931
+ className: "px-chat-select-drawer__search-clear",
1932
+ onClick: () => setSearchValue(""),
1933
+ children: /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CLOSE, size: "small" })
1934
+ }
1935
+ )
1936
+ ] }),
1937
+ /* @__PURE__ */ jsx("ul", { className: "px-chat-select-drawer__options", role: "listbox", children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("li", { className: "px-chat-select-drawer__empty", children: "No hay opciones disponibles" }) : filteredOptions.map((option) => {
1938
+ const isSelected = selected?.value === option.value;
1939
+ return /* @__PURE__ */ jsxs(
1940
+ "li",
1941
+ {
1942
+ className: `px-chat-select-drawer__option ${isSelected ? "px-chat-select-drawer__option--selected" : ""} ${option.disabled ? "px-chat-select-drawer__option--disabled" : ""}`,
1943
+ onClick: () => {
1944
+ if (!option.disabled) {
1945
+ setSelected(option);
1946
+ setIsDrawerOpen(false);
1947
+ setSearchValue("");
1948
+ }
1949
+ },
1950
+ role: "option",
1951
+ "aria-selected": isSelected,
1952
+ children: [
1953
+ option.icon && /* @__PURE__ */ jsx("span", { className: "px-chat-select-drawer__option-icon", children: option.icon }),
1954
+ /* @__PURE__ */ jsx("span", { className: "px-chat-select-drawer__option-label", children: option.label }),
1955
+ isSelected && /* @__PURE__ */ jsx("span", { className: "px-chat-select-drawer__option-check", children: /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CHECK, size: "small" }) })
1956
+ ]
1957
+ },
1958
+ option.value
1959
+ );
1960
+ }) })
1961
+ ] })
1962
+ }
1963
+ )
1964
+ ] });
1965
+ }
1694
1966
  return /* @__PURE__ */ jsxs("div", { className: "px-chat-select-with-confirm", children: [
1695
1967
  /* @__PURE__ */ jsx(
1696
1968
  Select$2,
@@ -1699,6 +1971,7 @@ const SelectWithConfirm = ({
1699
1971
  ...componentProps,
1700
1972
  variant: "chat",
1701
1973
  mode: "single",
1974
+ showSearch: true,
1702
1975
  hideErrorSpace: true,
1703
1976
  allowClear: true,
1704
1977
  onClear: () => setSelected(null),
@@ -1711,27 +1984,185 @@ const SelectWithConfirm = ({
1711
1984
  variant: "primary",
1712
1985
  size: "small",
1713
1986
  disabled: !selected,
1714
- onClick: () => selected && emitInteraction(selected.value, selected.label),
1987
+ onClick: handleConfirm,
1715
1988
  children: "Confirmar"
1716
1989
  }
1717
1990
  )
1718
1991
  ] });
1719
1992
  };
1720
1993
 
1994
+ const MOBILE_BREAKPOINT$2 = 640;
1995
+ const useIsMobile$3 = () => {
1996
+ const [isMobile, setIsMobile] = useState(
1997
+ typeof window !== "undefined" ? window.innerWidth < MOBILE_BREAKPOINT$2 : false
1998
+ );
1999
+ useEffect(() => {
2000
+ const mq = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT$2 - 1}px)`);
2001
+ const handler = (e) => setIsMobile(e.matches);
2002
+ mq.addEventListener("change", handler);
2003
+ return () => mq.removeEventListener("change", handler);
2004
+ }, []);
2005
+ return isMobile;
2006
+ };
1721
2007
  const SelectMultipleWithConfirm = ({
1722
2008
  component,
1723
2009
  eventBus,
1724
2010
  assistantMessageId = ""
1725
2011
  }) => {
1726
2012
  const [selectedOptions, setSelectedOptions] = useState([]);
2013
+ const [isDrawerOpen, setIsDrawerOpen] = useState(false);
2014
+ const [searchValue, setSearchValue] = useState("");
2015
+ const searchInputRef = useRef(null);
2016
+ const isMobile = useIsMobile$3();
1727
2017
  const { field_name, value, ...componentProps } = component.props;
2018
+ const options = componentProps.options || [];
2019
+ const placeholder = componentProps.placeholder || "Seleccionar...";
2020
+ const label = componentProps.label || "";
1728
2021
  const { emitInteraction, isConfirmed } = useComponentInteraction({
1729
2022
  eventBus,
1730
2023
  fieldName: component.props.field_name,
1731
2024
  componentType: component.type,
1732
2025
  assistantMessageId
1733
2026
  });
2027
+ const handleConfirm = () => {
2028
+ if (selectedOptions.length > 0) {
2029
+ emitInteraction(
2030
+ selectedOptions.map((o) => o.value),
2031
+ selectedOptions.map((o) => o.label).join(", ")
2032
+ );
2033
+ setIsDrawerOpen(false);
2034
+ }
2035
+ };
2036
+ const toggleOption = (option) => {
2037
+ if (option.disabled) return;
2038
+ const isSelected = selectedOptions.some((sel) => sel.value === option.value);
2039
+ if (isSelected) {
2040
+ setSelectedOptions(selectedOptions.filter((sel) => sel.value !== option.value));
2041
+ } else {
2042
+ setSelectedOptions([...selectedOptions, option]);
2043
+ }
2044
+ };
2045
+ const filteredOptions = searchValue ? options.filter((opt) => opt.label.toLowerCase().includes(searchValue.toLowerCase())) : options;
2046
+ useEffect(() => {
2047
+ if (isDrawerOpen && searchInputRef.current) {
2048
+ setTimeout(() => searchInputRef.current?.focus(), 350);
2049
+ }
2050
+ }, [isDrawerOpen]);
1734
2051
  if (isConfirmed) return null;
2052
+ if (isMobile) {
2053
+ return /* @__PURE__ */ jsxs("div", { className: "px-chat-select-with-confirm", children: [
2054
+ label && /* @__PURE__ */ jsx("label", { className: "px-chat-select-with-confirm__label", children: label }),
2055
+ /* @__PURE__ */ jsxs(
2056
+ "div",
2057
+ {
2058
+ className: `px-chat-select-with-confirm__trigger ${isDrawerOpen ? "px-chat-select-with-confirm__trigger--open" : ""}`,
2059
+ onClick: () => setIsDrawerOpen(true),
2060
+ role: "button",
2061
+ tabIndex: 0,
2062
+ onKeyDown: (e) => {
2063
+ if (e.key === "Enter" || e.key === " ") setIsDrawerOpen(true);
2064
+ },
2065
+ children: [
2066
+ selectedOptions.length === 0 ? /* @__PURE__ */ jsx("span", { className: "px-chat-select-with-confirm__trigger-text px-chat-select-with-confirm__trigger-text--placeholder", children: placeholder }) : /* @__PURE__ */ jsx("div", { className: "px-chat-select-with-confirm__trigger-tags", children: selectedOptions.map((opt) => /* @__PURE__ */ jsxs("span", { className: "px-chat-select-with-confirm__trigger-tag", children: [
2067
+ opt.label,
2068
+ /* @__PURE__ */ jsx(
2069
+ "button",
2070
+ {
2071
+ type: "button",
2072
+ className: "px-chat-select-with-confirm__trigger-tag-remove",
2073
+ onClick: (e) => {
2074
+ e.stopPropagation();
2075
+ setSelectedOptions(selectedOptions.filter((s) => s.value !== opt.value));
2076
+ },
2077
+ "aria-label": `Quitar ${opt.label}`,
2078
+ children: /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CLOSE, size: "small" })
2079
+ }
2080
+ )
2081
+ ] }, opt.value)) }),
2082
+ /* @__PURE__ */ jsx("span", { className: "px-chat-select-with-confirm__chevron", children: /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CHEVRON_DOWN, size: "small" }) })
2083
+ ]
2084
+ }
2085
+ ),
2086
+ /* @__PURE__ */ jsx(
2087
+ Button$1,
2088
+ {
2089
+ variant: "primary",
2090
+ size: "small",
2091
+ disabled: selectedOptions.length === 0,
2092
+ onClick: handleConfirm,
2093
+ children: "Confirmar"
2094
+ }
2095
+ ),
2096
+ /* @__PURE__ */ jsx(
2097
+ Drawer$1,
2098
+ {
2099
+ isOpen: isDrawerOpen,
2100
+ onClose: () => {
2101
+ setIsDrawerOpen(false);
2102
+ setSearchValue("");
2103
+ },
2104
+ title: label || placeholder,
2105
+ footer: /* @__PURE__ */ jsxs(
2106
+ Button$1,
2107
+ {
2108
+ variant: "primary",
2109
+ size: "medium",
2110
+ disabled: selectedOptions.length === 0,
2111
+ onClick: handleConfirm,
2112
+ fullWidth: true,
2113
+ children: [
2114
+ "Confirmar",
2115
+ selectedOptions.length > 0 ? ` (${selectedOptions.length})` : ""
2116
+ ]
2117
+ }
2118
+ ),
2119
+ children: /* @__PURE__ */ jsxs("div", { className: "px-chat-select-drawer", children: [
2120
+ /* @__PURE__ */ jsxs("div", { className: "px-chat-select-drawer__search", children: [
2121
+ /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.SEARCH, size: "small" }),
2122
+ /* @__PURE__ */ jsx(
2123
+ "input",
2124
+ {
2125
+ ref: searchInputRef,
2126
+ type: "text",
2127
+ className: "px-chat-select-drawer__search-input",
2128
+ value: searchValue,
2129
+ onChange: (e) => setSearchValue(e.target.value),
2130
+ placeholder: "Buscar..."
2131
+ }
2132
+ ),
2133
+ searchValue && /* @__PURE__ */ jsx(
2134
+ "button",
2135
+ {
2136
+ type: "button",
2137
+ className: "px-chat-select-drawer__search-clear",
2138
+ onClick: () => setSearchValue(""),
2139
+ children: /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CLOSE, size: "small" })
2140
+ }
2141
+ )
2142
+ ] }),
2143
+ /* @__PURE__ */ jsx("ul", { className: "px-chat-select-drawer__options", role: "listbox", "aria-multiselectable": "true", children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("li", { className: "px-chat-select-drawer__empty", children: "No hay opciones disponibles" }) : filteredOptions.map((option) => {
2144
+ const isSelected = selectedOptions.some((sel) => sel.value === option.value);
2145
+ return /* @__PURE__ */ jsxs(
2146
+ "li",
2147
+ {
2148
+ className: `px-chat-select-drawer__option ${isSelected ? "px-chat-select-drawer__option--selected" : ""} ${option.disabled ? "px-chat-select-drawer__option--disabled" : ""}`,
2149
+ onClick: () => toggleOption(option),
2150
+ role: "option",
2151
+ "aria-selected": isSelected,
2152
+ children: [
2153
+ /* @__PURE__ */ jsx("span", { className: `px-chat-select-drawer__checkbox ${isSelected ? "px-chat-select-drawer__checkbox--checked" : ""}`, children: isSelected && /* @__PURE__ */ jsx(Icon$1, { type: ICON_TYPES.CHECK, size: "small" }) }),
2154
+ option.icon && /* @__PURE__ */ jsx("span", { className: "px-chat-select-drawer__option-icon", children: option.icon }),
2155
+ /* @__PURE__ */ jsx("span", { className: "px-chat-select-drawer__option-label", children: option.label })
2156
+ ]
2157
+ },
2158
+ option.value
2159
+ );
2160
+ }) })
2161
+ ] })
2162
+ }
2163
+ )
2164
+ ] });
2165
+ }
1735
2166
  return /* @__PURE__ */ jsxs("div", { className: "px-chat-select-with-confirm", children: [
1736
2167
  /* @__PURE__ */ jsx(
1737
2168
  Select$2,
@@ -1740,10 +2171,11 @@ const SelectMultipleWithConfirm = ({
1740
2171
  ...componentProps,
1741
2172
  variant: "chat",
1742
2173
  mode: "multiple",
2174
+ showSearch: true,
1743
2175
  hideErrorSpace: true,
1744
2176
  allowClear: true,
1745
2177
  onClear: () => setSelectedOptions([]),
1746
- onChangeMultiple: (_values, options) => setSelectedOptions(options)
2178
+ onChangeMultiple: (_values, opts) => setSelectedOptions(opts)
1747
2179
  }
1748
2180
  ),
1749
2181
  /* @__PURE__ */ jsx(
@@ -1752,10 +2184,7 @@ const SelectMultipleWithConfirm = ({
1752
2184
  variant: "primary",
1753
2185
  size: "small",
1754
2186
  disabled: selectedOptions.length === 0,
1755
- onClick: () => emitInteraction(
1756
- selectedOptions.map((o) => o.value),
1757
- selectedOptions.map((o) => o.label).join(", ")
1758
- ),
2187
+ onClick: handleConfirm,
1759
2188
  children: "Confirmar"
1760
2189
  }
1761
2190
  )
@@ -1809,130 +2238,6 @@ const InputWithConfirm = ({
1809
2238
  ] });
1810
2239
  };
1811
2240
 
1812
- const useAppHeight$5 = () => {
1813
- useEffect(() => {
1814
- const setDrawerHeight = () => {
1815
- const fullViewportHeight = window.innerHeight;
1816
- const documentHeight = document.documentElement.clientHeight;
1817
- const drawerHeight = Math.max(fullViewportHeight, documentHeight);
1818
- document.documentElement.style.setProperty(
1819
- "--app-height",
1820
- `${drawerHeight}px`
1821
- );
1822
- document.documentElement.style.setProperty(
1823
- "--drawer-height",
1824
- `${drawerHeight}px`
1825
- );
1826
- document.documentElement.style.setProperty(
1827
- "--viewport-height",
1828
- `${fullViewportHeight}px`
1829
- );
1830
- };
1831
- setDrawerHeight();
1832
- window.addEventListener("resize", setDrawerHeight);
1833
- window.addEventListener("orientationchange", setDrawerHeight);
1834
- document.addEventListener("fullscreenchange", setDrawerHeight);
1835
- return () => {
1836
- window.removeEventListener("resize", setDrawerHeight);
1837
- window.removeEventListener("orientationchange", setDrawerHeight);
1838
- document.removeEventListener("fullscreenchange", setDrawerHeight);
1839
- };
1840
- }, []);
1841
- };
1842
-
1843
- const Drawer$1 = ({
1844
- isOpen,
1845
- onClose,
1846
- children,
1847
- title,
1848
- headerExtra,
1849
- footer,
1850
- showCloseButton = true,
1851
- closeOnOverlayClick = true,
1852
- closeOnEscape = true,
1853
- className = ""
1854
- }) => {
1855
- const [visible, setVisible] = useState(false);
1856
- const [animating, setAnimating] = useState(false);
1857
- const contentRef = useRef(null);
1858
- useAppHeight$5();
1859
- useEffect(() => {
1860
- if (isOpen) {
1861
- setVisible(true);
1862
- requestAnimationFrame(() => {
1863
- requestAnimationFrame(() => setAnimating(true));
1864
- });
1865
- } else {
1866
- setAnimating(false);
1867
- const timer = setTimeout(() => setVisible(false), 300);
1868
- return () => clearTimeout(timer);
1869
- }
1870
- }, [isOpen]);
1871
- useEffect(() => {
1872
- if (isOpen) {
1873
- document.body.style.overflow = "hidden";
1874
- return () => {
1875
- document.body.style.overflow = "";
1876
- };
1877
- }
1878
- }, [isOpen]);
1879
- useEffect(() => {
1880
- if (!isOpen || !closeOnEscape) return;
1881
- const handleEscape = (e) => {
1882
- if (e.key === "Escape") onClose();
1883
- };
1884
- document.addEventListener("keydown", handleEscape);
1885
- return () => document.removeEventListener("keydown", handleEscape);
1886
- }, [isOpen, onClose, closeOnEscape]);
1887
- const handleOverlayClick = useCallback((e) => {
1888
- if (e.target === e.currentTarget && closeOnOverlayClick) {
1889
- onClose();
1890
- }
1891
- }, [onClose, closeOnOverlayClick]);
1892
- if (!visible) return null;
1893
- const prefix = COMPONENT_PREFIX$1;
1894
- const overlayClasses = [
1895
- `${prefix}drawer-overlay`,
1896
- animating && `${prefix}drawer-overlay--visible`
1897
- ].filter(Boolean).join(" ");
1898
- const drawerClasses = [
1899
- `${prefix}drawer`,
1900
- animating && `${prefix}drawer--open`,
1901
- className
1902
- ].filter(Boolean).join(" ");
1903
- return createPortal(
1904
- /* @__PURE__ */ jsx("div", { className: overlayClasses, onClick: handleOverlayClick, children: /* @__PURE__ */ jsxs(
1905
- "div",
1906
- {
1907
- className: drawerClasses,
1908
- role: "dialog",
1909
- "aria-modal": "true",
1910
- "aria-labelledby": title ? `${prefix}drawer-title` : void 0,
1911
- children: [
1912
- (title || showCloseButton || headerExtra) && /* @__PURE__ */ jsxs("div", { className: `${prefix}drawer__header`, children: [
1913
- title && /* @__PURE__ */ jsx("h2", { id: `${prefix}drawer-title`, className: `${prefix}drawer__title`, children: title }),
1914
- headerExtra && /* @__PURE__ */ jsx("div", { className: `${prefix}drawer__header-extra`, children: headerExtra }),
1915
- showCloseButton && /* @__PURE__ */ jsx(
1916
- "button",
1917
- {
1918
- type: "button",
1919
- className: `${prefix}drawer__close`,
1920
- onClick: onClose,
1921
- "aria-label": "Cerrar",
1922
- children: "\u2715"
1923
- }
1924
- )
1925
- ] }),
1926
- /* @__PURE__ */ jsx("div", { ref: contentRef, className: `${prefix}drawer__content`, children }),
1927
- footer && /* @__PURE__ */ jsx("div", { className: `${prefix}drawer__footer`, children: footer })
1928
- ]
1929
- }
1930
- ) }),
1931
- document.body
1932
- );
1933
- };
1934
- Drawer$1.displayName = "Drawer";
1935
-
1936
2241
  const CHAT_CONFIG_DEFAULTS = {
1937
2242
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
1938
2243
  locale: "es-ES",
@@ -3527,12 +3832,6 @@ const thinkingActions = {
3527
3832
  hide: () => setChatStore(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR, { visible: false }),
3528
3833
  setThinking: (isThinking) => {
3529
3834
  setChatStore(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR, { visible: isThinking });
3530
- if (isThinking) {
3531
- chatInputActions.setSendDisabled(true);
3532
- } else {
3533
- const currentInput = chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT);
3534
- chatInputActions.updateButtonVisibility(currentInput.hasText, currentInput.hasAttachments);
3535
- }
3536
3835
  }
3537
3836
  };
3538
3837
  const scrollButtonActions = {
@@ -4545,9 +4844,9 @@ const useChatHandlers = ({
4545
4844
  clearAttachments,
4546
4845
  scrollToLastUserMessage
4547
4846
  }) => {
4548
- const isThinking = () => chatStore.get(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR).visible;
4847
+ const isInputDisabled = () => chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT).buttonSend.disabled;
4549
4848
  const handleSendWithFiles = (content, files) => {
4550
- if (isThinking()) return;
4849
+ if (isInputDisabled()) return;
4551
4850
  if (!content.trim() && (!files || files.length === 0)) return;
4552
4851
  combinedActions.handleMessageSend();
4553
4852
  onSend(content, files);
@@ -4558,7 +4857,7 @@ const useChatHandlers = ({
4558
4857
  const handleInputKeyDown = (e, inputValue, attachments) => {
4559
4858
  if (e.key === "Enter" && !e.shiftKey) {
4560
4859
  e.preventDefault();
4561
- if (isThinking()) return;
4860
+ if (isInputDisabled()) return;
4562
4861
  handleSendWithFiles(inputValue, attachments);
4563
4862
  }
4564
4863
  };
@@ -4895,12 +5194,21 @@ const Chat = ({
4895
5194
  const unsubComponent = eventBus.on(CHAT_EVENT.COMPONENT_INTERACTION, () => {
4896
5195
  scrollToTopActions.activate();
4897
5196
  });
5197
+ const unsubInputDisabled = eventBus.on(CHAT_EVENT.INPUT_DISABLED, ({ disabled }) => {
5198
+ if (disabled) {
5199
+ chatInputActions.setSendDisabled(true);
5200
+ } else {
5201
+ const { hasText, hasAttachments } = chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT);
5202
+ chatInputActions.updateButtonVisibility(hasText, hasAttachments);
5203
+ }
5204
+ });
4898
5205
  return () => {
4899
5206
  unsubMessages();
4900
5207
  unsubHeader();
4901
5208
  unsubPlaceholder();
4902
5209
  unsubThinking();
4903
5210
  unsubComponent();
5211
+ unsubInputDisabled();
4904
5212
  };
4905
5213
  }, [eventBus]);
4906
5214
  const handleSend = (content, files) => {
@@ -4985,33 +5293,37 @@ const Chat = ({
4985
5293
  ref: messagesContainerRef,
4986
5294
  onClick: handleMainClick,
4987
5295
  children: [
4988
- messageGroups.map((group, groupIndex) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
4989
- /* @__PURE__ */ jsx(DateDivider, { date: group.date }),
4990
- group.messages.map((msg, msgIndex) => {
4991
- const key = msg.id ?? `${groupIndex}-${msgIndex}`;
4992
- return msg.role === "user" ? /* @__PURE__ */ jsx(
4993
- UserMessage,
4994
- {
4995
- content: msg.content,
4996
- timestamp: msg.timestamp,
4997
- status: msg.status,
4998
- onRetry: msg.status === "failed" ? () => handleRetry(msg) : void 0,
4999
- files: msg.files
5000
- },
5001
- key
5002
- ) : /* @__PURE__ */ jsx(
5003
- AssistantMessage,
5004
- {
5005
- content: msg.content,
5006
- timestamp: msg.timestamp,
5007
- files: msg.files,
5008
- eventBus,
5009
- messageId: msg.id
5010
- },
5011
- key
5012
- );
5013
- })
5014
- ] }, `${group.date.getTime()}-${groupIndex}`)),
5296
+ messageGroups.map((group, groupIndex) => {
5297
+ const isToday = group.date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
5298
+ const showDivider = !(messageGroups.length === 1 && isToday);
5299
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
5300
+ showDivider && /* @__PURE__ */ jsx(DateDivider, { date: group.date }),
5301
+ group.messages.map((msg, msgIndex) => {
5302
+ const key = msg.id ?? `${groupIndex}-${msgIndex}`;
5303
+ return msg.role === "user" ? /* @__PURE__ */ jsx(
5304
+ UserMessage,
5305
+ {
5306
+ content: msg.content,
5307
+ timestamp: msg.timestamp,
5308
+ status: msg.status,
5309
+ onRetry: msg.status === "failed" ? () => handleRetry(msg) : void 0,
5310
+ files: msg.files
5311
+ },
5312
+ key
5313
+ ) : /* @__PURE__ */ jsx(
5314
+ AssistantMessage,
5315
+ {
5316
+ content: msg.content,
5317
+ timestamp: msg.timestamp,
5318
+ files: msg.files,
5319
+ eventBus,
5320
+ messageId: msg.id
5321
+ },
5322
+ key
5323
+ );
5324
+ })
5325
+ ] }, `${group.date.getTime()}-${groupIndex}`);
5326
+ }),
5015
5327
  showThinking && /* @__PURE__ */ jsx(AssistantThinkingIndicator, {}),
5016
5328
  /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
5017
5329
  ]