@howone/sdk 0.1.19 → 0.1.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.d.mts +34 -4
- package/dist/index.d.ts +34 -4
- package/dist/index.js +124 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -232,7 +232,7 @@ var FloatingButton = ({
|
|
|
232
232
|
{
|
|
233
233
|
onClick,
|
|
234
234
|
id: "floating-howone-btn",
|
|
235
|
-
className: `fixed flex bg-
|
|
235
|
+
className: `fixed flex bg-background gap-2 items-center right-4 z-50 text-black dark:text-white px-3 py-2 rounded-lg shadow-lg transition-colors duration-200 border border-gray-200 dark:border-gray-700 ${className}`,
|
|
236
236
|
style: {
|
|
237
237
|
fontSize: "14px",
|
|
238
238
|
fontWeight: "bold",
|
|
@@ -1499,12 +1499,86 @@ var LoginForm = ({
|
|
|
1499
1499
|
|
|
1500
1500
|
// src/components/auth/AuthProvider.tsx
|
|
1501
1501
|
init_auth();
|
|
1502
|
-
import { createContext, useContext, useState as
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1502
|
+
import { createContext as createContext2, useContext as useContext2, useState as useState4 } from "react";
|
|
1503
|
+
|
|
1504
|
+
// src/components/theme/ThemeProvider.tsx
|
|
1505
|
+
import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
|
|
1506
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1507
|
+
var initialState = {
|
|
1508
|
+
theme: "system",
|
|
1509
|
+
setTheme: () => null
|
|
1510
|
+
};
|
|
1511
|
+
var ThemeProviderContext = createContext(initialState);
|
|
1512
|
+
function ThemeProvider({
|
|
1513
|
+
children,
|
|
1514
|
+
defaultTheme = "system",
|
|
1515
|
+
storageKey = "vite-ui-theme",
|
|
1516
|
+
forceDefault = false,
|
|
1517
|
+
...props
|
|
1518
|
+
}) {
|
|
1519
|
+
const [theme, setTheme] = useState3(() => {
|
|
1520
|
+
if (forceDefault) {
|
|
1521
|
+
localStorage.setItem(storageKey, defaultTheme);
|
|
1522
|
+
return defaultTheme;
|
|
1523
|
+
}
|
|
1524
|
+
const stored = localStorage.getItem(storageKey);
|
|
1525
|
+
const initialTheme = stored || defaultTheme;
|
|
1526
|
+
if (!stored) {
|
|
1527
|
+
localStorage.setItem(storageKey, defaultTheme);
|
|
1528
|
+
}
|
|
1529
|
+
return initialTheme;
|
|
1530
|
+
});
|
|
1531
|
+
useEffect3(() => {
|
|
1532
|
+
const root = window.document.documentElement;
|
|
1533
|
+
root.classList.remove("light", "dark");
|
|
1534
|
+
if (theme === "system") {
|
|
1535
|
+
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1536
|
+
root.classList.add(systemTheme);
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
root.classList.add(theme);
|
|
1540
|
+
}, [theme]);
|
|
1541
|
+
const value = {
|
|
1542
|
+
theme,
|
|
1543
|
+
setTheme: (theme2) => {
|
|
1544
|
+
localStorage.setItem(storageKey, theme2);
|
|
1545
|
+
setTheme(theme2);
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
return /* @__PURE__ */ jsx3(ThemeProviderContext.Provider, { ...props, value, children });
|
|
1549
|
+
}
|
|
1550
|
+
var useTheme = () => {
|
|
1551
|
+
const context = useContext(ThemeProviderContext);
|
|
1552
|
+
if (context === void 0)
|
|
1553
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
1554
|
+
return context;
|
|
1555
|
+
};
|
|
1556
|
+
|
|
1557
|
+
// src/components/ui/Toast/GlobalToastContainer.tsx
|
|
1558
|
+
import { ToastContainer } from "react-toastify";
|
|
1559
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1560
|
+
function GlobalToastContainer() {
|
|
1561
|
+
return /* @__PURE__ */ jsx4(
|
|
1562
|
+
ToastContainer,
|
|
1563
|
+
{
|
|
1564
|
+
newestOnTop: false,
|
|
1565
|
+
closeButton: false
|
|
1566
|
+
}
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// src/components/auth/AuthProvider.tsx
|
|
1571
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1572
|
+
var AuthContext = createContext2(null);
|
|
1573
|
+
var HowoneProvider = ({
|
|
1574
|
+
children,
|
|
1575
|
+
showFloatingButton = true,
|
|
1576
|
+
defaultTheme = "system",
|
|
1577
|
+
themeStorageKey = "howone-theme",
|
|
1578
|
+
forceDefaultTheme = false
|
|
1579
|
+
}) => {
|
|
1580
|
+
const [user, setUser] = useState4(() => parseUserFromToken(getToken()));
|
|
1581
|
+
const [token, setTokenState] = useState4(() => getToken());
|
|
1508
1582
|
const logout = () => {
|
|
1509
1583
|
try {
|
|
1510
1584
|
setToken(null);
|
|
@@ -1519,13 +1593,24 @@ var AuthProvider = ({ children, showFloatingButton = true }) => {
|
|
|
1519
1593
|
isAuthenticated: !!token,
|
|
1520
1594
|
logout
|
|
1521
1595
|
};
|
|
1522
|
-
return /* @__PURE__ */
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1596
|
+
return /* @__PURE__ */ jsxs3(
|
|
1597
|
+
ThemeProvider,
|
|
1598
|
+
{
|
|
1599
|
+
defaultTheme,
|
|
1600
|
+
storageKey: themeStorageKey,
|
|
1601
|
+
forceDefault: forceDefaultTheme,
|
|
1602
|
+
children: [
|
|
1603
|
+
/* @__PURE__ */ jsxs3(AuthContext.Provider, { value, children: [
|
|
1604
|
+
children,
|
|
1605
|
+
showFloatingButton && /* @__PURE__ */ jsx5(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1606
|
+
] }),
|
|
1607
|
+
/* @__PURE__ */ jsx5(GlobalToastContainer, {})
|
|
1608
|
+
]
|
|
1609
|
+
}
|
|
1610
|
+
);
|
|
1526
1611
|
};
|
|
1527
1612
|
function useAuthContext() {
|
|
1528
|
-
const ctx =
|
|
1613
|
+
const ctx = useContext2(AuthContext);
|
|
1529
1614
|
if (!ctx) {
|
|
1530
1615
|
const t = getToken();
|
|
1531
1616
|
return {
|
|
@@ -1542,6 +1627,7 @@ function useAuthContext() {
|
|
|
1542
1627
|
}
|
|
1543
1628
|
return ctx;
|
|
1544
1629
|
}
|
|
1630
|
+
var AuthProvider = HowoneProvider;
|
|
1545
1631
|
|
|
1546
1632
|
// src/components/index.ts
|
|
1547
1633
|
init_auth();
|
|
@@ -1629,7 +1715,7 @@ var howone = {
|
|
|
1629
1715
|
var client_default = howone;
|
|
1630
1716
|
|
|
1631
1717
|
// src/components/ui/Loading.tsx
|
|
1632
|
-
import { jsx as
|
|
1718
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1633
1719
|
var Loading = ({
|
|
1634
1720
|
size = "md",
|
|
1635
1721
|
text = "Loading...",
|
|
@@ -1642,14 +1728,14 @@ var Loading = ({
|
|
|
1642
1728
|
lg: "h-12 w-12"
|
|
1643
1729
|
};
|
|
1644
1730
|
const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
|
|
1645
|
-
return /* @__PURE__ */
|
|
1646
|
-
/* @__PURE__ */
|
|
1731
|
+
return /* @__PURE__ */ jsx6("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ jsxs4("div", { className: "text-center", children: [
|
|
1732
|
+
/* @__PURE__ */ jsx6(
|
|
1647
1733
|
"div",
|
|
1648
1734
|
{
|
|
1649
1735
|
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
1650
1736
|
}
|
|
1651
1737
|
),
|
|
1652
|
-
text && /* @__PURE__ */
|
|
1738
|
+
text && /* @__PURE__ */ jsx6("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
1653
1739
|
] }) });
|
|
1654
1740
|
};
|
|
1655
1741
|
var LoadingSpinner = ({
|
|
@@ -1661,7 +1747,7 @@ var LoadingSpinner = ({
|
|
|
1661
1747
|
md: "h-8 w-8",
|
|
1662
1748
|
lg: "h-12 w-12"
|
|
1663
1749
|
};
|
|
1664
|
-
return /* @__PURE__ */
|
|
1750
|
+
return /* @__PURE__ */ jsx6(
|
|
1665
1751
|
"div",
|
|
1666
1752
|
{
|
|
1667
1753
|
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
@@ -1671,7 +1757,7 @@ var LoadingSpinner = ({
|
|
|
1671
1757
|
|
|
1672
1758
|
// src/components/ui/ErrorBoundary.tsx
|
|
1673
1759
|
import { Component } from "react";
|
|
1674
|
-
import { jsx as
|
|
1760
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1675
1761
|
var ErrorBoundary = class extends Component {
|
|
1676
1762
|
constructor(props) {
|
|
1677
1763
|
super(props);
|
|
@@ -1694,13 +1780,13 @@ var ErrorBoundary = class extends Component {
|
|
|
1694
1780
|
if (this.state.hasError) {
|
|
1695
1781
|
if (this.props.fallback) {
|
|
1696
1782
|
const FallbackComponent = this.props.fallback;
|
|
1697
|
-
return /* @__PURE__ */
|
|
1783
|
+
return /* @__PURE__ */ jsx7(FallbackComponent, { error: this.state.error, retry: this.handleRetry });
|
|
1698
1784
|
}
|
|
1699
|
-
return /* @__PURE__ */
|
|
1700
|
-
/* @__PURE__ */
|
|
1701
|
-
/* @__PURE__ */
|
|
1702
|
-
/* @__PURE__ */
|
|
1703
|
-
/* @__PURE__ */
|
|
1785
|
+
return /* @__PURE__ */ jsx7("div", { className: "min-h-[400px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center max-w-md", children: [
|
|
1786
|
+
/* @__PURE__ */ jsx7("div", { className: "text-red-500 text-6xl mb-4", children: "\u26A0\uFE0F" }),
|
|
1787
|
+
/* @__PURE__ */ jsx7("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Something went wrong" }),
|
|
1788
|
+
/* @__PURE__ */ jsx7("p", { className: "text-gray-600 mb-4", children: "An unexpected error occurred. Please try refreshing the page." }),
|
|
1789
|
+
/* @__PURE__ */ jsx7(
|
|
1704
1790
|
"button",
|
|
1705
1791
|
{
|
|
1706
1792
|
onClick: this.handleRetry,
|
|
@@ -1714,10 +1800,10 @@ var ErrorBoundary = class extends Component {
|
|
|
1714
1800
|
return this.props.children;
|
|
1715
1801
|
}
|
|
1716
1802
|
};
|
|
1717
|
-
var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */
|
|
1718
|
-
/* @__PURE__ */
|
|
1719
|
-
/* @__PURE__ */
|
|
1720
|
-
retry && /* @__PURE__ */
|
|
1803
|
+
var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx7("div", { className: "min-h-[200px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center", children: [
|
|
1804
|
+
/* @__PURE__ */ jsx7("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
|
|
1805
|
+
/* @__PURE__ */ jsx7("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
|
|
1806
|
+
retry && /* @__PURE__ */ jsx7(
|
|
1721
1807
|
"button",
|
|
1722
1808
|
{
|
|
1723
1809
|
onClick: retry,
|
|
@@ -1727,54 +1813,11 @@ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx5("div", { classNam
|
|
|
1727
1813
|
)
|
|
1728
1814
|
] }) });
|
|
1729
1815
|
|
|
1730
|
-
// src/components/theme/ThemeProvider.tsx
|
|
1731
|
-
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect3, useState as useState4 } from "react";
|
|
1732
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1733
|
-
var initialState = {
|
|
1734
|
-
theme: "system",
|
|
1735
|
-
setTheme: () => null
|
|
1736
|
-
};
|
|
1737
|
-
var ThemeProviderContext = createContext2(initialState);
|
|
1738
|
-
function ThemeProvider({
|
|
1739
|
-
children,
|
|
1740
|
-
defaultTheme = "system",
|
|
1741
|
-
storageKey = "vite-ui-theme",
|
|
1742
|
-
...props
|
|
1743
|
-
}) {
|
|
1744
|
-
const [theme, setTheme] = useState4(
|
|
1745
|
-
() => localStorage.getItem(storageKey) || defaultTheme
|
|
1746
|
-
);
|
|
1747
|
-
useEffect3(() => {
|
|
1748
|
-
const root = window.document.documentElement;
|
|
1749
|
-
root.classList.remove("light", "dark");
|
|
1750
|
-
if (theme === "system") {
|
|
1751
|
-
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1752
|
-
root.classList.add(systemTheme);
|
|
1753
|
-
return;
|
|
1754
|
-
}
|
|
1755
|
-
root.classList.add(theme);
|
|
1756
|
-
}, [theme]);
|
|
1757
|
-
const value = {
|
|
1758
|
-
theme,
|
|
1759
|
-
setTheme: (theme2) => {
|
|
1760
|
-
localStorage.setItem(storageKey, theme2);
|
|
1761
|
-
setTheme(theme2);
|
|
1762
|
-
}
|
|
1763
|
-
};
|
|
1764
|
-
return /* @__PURE__ */ jsx6(ThemeProviderContext.Provider, { ...props, value, children });
|
|
1765
|
-
}
|
|
1766
|
-
var useTheme = () => {
|
|
1767
|
-
const context = useContext2(ThemeProviderContext);
|
|
1768
|
-
if (context === void 0)
|
|
1769
|
-
throw new Error("useTheme must be used within a ThemeProvider");
|
|
1770
|
-
return context;
|
|
1771
|
-
};
|
|
1772
|
-
|
|
1773
1816
|
// src/components/theme/ThemeToggle.tsx
|
|
1774
1817
|
import * as React4 from "react";
|
|
1775
1818
|
import { useTheme as useTheme2 } from "next-themes";
|
|
1776
1819
|
import { Icon as Icon3 } from "@iconify/react";
|
|
1777
|
-
import { jsx as
|
|
1820
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1778
1821
|
function ThemeToggle({ className }) {
|
|
1779
1822
|
const { setTheme, theme } = useTheme2();
|
|
1780
1823
|
const [mounted, setMounted] = React4.useState(false);
|
|
@@ -1788,8 +1831,8 @@ function ThemeToggle({ className }) {
|
|
|
1788
1831
|
className: `relative inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground ${className || ""}`,
|
|
1789
1832
|
disabled: true,
|
|
1790
1833
|
children: [
|
|
1791
|
-
/* @__PURE__ */
|
|
1792
|
-
/* @__PURE__ */
|
|
1834
|
+
/* @__PURE__ */ jsx8(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
|
|
1835
|
+
/* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Toggle theme" })
|
|
1793
1836
|
]
|
|
1794
1837
|
}
|
|
1795
1838
|
);
|
|
@@ -1800,26 +1843,13 @@ function ThemeToggle({ className }) {
|
|
|
1800
1843
|
className: `inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors ${className || ""}`,
|
|
1801
1844
|
onClick: () => setTheme(theme === "light" ? "dark" : "light"),
|
|
1802
1845
|
children: [
|
|
1803
|
-
theme === "light" ? /* @__PURE__ */
|
|
1804
|
-
/* @__PURE__ */
|
|
1846
|
+
theme === "light" ? /* @__PURE__ */ jsx8(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }) : /* @__PURE__ */ jsx8(Icon3, { icon: "solar:moon-linear", width: 20, height: 20 }),
|
|
1847
|
+
/* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Toggle theme" })
|
|
1805
1848
|
]
|
|
1806
1849
|
}
|
|
1807
1850
|
);
|
|
1808
1851
|
}
|
|
1809
1852
|
|
|
1810
|
-
// src/components/ui/Toast/GlobalToastContainer.tsx
|
|
1811
|
-
import { ToastContainer } from "react-toastify";
|
|
1812
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1813
|
-
function GlobalToastContainer() {
|
|
1814
|
-
return /* @__PURE__ */ jsx8(
|
|
1815
|
-
ToastContainer,
|
|
1816
|
-
{
|
|
1817
|
-
newestOnTop: false,
|
|
1818
|
-
closeButton: false
|
|
1819
|
-
}
|
|
1820
|
-
);
|
|
1821
|
-
}
|
|
1822
|
-
|
|
1823
1853
|
// src/components/ui/Toast/ClayxToast.tsx
|
|
1824
1854
|
import React5, { useCallback } from "react";
|
|
1825
1855
|
import { Bounce, toast } from "react-toastify";
|
|
@@ -2364,6 +2394,7 @@ export {
|
|
|
2364
2394
|
ErrorBoundary,
|
|
2365
2395
|
FloatingButton,
|
|
2366
2396
|
GlobalToastContainer,
|
|
2397
|
+
HowoneProvider,
|
|
2367
2398
|
Loading,
|
|
2368
2399
|
LoadingSpinner,
|
|
2369
2400
|
LoginForm,
|