@syscore/ui-library 1.19.0 → 1.20.0
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/client/global.css +17 -0
- package/client/ui/Dialog.stories.tsx +104 -3
- package/client/ui/MobileNav.stories.tsx +81 -38
- package/client/ui/Tooltip.stories.tsx +24 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +169 -56
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { AlertDialogTitle } from '../client/components/ui/alert-dialog';
|
|
|
20
20
|
import { AlertDialogTrigger } from '../client/components/ui/alert-dialog';
|
|
21
21
|
import { AlertTitle } from '../client/components/ui/alert';
|
|
22
22
|
import { AlphaIcon } from '../client/components/icons/AlphaIcon';
|
|
23
|
+
import { AnimatedTabs } from '../client/components/ui/tabs';
|
|
23
24
|
import { AspectRatio } from '../client/components/ui/aspect-ratio';
|
|
24
25
|
import { Avatar } from '../client/components/ui/avatar';
|
|
25
26
|
import { AvatarFallback } from '../client/components/ui/avatar';
|
|
@@ -412,6 +413,8 @@ export { AlertTitle }
|
|
|
412
413
|
|
|
413
414
|
export { AlphaIcon }
|
|
414
415
|
|
|
416
|
+
export { AnimatedTabs }
|
|
417
|
+
|
|
415
418
|
export { AspectRatio }
|
|
416
419
|
|
|
417
420
|
export { Avatar }
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import React__default, { useState,
|
|
3
|
+
import React__default, { useState, useCallback, useEffect, useRef, createContext, useMemo, useLayoutEffect, useContext } from "react";
|
|
4
4
|
import { motion, AnimatePresence, useMotionValue, animate } from "motion/react";
|
|
5
5
|
import { clsx } from "clsx";
|
|
6
6
|
import { twMerge } from "tailwind-merge";
|
|
@@ -18,6 +18,7 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
|
18
18
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
19
19
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
20
20
|
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
21
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
21
22
|
import { OTPInput, OTPInputContext } from "input-otp";
|
|
22
23
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
23
24
|
import { useFormContext, FormProvider, Controller } from "react-hook-form";
|
|
@@ -27,7 +28,6 @@ import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
|
27
28
|
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
28
29
|
import { DayPicker } from "react-day-picker";
|
|
29
30
|
import { Command as Command$1 } from "cmdk";
|
|
30
|
-
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
31
31
|
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
32
32
|
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
|
33
33
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
@@ -1752,6 +1752,172 @@ const Slider = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
1752
1752
|
}
|
|
1753
1753
|
));
|
|
1754
1754
|
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
1755
|
+
function useTabs({ tabs, initialTabId }) {
|
|
1756
|
+
const initialIndex = tabs.findIndex((tab) => tab.value === initialTabId);
|
|
1757
|
+
const [selectedTabIndex, setSelectedTabIndex] = useState(
|
|
1758
|
+
initialIndex >= 0 ? initialIndex : 0
|
|
1759
|
+
);
|
|
1760
|
+
const setSelectedTab = useCallback(([index, direction]) => {
|
|
1761
|
+
setSelectedTabIndex(index);
|
|
1762
|
+
}, []);
|
|
1763
|
+
const selectedTab = tabs[selectedTabIndex] || tabs[0];
|
|
1764
|
+
return {
|
|
1765
|
+
tabProps: {
|
|
1766
|
+
tabs,
|
|
1767
|
+
selectedTabIndex,
|
|
1768
|
+
setSelectedTab
|
|
1769
|
+
},
|
|
1770
|
+
selectedTab
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
const transition = {
|
|
1774
|
+
type: "tween",
|
|
1775
|
+
ease: "easeOut",
|
|
1776
|
+
duration: 0.15
|
|
1777
|
+
};
|
|
1778
|
+
const TabContent = ({ tab }) => {
|
|
1779
|
+
return /* @__PURE__ */ jsx(
|
|
1780
|
+
motion.div,
|
|
1781
|
+
{
|
|
1782
|
+
initial: { opacity: 0, y: 10 },
|
|
1783
|
+
animate: { opacity: 1, y: 0 },
|
|
1784
|
+
exit: { opacity: 0, y: -10 },
|
|
1785
|
+
transition,
|
|
1786
|
+
children: tab.content
|
|
1787
|
+
},
|
|
1788
|
+
tab.value
|
|
1789
|
+
);
|
|
1790
|
+
};
|
|
1791
|
+
const Tabs = ({
|
|
1792
|
+
tabs,
|
|
1793
|
+
selectedTabIndex,
|
|
1794
|
+
setSelectedTab
|
|
1795
|
+
}) => {
|
|
1796
|
+
var _a, _b, _c;
|
|
1797
|
+
const [buttonRefs, setButtonRefs] = React__default.useState([]);
|
|
1798
|
+
React__default.useEffect(() => {
|
|
1799
|
+
setButtonRefs((prev) => prev.slice(0, tabs.length));
|
|
1800
|
+
}, [tabs.length]);
|
|
1801
|
+
const navRef = React__default.useRef(null);
|
|
1802
|
+
const navRect = (_a = navRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
1803
|
+
const selectedRect = (_b = buttonRefs[selectedTabIndex]) == null ? void 0 : _b.getBoundingClientRect();
|
|
1804
|
+
const [hoveredTabIndex, setHoveredTabIndex] = React__default.useState(
|
|
1805
|
+
null
|
|
1806
|
+
);
|
|
1807
|
+
(_c = buttonRefs[hoveredTabIndex ?? -1]) == null ? void 0 : _c.getBoundingClientRect();
|
|
1808
|
+
return /* @__PURE__ */ jsxs(
|
|
1809
|
+
"nav",
|
|
1810
|
+
{
|
|
1811
|
+
ref: navRef,
|
|
1812
|
+
className: "tabs-nav",
|
|
1813
|
+
onPointerLeave: () => setHoveredTabIndex(null),
|
|
1814
|
+
children: [
|
|
1815
|
+
tabs.map((item, i) => {
|
|
1816
|
+
const isActive = selectedTabIndex === i;
|
|
1817
|
+
return /* @__PURE__ */ jsx(
|
|
1818
|
+
"button",
|
|
1819
|
+
{
|
|
1820
|
+
className: "tabs-nav-button",
|
|
1821
|
+
onPointerEnter: () => setHoveredTabIndex(i),
|
|
1822
|
+
onFocus: () => setHoveredTabIndex(i),
|
|
1823
|
+
onClick: () => setSelectedTab([i, i > selectedTabIndex ? 1 : -1]),
|
|
1824
|
+
children: /* @__PURE__ */ jsx(
|
|
1825
|
+
motion.span,
|
|
1826
|
+
{
|
|
1827
|
+
ref: (el) => {
|
|
1828
|
+
buttonRefs[i] = el;
|
|
1829
|
+
},
|
|
1830
|
+
className: cn("tabs-nav-button-text", {
|
|
1831
|
+
"tabs-nav-button-text--inactive": !isActive,
|
|
1832
|
+
"tabs-nav-button-text--active": isActive
|
|
1833
|
+
}),
|
|
1834
|
+
children: /* @__PURE__ */ jsx(
|
|
1835
|
+
"small",
|
|
1836
|
+
{
|
|
1837
|
+
className: item.value === "danger-zone" ? "tabs-nav-button-text--danger" : "",
|
|
1838
|
+
children: item.label
|
|
1839
|
+
}
|
|
1840
|
+
)
|
|
1841
|
+
}
|
|
1842
|
+
)
|
|
1843
|
+
},
|
|
1844
|
+
item.value
|
|
1845
|
+
);
|
|
1846
|
+
}),
|
|
1847
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: selectedRect && navRect && /* @__PURE__ */ jsx(
|
|
1848
|
+
motion.div,
|
|
1849
|
+
{
|
|
1850
|
+
className: cn("tabs-nav-indicator", {
|
|
1851
|
+
"tabs-nav-indicator--danger": selectedTabIndex === tabs.findIndex(({ value }) => value === "danger-zone"),
|
|
1852
|
+
"tabs-nav-indicator--default": selectedTabIndex !== tabs.findIndex(({ value }) => value === "danger-zone")
|
|
1853
|
+
}),
|
|
1854
|
+
initial: false,
|
|
1855
|
+
animate: {
|
|
1856
|
+
width: selectedRect.width,
|
|
1857
|
+
x: selectedRect.left - navRect.left,
|
|
1858
|
+
opacity: 1
|
|
1859
|
+
},
|
|
1860
|
+
transition
|
|
1861
|
+
}
|
|
1862
|
+
) }),
|
|
1863
|
+
/* @__PURE__ */ jsx("div", { className: "tabs-nav-underline" })
|
|
1864
|
+
]
|
|
1865
|
+
}
|
|
1866
|
+
);
|
|
1867
|
+
};
|
|
1868
|
+
function AnimatedTabs({ tabs }) {
|
|
1869
|
+
const [hookProps] = React__default.useState(() => {
|
|
1870
|
+
var _a;
|
|
1871
|
+
const initialTabId = ((_a = tabs.find((tab) => tab.value === "home")) == null ? void 0 : _a.value) || tabs[0].value;
|
|
1872
|
+
return {
|
|
1873
|
+
tabs: tabs.map((tab) => ({
|
|
1874
|
+
...tab
|
|
1875
|
+
})),
|
|
1876
|
+
initialTabId
|
|
1877
|
+
};
|
|
1878
|
+
});
|
|
1879
|
+
const framer = useTabs(hookProps);
|
|
1880
|
+
return /* @__PURE__ */ jsxs("div", { className: "tabs-container", children: [
|
|
1881
|
+
/* @__PURE__ */ jsx("div", { className: "tabs-container-inner", children: /* @__PURE__ */ jsx(Tabs, { ...framer.tabProps }) }),
|
|
1882
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsx(TabContent, { tab: framer.selectedTab }) })
|
|
1883
|
+
] });
|
|
1884
|
+
}
|
|
1885
|
+
const TabsRoot = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1886
|
+
TabsPrimitive.Root,
|
|
1887
|
+
{
|
|
1888
|
+
ref,
|
|
1889
|
+
className: cn("tabs", className),
|
|
1890
|
+
...props
|
|
1891
|
+
}
|
|
1892
|
+
));
|
|
1893
|
+
TabsRoot.displayName = TabsPrimitive.Root.displayName;
|
|
1894
|
+
const TabsList = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1895
|
+
TabsPrimitive.List,
|
|
1896
|
+
{
|
|
1897
|
+
ref,
|
|
1898
|
+
className: cn("tabs-list", className),
|
|
1899
|
+
...props
|
|
1900
|
+
}
|
|
1901
|
+
));
|
|
1902
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
1903
|
+
const TabsTrigger = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1904
|
+
TabsPrimitive.Trigger,
|
|
1905
|
+
{
|
|
1906
|
+
ref,
|
|
1907
|
+
className: cn("tabs-trigger", className),
|
|
1908
|
+
...props
|
|
1909
|
+
}
|
|
1910
|
+
));
|
|
1911
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
1912
|
+
const TabsContent = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1913
|
+
TabsPrimitive.Content,
|
|
1914
|
+
{
|
|
1915
|
+
ref,
|
|
1916
|
+
className: cn("tabs-content", className),
|
|
1917
|
+
...props
|
|
1918
|
+
}
|
|
1919
|
+
));
|
|
1920
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
1755
1921
|
const InputOTP = React.forwardRef(({ className, containerClassName, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1756
1922
|
OTPInput,
|
|
1757
1923
|
{
|
|
@@ -2759,60 +2925,6 @@ const Tag = React.forwardRef(
|
|
|
2759
2925
|
}
|
|
2760
2926
|
);
|
|
2761
2927
|
Tag.displayName = "Tag";
|
|
2762
|
-
function useTabs({ tabs, initialTabId }) {
|
|
2763
|
-
const initialIndex = tabs.findIndex((tab) => tab.value === initialTabId);
|
|
2764
|
-
const [selectedTabIndex, setSelectedTabIndex] = useState(
|
|
2765
|
-
initialIndex >= 0 ? initialIndex : 0
|
|
2766
|
-
);
|
|
2767
|
-
const setSelectedTab = useCallback(([index, direction]) => {
|
|
2768
|
-
setSelectedTabIndex(index);
|
|
2769
|
-
}, []);
|
|
2770
|
-
const selectedTab = tabs[selectedTabIndex] || tabs[0];
|
|
2771
|
-
return {
|
|
2772
|
-
tabProps: {
|
|
2773
|
-
tabs,
|
|
2774
|
-
selectedTabIndex,
|
|
2775
|
-
setSelectedTab
|
|
2776
|
-
},
|
|
2777
|
-
selectedTab
|
|
2778
|
-
};
|
|
2779
|
-
}
|
|
2780
|
-
const TabsRoot = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2781
|
-
TabsPrimitive.Root,
|
|
2782
|
-
{
|
|
2783
|
-
ref,
|
|
2784
|
-
className: cn("tabs", className),
|
|
2785
|
-
...props
|
|
2786
|
-
}
|
|
2787
|
-
));
|
|
2788
|
-
TabsRoot.displayName = TabsPrimitive.Root.displayName;
|
|
2789
|
-
const TabsList = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2790
|
-
TabsPrimitive.List,
|
|
2791
|
-
{
|
|
2792
|
-
ref,
|
|
2793
|
-
className: cn("tabs-list", className),
|
|
2794
|
-
...props
|
|
2795
|
-
}
|
|
2796
|
-
));
|
|
2797
|
-
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
2798
|
-
const TabsTrigger = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2799
|
-
TabsPrimitive.Trigger,
|
|
2800
|
-
{
|
|
2801
|
-
ref,
|
|
2802
|
-
className: cn("tabs-trigger", className),
|
|
2803
|
-
...props
|
|
2804
|
-
}
|
|
2805
|
-
));
|
|
2806
|
-
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
2807
|
-
const TabsContent = React__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2808
|
-
TabsPrimitive.Content,
|
|
2809
|
-
{
|
|
2810
|
-
ref,
|
|
2811
|
-
className: cn("tabs-content", className),
|
|
2812
|
-
...props
|
|
2813
|
-
}
|
|
2814
|
-
));
|
|
2815
|
-
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
2816
2928
|
const Pagination = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
2817
2929
|
"nav",
|
|
2818
2930
|
{
|
|
@@ -13228,6 +13340,7 @@ export {
|
|
|
13228
13340
|
AlertDialogTrigger,
|
|
13229
13341
|
AlertTitle,
|
|
13230
13342
|
AlphaIcon,
|
|
13343
|
+
AnimatedTabs,
|
|
13231
13344
|
AspectRatio,
|
|
13232
13345
|
Avatar,
|
|
13233
13346
|
AvatarFallback,
|