@mieweb/ui 0.8.0-dev.8 → 0.8.0-dev.9

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 CHANGED
@@ -55,7 +55,7 @@ var chunkPLMXN23Q_cjs = require('./chunk-PLMXN23Q.cjs');
55
55
  var chunkRS5VA6QU_cjs = require('./chunk-RS5VA6QU.cjs');
56
56
  var chunkJMZF7ZHF_cjs = require('./chunk-JMZF7ZHF.cjs');
57
57
  var chunkZO4L6C2Y_cjs = require('./chunk-ZO4L6C2Y.cjs');
58
- var chunkH7QSGFMZ_cjs = require('./chunk-H7QSGFMZ.cjs');
58
+ var chunkVKNCQIVN_cjs = require('./chunk-VKNCQIVN.cjs');
59
59
  var chunk3TXOFAXP_cjs = require('./chunk-3TXOFAXP.cjs');
60
60
  require('./chunk-VBWRH4UW.cjs');
61
61
  var chunkI2ECTLON_cjs = require('./chunk-I2ECTLON.cjs');
@@ -64,7 +64,7 @@ var chunk7AECNMYV_cjs = require('./chunk-7AECNMYV.cjs');
64
64
  var chunkN5O47VGS_cjs = require('./chunk-N5O47VGS.cjs');
65
65
  var chunkX4LBUPJO_cjs = require('./chunk-X4LBUPJO.cjs');
66
66
  var chunkIUDY6S7I_cjs = require('./chunk-IUDY6S7I.cjs');
67
- var chunkV2NEANVH_cjs = require('./chunk-V2NEANVH.cjs');
67
+ var chunk4J4FDVPS_cjs = require('./chunk-4J4FDVPS.cjs');
68
68
  var chunkHK3AMH3Q_cjs = require('./chunk-HK3AMH3Q.cjs');
69
69
  var chunkNYJIXR4Y_cjs = require('./chunk-NYJIXR4Y.cjs');
70
70
  var chunkTVLZZI5Q_cjs = require('./chunk-TVLZZI5Q.cjs');
@@ -1636,6 +1636,126 @@ function AIChat({
1636
1636
  }
1637
1637
  );
1638
1638
  }
1639
+ var ToastContext = React13.createContext(null);
1640
+ var toastIdCounter = 0;
1641
+ function generateToastId() {
1642
+ return `toast-${++toastIdCounter}-${Date.now()}`;
1643
+ }
1644
+ function ToastProvider({
1645
+ children,
1646
+ maxToasts = 5,
1647
+ defaultDuration = 5e3,
1648
+ position = "bottom-end"
1649
+ }) {
1650
+ const [toasts, setToasts] = React13.useState([]);
1651
+ const dismiss = React13.useCallback((id) => {
1652
+ setToasts((prev) => {
1653
+ const toast2 = prev.find((t) => t.id === id);
1654
+ if (toast2?.onDismiss) {
1655
+ toast2.onDismiss();
1656
+ }
1657
+ return prev.filter((t) => t.id !== id);
1658
+ });
1659
+ }, []);
1660
+ const dismissAll = React13.useCallback(() => {
1661
+ setToasts((prev) => {
1662
+ prev.forEach((t) => t.onDismiss?.());
1663
+ return [];
1664
+ });
1665
+ }, []);
1666
+ const toast = React13.useCallback(
1667
+ (options) => {
1668
+ const id = generateToastId();
1669
+ const duration = options.duration ?? defaultDuration;
1670
+ const newToast = {
1671
+ ...options,
1672
+ id,
1673
+ variant: options.variant ?? "info",
1674
+ dismissible: options.dismissible ?? true,
1675
+ duration
1676
+ };
1677
+ setToasts((prev) => {
1678
+ const updated = [...prev, newToast];
1679
+ if (updated.length > maxToasts) {
1680
+ const removed = updated.slice(0, updated.length - maxToasts);
1681
+ removed.forEach((t) => t.onDismiss?.());
1682
+ return updated.slice(-maxToasts);
1683
+ }
1684
+ return updated;
1685
+ });
1686
+ if (duration > 0) {
1687
+ setTimeout(() => dismiss(id), duration);
1688
+ }
1689
+ return id;
1690
+ },
1691
+ [maxToasts, defaultDuration, dismiss]
1692
+ );
1693
+ const success = React13.useCallback(
1694
+ (message, options) => {
1695
+ return toast({ ...options, message, variant: "success" });
1696
+ },
1697
+ [toast]
1698
+ );
1699
+ const error = React13.useCallback(
1700
+ (message, options) => {
1701
+ return toast({
1702
+ ...options,
1703
+ message,
1704
+ variant: "error",
1705
+ duration: options?.duration ?? 7e3
1706
+ // Errors stay longer by default
1707
+ });
1708
+ },
1709
+ [toast]
1710
+ );
1711
+ const warning = React13.useCallback(
1712
+ (message, options) => {
1713
+ return toast({ ...options, message, variant: "warning" });
1714
+ },
1715
+ [toast]
1716
+ );
1717
+ const info = React13.useCallback(
1718
+ (message, options) => {
1719
+ return toast({ ...options, message, variant: "info" });
1720
+ },
1721
+ [toast]
1722
+ );
1723
+ const contextValue = React13.useMemo(
1724
+ () => ({
1725
+ toasts,
1726
+ position,
1727
+ toast,
1728
+ success,
1729
+ error,
1730
+ warning,
1731
+ info,
1732
+ dismiss,
1733
+ dismissAll
1734
+ }),
1735
+ [
1736
+ toasts,
1737
+ position,
1738
+ toast,
1739
+ success,
1740
+ error,
1741
+ warning,
1742
+ info,
1743
+ dismiss,
1744
+ dismissAll
1745
+ ]
1746
+ );
1747
+ return /* @__PURE__ */ jsxRuntime.jsx(ToastContext.Provider, { value: contextValue, children });
1748
+ }
1749
+ function useToast() {
1750
+ const context = React13.useContext(ToastContext);
1751
+ if (!context) {
1752
+ throw new Error("useToast must be used within a ToastProvider");
1753
+ }
1754
+ return context;
1755
+ }
1756
+ function useOptionalToast() {
1757
+ return React13.useContext(ToastContext);
1758
+ }
1639
1759
  var CheckIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
1640
1760
  "svg",
1641
1761
  {
@@ -1767,7 +1887,7 @@ function Toast({
1767
1887
  className: chunkS5RVSXDV_cjs.cn(
1768
1888
  "flex items-start gap-3 rounded-lg border p-4 shadow-lg",
1769
1889
  "max-w-[420px] min-w-[300px]",
1770
- "animate-slide-in-right",
1890
+ "animate-slide-in-right rtl:animate-slide-in-left",
1771
1891
  styles.container
1772
1892
  ),
1773
1893
  children: [
@@ -1800,18 +1920,25 @@ function Toast({
1800
1920
  );
1801
1921
  }
1802
1922
  var positionStyles = {
1803
- "top-left": "top-4 left-4 items-start",
1923
+ "top-start": "top-4 start-4 items-start",
1804
1924
  "top-center": "top-4 left-1/2 -translate-x-1/2 items-center",
1805
- "top-right": "top-4 right-4 items-end",
1806
- "bottom-left": "bottom-4 left-4 items-start",
1925
+ "top-end": "top-4 end-4 items-end",
1926
+ "bottom-start": "bottom-4 start-4 items-start",
1807
1927
  "bottom-center": "bottom-4 left-1/2 -translate-x-1/2 items-center",
1808
- "bottom-right": "bottom-4 right-4 items-end"
1928
+ "bottom-end": "bottom-4 end-4 items-end",
1929
+ // Deprecated physical aliases for the logical positions above.
1930
+ "top-left": "top-4 start-4 items-start",
1931
+ "top-right": "top-4 end-4 items-end",
1932
+ "bottom-left": "bottom-4 start-4 items-start",
1933
+ "bottom-right": "bottom-4 end-4 items-end"
1809
1934
  };
1810
1935
  function ToastContainer({
1811
1936
  toasts,
1812
- position = "bottom-right",
1937
+ position,
1813
1938
  onDismiss
1814
1939
  }) {
1940
+ const context = useOptionalToast();
1941
+ const resolvedPosition = position ?? context?.position ?? "bottom-end";
1815
1942
  if (toasts.length === 0) return null;
1816
1943
  return /* @__PURE__ */ jsxRuntime.jsx(
1817
1944
  "div",
@@ -1819,7 +1946,7 @@ function ToastContainer({
1819
1946
  "data-slot": "toast-container",
1820
1947
  className: chunkS5RVSXDV_cjs.cn(
1821
1948
  "pointer-events-none fixed z-50 flex flex-col gap-2",
1822
- positionStyles[position]
1949
+ positionStyles[resolvedPosition]
1823
1950
  ),
1824
1951
  "aria-live": "polite",
1825
1952
  "aria-atomic": "true",
@@ -1827,111 +1954,6 @@ function ToastContainer({
1827
1954
  }
1828
1955
  );
1829
1956
  }
1830
- var ToastContext = React13.createContext(null);
1831
- var toastIdCounter = 0;
1832
- function generateToastId() {
1833
- return `toast-${++toastIdCounter}-${Date.now()}`;
1834
- }
1835
- function ToastProvider({
1836
- children,
1837
- maxToasts = 5,
1838
- defaultDuration = 5e3
1839
- }) {
1840
- const [toasts, setToasts] = React13.useState([]);
1841
- const dismiss = React13.useCallback((id) => {
1842
- setToasts((prev) => {
1843
- const toast2 = prev.find((t) => t.id === id);
1844
- if (toast2?.onDismiss) {
1845
- toast2.onDismiss();
1846
- }
1847
- return prev.filter((t) => t.id !== id);
1848
- });
1849
- }, []);
1850
- const dismissAll = React13.useCallback(() => {
1851
- setToasts((prev) => {
1852
- prev.forEach((t) => t.onDismiss?.());
1853
- return [];
1854
- });
1855
- }, []);
1856
- const toast = React13.useCallback(
1857
- (options) => {
1858
- const id = generateToastId();
1859
- const duration = options.duration ?? defaultDuration;
1860
- const newToast = {
1861
- ...options,
1862
- id,
1863
- variant: options.variant ?? "info",
1864
- dismissible: options.dismissible ?? true,
1865
- duration
1866
- };
1867
- setToasts((prev) => {
1868
- const updated = [...prev, newToast];
1869
- if (updated.length > maxToasts) {
1870
- const removed = updated.slice(0, updated.length - maxToasts);
1871
- removed.forEach((t) => t.onDismiss?.());
1872
- return updated.slice(-maxToasts);
1873
- }
1874
- return updated;
1875
- });
1876
- if (duration > 0) {
1877
- setTimeout(() => dismiss(id), duration);
1878
- }
1879
- return id;
1880
- },
1881
- [maxToasts, defaultDuration, dismiss]
1882
- );
1883
- const success = React13.useCallback(
1884
- (message, options) => {
1885
- return toast({ ...options, message, variant: "success" });
1886
- },
1887
- [toast]
1888
- );
1889
- const error = React13.useCallback(
1890
- (message, options) => {
1891
- return toast({
1892
- ...options,
1893
- message,
1894
- variant: "error",
1895
- duration: options?.duration ?? 7e3
1896
- // Errors stay longer by default
1897
- });
1898
- },
1899
- [toast]
1900
- );
1901
- const warning = React13.useCallback(
1902
- (message, options) => {
1903
- return toast({ ...options, message, variant: "warning" });
1904
- },
1905
- [toast]
1906
- );
1907
- const info = React13.useCallback(
1908
- (message, options) => {
1909
- return toast({ ...options, message, variant: "info" });
1910
- },
1911
- [toast]
1912
- );
1913
- const contextValue = React13.useMemo(
1914
- () => ({
1915
- toasts,
1916
- toast,
1917
- success,
1918
- error,
1919
- warning,
1920
- info,
1921
- dismiss,
1922
- dismissAll
1923
- }),
1924
- [toasts, toast, success, error, warning, info, dismiss, dismissAll]
1925
- );
1926
- return /* @__PURE__ */ jsxRuntime.jsx(ToastContext.Provider, { value: contextValue, children });
1927
- }
1928
- function useToast() {
1929
- const context = React13.useContext(ToastContext);
1930
- if (!context) {
1931
- throw new Error("useToast must be used within a ToastProvider");
1932
- }
1933
- return context;
1934
- }
1935
1957
  var MENU_OFFSET_PX = 6;
1936
1958
  var MENU_MAX_HEIGHT_PX = 320;
1937
1959
  function optionKey(option) {
@@ -45367,11 +45389,11 @@ Object.defineProperty(exports, "FilterSummaryBar", {
45367
45389
  });
45368
45390
  Object.defineProperty(exports, "FloatingWindow", {
45369
45391
  enumerable: true,
45370
- get: function () { return chunkH7QSGFMZ_cjs.FloatingWindow; }
45392
+ get: function () { return chunkVKNCQIVN_cjs.FloatingWindow; }
45371
45393
  });
45372
45394
  Object.defineProperty(exports, "MinimizedWindow", {
45373
45395
  enumerable: true,
45374
- get: function () { return chunkH7QSGFMZ_cjs.MinimizedWindow; }
45396
+ get: function () { return chunkVKNCQIVN_cjs.MinimizedWindow; }
45375
45397
  });
45376
45398
  Object.defineProperty(exports, "FreshnessBadge", {
45377
45399
  enumerable: true,
@@ -45439,11 +45461,11 @@ Object.defineProperty(exports, "CollapsibleTrigger", {
45439
45461
  });
45440
45462
  Object.defineProperty(exports, "miewebUIPreset", {
45441
45463
  enumerable: true,
45442
- get: function () { return chunkV2NEANVH_cjs.miewebUIPreset; }
45464
+ get: function () { return chunk4J4FDVPS_cjs.miewebUIPreset; }
45443
45465
  });
45444
45466
  Object.defineProperty(exports, "miewebUISafelist", {
45445
45467
  enumerable: true,
45446
- get: function () { return chunkV2NEANVH_cjs.miewebUISafelist; }
45468
+ get: function () { return chunk4J4FDVPS_cjs.miewebUISafelist; }
45447
45469
  });
45448
45470
  Object.defineProperty(exports, "Accordion", {
45449
45471
  enumerable: true,
@@ -47050,6 +47072,7 @@ exports.useDocumentDetection = useDocumentDetection;
47050
47072
  exports.useDropzone = useDropzone;
47051
47073
  exports.useFileUpload = useFileUpload;
47052
47074
  exports.useHeyOzwell = useHeyOzwell;
47075
+ exports.useOptionalToast = useOptionalToast;
47053
47076
  exports.useSidebar = useSidebar;
47054
47077
  exports.useSpeakerVerify = useSpeakerVerify;
47055
47078
  exports.useToast = useToast;