@rovula/ui 0.0.26 → 0.0.28

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.
Files changed (159) hide show
  1. package/dist/cjs/bundle.css +185 -37
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/AlertDialog/{Alert.stories.d.ts → AlertDialog.stories.d.ts} +4 -0
  5. package/dist/cjs/types/components/Calendar/Calendar.stories.d.ts +7 -7
  6. package/dist/cjs/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
  7. package/dist/cjs/types/components/Text/Text.d.ts +5 -6
  8. package/dist/cjs/types/components/Text/Text.stories.d.ts +10 -2
  9. package/dist/cjs/types/components/Toast/Toast.d.ts +17 -0
  10. package/dist/cjs/types/components/Toast/Toast.stories.d.ts +358 -0
  11. package/dist/cjs/types/components/Toast/Toast.styles.d.ts +12 -0
  12. package/dist/cjs/types/components/Toast/Toaster.d.ts +1 -0
  13. package/dist/cjs/types/components/Toast/useToast.d.ts +55 -0
  14. package/dist/cjs/types/components/Tooltip/Tooltip.d.ts +8 -0
  15. package/dist/cjs/types/components/Tooltip/Tooltip.stories.d.ts +59 -0
  16. package/dist/cjs/types/components/Tooltip/TooltipSimple.d.ts +13 -0
  17. package/dist/cjs/types/icons/material-icon/outline/AllOutIcon.d.ts +3 -0
  18. package/dist/cjs/types/icons/material-icon/outline/FormatAlignCenterIcon.d.ts +3 -0
  19. package/dist/cjs/types/icons/material-icon/outline/FormatAlignJustifyIcon.d.ts +3 -0
  20. package/dist/cjs/types/icons/material-icon/outline/FormatAlignLeftIcon.d.ts +3 -0
  21. package/dist/cjs/types/icons/material-icon/outline/FormatAlignRightIcon.d.ts +3 -0
  22. package/dist/cjs/types/icons/material-icon/outline/FormatBoldIcon.d.ts +3 -0
  23. package/dist/cjs/types/icons/material-icon/outline/FormatItalicIcon.d.ts +3 -0
  24. package/dist/cjs/types/icons/material-icon/outline/FormatListBulletedIcon.d.ts +3 -0
  25. package/dist/cjs/types/icons/material-icon/outline/FormatListNumberedIcon.d.ts +3 -0
  26. package/dist/cjs/types/icons/material-icon/outline/FormatUnderlinedIcon.d.ts +3 -0
  27. package/dist/cjs/types/icons/material-icon/outline/index.d.ts +10 -0
  28. package/dist/cjs/types/icons/material-icon/solid/AllOutIcon.d.ts +3 -0
  29. package/dist/cjs/types/icons/material-icon/solid/FormatAlignCenterIcon.d.ts +3 -0
  30. package/dist/cjs/types/icons/material-icon/solid/FormatAlignJustifyIcon.d.ts +3 -0
  31. package/dist/cjs/types/icons/material-icon/solid/FormatAlignLeftIcon.d.ts +3 -0
  32. package/dist/cjs/types/icons/material-icon/solid/FormatAlignRightIcon.d.ts +3 -0
  33. package/dist/cjs/types/icons/material-icon/solid/FormatBoldIcon.d.ts +3 -0
  34. package/dist/cjs/types/icons/material-icon/solid/FormatItalicIcon.d.ts +3 -0
  35. package/dist/cjs/types/icons/material-icon/solid/FormatListBulletedIcon.d.ts +3 -0
  36. package/dist/cjs/types/icons/material-icon/solid/FormatListNumberedIcon.d.ts +3 -0
  37. package/dist/cjs/types/icons/material-icon/solid/FormatUnderlinedIcon.d.ts +3 -0
  38. package/dist/cjs/types/icons/material-icon/solid/index.d.ts +10 -0
  39. package/dist/cjs/types/index.d.ts +5 -0
  40. package/dist/components/AlertDialog/{Alert.stories.js → AlertDialog.stories.js} +13 -1
  41. package/dist/components/Checkbox/Checkbox.js +5 -4
  42. package/dist/components/Icon/Icon.stories.js +10 -0
  43. package/dist/components/Popover/Popover.js +1 -1
  44. package/dist/components/RadioGroup/RadioGroup.js +1 -4
  45. package/dist/components/Switch/Switch.js +1 -1
  46. package/dist/components/Text/Text.js +3 -5
  47. package/dist/components/Toast/Toast.js +52 -0
  48. package/dist/components/Toast/Toast.stories.js +82 -0
  49. package/dist/components/Toast/Toast.styles.js +60 -0
  50. package/dist/components/Toast/Toaster.js +24 -0
  51. package/dist/components/Toast/useToast.js +121 -0
  52. package/dist/components/Tooltip/Tooltip.js +26 -0
  53. package/dist/components/Tooltip/Tooltip.stories.js +61 -0
  54. package/dist/components/Tooltip/TooltipSimple.js +18 -0
  55. package/dist/esm/bundle.css +185 -37
  56. package/dist/esm/bundle.js +3 -3
  57. package/dist/esm/bundle.js.map +1 -1
  58. package/dist/esm/types/components/AlertDialog/{Alert.stories.d.ts → AlertDialog.stories.d.ts} +4 -0
  59. package/dist/esm/types/components/Calendar/Calendar.stories.d.ts +7 -7
  60. package/dist/esm/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
  61. package/dist/esm/types/components/Text/Text.d.ts +5 -6
  62. package/dist/esm/types/components/Text/Text.stories.d.ts +10 -2
  63. package/dist/esm/types/components/Toast/Toast.d.ts +17 -0
  64. package/dist/esm/types/components/Toast/Toast.stories.d.ts +358 -0
  65. package/dist/esm/types/components/Toast/Toast.styles.d.ts +12 -0
  66. package/dist/esm/types/components/Toast/Toaster.d.ts +1 -0
  67. package/dist/esm/types/components/Toast/useToast.d.ts +55 -0
  68. package/dist/esm/types/components/Tooltip/Tooltip.d.ts +8 -0
  69. package/dist/esm/types/components/Tooltip/Tooltip.stories.d.ts +59 -0
  70. package/dist/esm/types/components/Tooltip/TooltipSimple.d.ts +13 -0
  71. package/dist/esm/types/icons/material-icon/outline/AllOutIcon.d.ts +3 -0
  72. package/dist/esm/types/icons/material-icon/outline/FormatAlignCenterIcon.d.ts +3 -0
  73. package/dist/esm/types/icons/material-icon/outline/FormatAlignJustifyIcon.d.ts +3 -0
  74. package/dist/esm/types/icons/material-icon/outline/FormatAlignLeftIcon.d.ts +3 -0
  75. package/dist/esm/types/icons/material-icon/outline/FormatAlignRightIcon.d.ts +3 -0
  76. package/dist/esm/types/icons/material-icon/outline/FormatBoldIcon.d.ts +3 -0
  77. package/dist/esm/types/icons/material-icon/outline/FormatItalicIcon.d.ts +3 -0
  78. package/dist/esm/types/icons/material-icon/outline/FormatListBulletedIcon.d.ts +3 -0
  79. package/dist/esm/types/icons/material-icon/outline/FormatListNumberedIcon.d.ts +3 -0
  80. package/dist/esm/types/icons/material-icon/outline/FormatUnderlinedIcon.d.ts +3 -0
  81. package/dist/esm/types/icons/material-icon/outline/index.d.ts +10 -0
  82. package/dist/esm/types/icons/material-icon/solid/AllOutIcon.d.ts +3 -0
  83. package/dist/esm/types/icons/material-icon/solid/FormatAlignCenterIcon.d.ts +3 -0
  84. package/dist/esm/types/icons/material-icon/solid/FormatAlignJustifyIcon.d.ts +3 -0
  85. package/dist/esm/types/icons/material-icon/solid/FormatAlignLeftIcon.d.ts +3 -0
  86. package/dist/esm/types/icons/material-icon/solid/FormatAlignRightIcon.d.ts +3 -0
  87. package/dist/esm/types/icons/material-icon/solid/FormatBoldIcon.d.ts +3 -0
  88. package/dist/esm/types/icons/material-icon/solid/FormatItalicIcon.d.ts +3 -0
  89. package/dist/esm/types/icons/material-icon/solid/FormatListBulletedIcon.d.ts +3 -0
  90. package/dist/esm/types/icons/material-icon/solid/FormatListNumberedIcon.d.ts +3 -0
  91. package/dist/esm/types/icons/material-icon/solid/FormatUnderlinedIcon.d.ts +3 -0
  92. package/dist/esm/types/icons/material-icon/solid/index.d.ts +10 -0
  93. package/dist/esm/types/index.d.ts +5 -0
  94. package/dist/icons/material-icon/outline/AllOutIcon.js +3 -0
  95. package/dist/icons/material-icon/outline/FormatAlignCenterIcon.js +3 -0
  96. package/dist/icons/material-icon/outline/FormatAlignJustifyIcon.js +3 -0
  97. package/dist/icons/material-icon/outline/FormatAlignLeftIcon.js +3 -0
  98. package/dist/icons/material-icon/outline/FormatAlignRightIcon.js +3 -0
  99. package/dist/icons/material-icon/outline/FormatBoldIcon.js +3 -0
  100. package/dist/icons/material-icon/outline/FormatItalicIcon.js +3 -0
  101. package/dist/icons/material-icon/outline/FormatListBulletedIcon.js +3 -0
  102. package/dist/icons/material-icon/outline/FormatListNumberedIcon.js +3 -0
  103. package/dist/icons/material-icon/outline/FormatUnderlinedIcon.js +3 -0
  104. package/dist/icons/material-icon/outline/index.js +10 -0
  105. package/dist/icons/material-icon/solid/AllOutIcon.js +3 -0
  106. package/dist/icons/material-icon/solid/FormatAlignCenterIcon.js +3 -0
  107. package/dist/icons/material-icon/solid/FormatAlignJustifyIcon.js +3 -0
  108. package/dist/icons/material-icon/solid/FormatAlignLeftIcon.js +3 -0
  109. package/dist/icons/material-icon/solid/FormatAlignRightIcon.js +3 -0
  110. package/dist/icons/material-icon/solid/FormatBoldIcon.js +3 -0
  111. package/dist/icons/material-icon/solid/FormatItalicIcon.js +3 -0
  112. package/dist/icons/material-icon/solid/FormatListBulletedIcon.js +3 -0
  113. package/dist/icons/material-icon/solid/FormatListNumberedIcon.js +3 -0
  114. package/dist/icons/material-icon/solid/FormatUnderlinedIcon.js +3 -0
  115. package/dist/icons/material-icon/solid/index.js +10 -0
  116. package/dist/index.d.ts +94 -6
  117. package/dist/index.js +5 -0
  118. package/dist/src/theme/global.css +230 -46
  119. package/dist/theme/themes/xspector/state.css +1 -1
  120. package/package.json +4 -1
  121. package/src/components/AlertDialog/{Alert.stories.tsx → AlertDialog.stories.tsx} +41 -1
  122. package/src/components/Checkbox/Checkbox.tsx +9 -4
  123. package/src/components/Icon/Icon.stories.tsx +10 -0
  124. package/src/components/Popover/Popover.tsx +1 -1
  125. package/src/components/RadioGroup/RadioGroup.tsx +6 -7
  126. package/src/components/Switch/Switch.tsx +8 -5
  127. package/src/components/Text/Text.tsx +33 -40
  128. package/src/components/Toast/Toast.stories.tsx +144 -0
  129. package/src/components/Toast/Toast.styles.tsx +73 -0
  130. package/src/components/Toast/Toast.tsx +116 -0
  131. package/src/components/Toast/Toaster.tsx +50 -0
  132. package/src/components/Toast/useToast.ts +222 -0
  133. package/src/components/Tooltip/Tooltip.stories.tsx +152 -0
  134. package/src/components/Tooltip/Tooltip.tsx +38 -0
  135. package/src/components/Tooltip/TooltipSimple.tsx +46 -0
  136. package/src/icons/material-icon/outline/AllOutIcon.tsx +20 -0
  137. package/src/icons/material-icon/outline/FormatAlignCenterIcon.tsx +20 -0
  138. package/src/icons/material-icon/outline/FormatAlignJustifyIcon.tsx +20 -0
  139. package/src/icons/material-icon/outline/FormatAlignLeftIcon.tsx +20 -0
  140. package/src/icons/material-icon/outline/FormatAlignRightIcon.tsx +20 -0
  141. package/src/icons/material-icon/outline/FormatBoldIcon.tsx +20 -0
  142. package/src/icons/material-icon/outline/FormatItalicIcon.tsx +20 -0
  143. package/src/icons/material-icon/outline/FormatListBulletedIcon.tsx +20 -0
  144. package/src/icons/material-icon/outline/FormatListNumberedIcon.tsx +20 -0
  145. package/src/icons/material-icon/outline/FormatUnderlinedIcon.tsx +20 -0
  146. package/src/icons/material-icon/outline/index.ts +10 -0
  147. package/src/icons/material-icon/solid/AllOutIcon.tsx +20 -0
  148. package/src/icons/material-icon/solid/FormatAlignCenterIcon.tsx +20 -0
  149. package/src/icons/material-icon/solid/FormatAlignJustifyIcon.tsx +20 -0
  150. package/src/icons/material-icon/solid/FormatAlignLeftIcon.tsx +20 -0
  151. package/src/icons/material-icon/solid/FormatAlignRightIcon.tsx +20 -0
  152. package/src/icons/material-icon/solid/FormatBoldIcon.tsx +20 -0
  153. package/src/icons/material-icon/solid/FormatItalicIcon.tsx +20 -0
  154. package/src/icons/material-icon/solid/FormatListBulletedIcon.tsx +20 -0
  155. package/src/icons/material-icon/solid/FormatListNumberedIcon.tsx +20 -0
  156. package/src/icons/material-icon/solid/FormatUnderlinedIcon.tsx +20 -0
  157. package/src/icons/material-icon/solid/index.ts +10 -0
  158. package/src/index.ts +5 -0
  159. package/src/theme/themes/xspector/state.css +1 -1
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from "react";
2
+ interface TooltipProps {
3
+ children: ReactNode;
4
+ content: ReactNode;
5
+ open?: boolean;
6
+ defaultOpen?: boolean;
7
+ onOpenChange?: (open: boolean) => void;
8
+ side?: "top" | "bottom" | "left" | "right";
9
+ align?: "start" | "center" | "end";
10
+ className?: string;
11
+ }
12
+ export declare function TooltipSimple({ children, content, open, defaultOpen, onOpenChange, ...props }: TooltipProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const AllOutIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default AllOutIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignCenterIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignCenterIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignJustifyIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignJustifyIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignLeftIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignLeftIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignRightIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignRightIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatBoldIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatBoldIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatItalicIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatItalicIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatListBulletedIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatListBulletedIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatListNumberedIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatListNumberedIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatUnderlinedIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatUnderlinedIcon;
@@ -10,3 +10,13 @@ export { default as ExpandCircleUpIcon } from "./ExpandCircleUpIcon";
10
10
  export { default as ContentCopyIcon } from "./ContentCopyIcon";
11
11
  export { default as ContentPasteIcon } from "./ContentPasteIcon";
12
12
  export { default as ChevronDownIcon } from "./ChevronDownIcon";
13
+ export { default as FormatBoldIcon } from "./FormatBoldIcon";
14
+ export { default as FormatItalicIcon } from "./FormatItalicIcon";
15
+ export { default as FormatUnderlinedIcon } from "./FormatUnderlinedIcon";
16
+ export { default as FormatAlignLeftIcon } from "./FormatAlignLeftIcon";
17
+ export { default as FormatAlignCenterIcon } from "./FormatAlignCenterIcon";
18
+ export { default as FormatAlignRightIcon } from "./FormatAlignRightIcon";
19
+ export { default as FormatAlignJustifyIcon } from "./FormatAlignJustifyIcon";
20
+ export { default as FormatListBulletedIcon } from "./FormatListBulletedIcon";
21
+ export { default as FormatListNumberedIcon } from "./FormatListNumberedIcon";
22
+ export { default as AllOutIcon } from "./AllOutIcon";
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const AllOutIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default AllOutIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignCenterIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignCenterIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignJustifyIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignJustifyIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignLeftIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignLeftIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatAlignRightIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatAlignRightIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatBoldIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatBoldIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatItalicIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatItalicIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatListBulletedIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatListBulletedIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatListNumberedIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatListNumberedIcon;
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ declare const FormatUnderlinedIcon: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormatUnderlinedIcon;
@@ -10,3 +10,13 @@ export { default as ExpandCircleUpIcon } from "./ExpandCircleUpIcon";
10
10
  export { default as ContentCopyIcon } from "./ContentCopyIcon";
11
11
  export { default as ContentPasteIcon } from "./ContentPasteIcon";
12
12
  export { default as ChevronDownIcon } from "./ChevronDownIcon";
13
+ export { default as FormatBoldIcon } from "./FormatBoldIcon";
14
+ export { default as FormatItalicIcon } from "./FormatItalicIcon";
15
+ export { default as FormatUnderlinedIcon } from "./FormatUnderlinedIcon";
16
+ export { default as FormatAlignLeftIcon } from "./FormatAlignLeftIcon";
17
+ export { default as FormatAlignCenterIcon } from "./FormatAlignCenterIcon";
18
+ export { default as FormatAlignRightIcon } from "./FormatAlignRightIcon";
19
+ export { default as FormatAlignJustifyIcon } from "./FormatAlignJustifyIcon";
20
+ export { default as FormatListBulletedIcon } from "./FormatListBulletedIcon";
21
+ export { default as FormatListNumberedIcon } from "./FormatListNumberedIcon";
22
+ export { default as AllOutIcon } from "./AllOutIcon";
@@ -26,6 +26,11 @@ export * from "./components/Search/Search";
26
26
  export * from "./components/Slider/Slider";
27
27
  export * from "./components/Switch/Switch";
28
28
  export * from "./components/DropdownMenu/DropdownMenu";
29
+ export * from "./components/Tooltip/Tooltip";
30
+ export * from "./components/Tooltip/TooltipSimple";
31
+ export * from "./components/Toast/Toast";
32
+ export * from "./components/Toast/Toaster";
33
+ export * from "./components/Toast/useToast";
29
34
  export type { ButtonProps } from "./components/Button/Button";
30
35
  export type { InputProps } from "./components/TextInput/TextInput";
31
36
  export type { DropdownProps, Options } from "./components/Dropdown/Dropdown";
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "./AlertDialog";
3
3
  // More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
4
4
  const meta = {
5
- title: "Components/Alert",
5
+ title: "Components/AlertDialog",
6
6
  component: AlertDialog,
7
7
  tags: ["autodocs"],
8
8
  parameters: {
@@ -26,3 +26,15 @@ export const Default = {
26
26
  return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsxs(AlertDialog, { children: [_jsx(AlertDialogTrigger, { children: "Open" }), _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Are you absolutely sure?" }), _jsx(AlertDialogDescription, { children: "This action cannot be undone. This will permanently delete your account and remove your data from our servers." })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Cancel" }), _jsx(AlertDialogAction, { children: "Continue" })] })] })] }) }));
27
27
  },
28
28
  };
29
+ export const CustomStyle = {
30
+ args: {
31
+ // label: "Lorem Ipsum",
32
+ // value: "Lorem Ipsum",
33
+ // fullwidth: true,
34
+ },
35
+ render: (args) => {
36
+ console.log("args ", args);
37
+ const props = Object.assign({}, args);
38
+ return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsxs(AlertDialog, { children: [_jsx(AlertDialogTrigger, { children: "Open" }), _jsxs(AlertDialogContent, { className: "justify-center text-center", children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { className: "text-center", children: "Are you absolutely sure?" }), _jsx(AlertDialogDescription, { className: "text-center", children: "This action cannot be undone. This will permanently delete your account and remove your data from our servers." })] }), _jsxs(AlertDialogFooter, { className: "flex sm:justify-stretch", children: [_jsx(AlertDialogCancel, { className: "flex-1 justify-center", children: "Cancel" }), _jsx(AlertDialogAction, { className: "flex-1 justify-center", children: "Continue" })] })] })] }) }));
39
+ },
40
+ };
@@ -17,10 +17,11 @@ import { CheckIcon } from "@heroicons/react/16/solid";
17
17
  import { cn } from "@/utils/cn";
18
18
  const Checkbox = React.forwardRef((_a, ref) => {
19
19
  var { className } = _a, props = __rest(_a, ["className"]);
20
- return (_jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary-30 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:border-state-disable-solid", {
21
- "data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground": !props.disabled,
22
- "bg-grey2-300": props.checked && props.disabled,
23
- }, className) }, props, { children: _jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: _jsx(CheckIcon, { className: "h-4 w-4" }) }) })));
20
+ return (_jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer size-4 shrink-0 rounded-[var(--spacing-spacing-xxs,2px)] border border-primary ring-offset-background", "hover:border-primary-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:border-state-disable-solid disabled:text-state-disable-outline", {
21
+ "data-[state=checked]:border-secondary data-[state=checked]:bg-secondary data-[state=checked]:text-secondary-foreground": !props.disabled,
22
+ "hover:data-[state=checked]:border-secondary-hover hover:data-[state=checked]:bg-secondary-hover": !props.disabled,
23
+ "bg-state-disable-solid": props.checked && props.disabled,
24
+ }, className) }, props, { children: _jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: _jsx(CheckIcon, { className: "size-4" }) }) })));
24
25
  });
25
26
  Checkbox.displayName = CheckboxPrimitive.Root.displayName;
26
27
  export { Checkbox };
@@ -350,6 +350,16 @@ export const PreviewMaterialIcon = {
350
350
  "expand-circle-up",
351
351
  "content-copy",
352
352
  "content-paste",
353
+ "format-bold",
354
+ "format-italic",
355
+ "format-underlined",
356
+ "format-align-left",
357
+ "format-align-center",
358
+ "format-align-right",
359
+ "format-align-justify",
360
+ "format-list-bulleted",
361
+ "format-list-numbered",
362
+ "all-out",
353
363
  ];
354
364
  return (_jsx("div", { className: "grid grid-cols-1 gap-4 w-full h-full", children: _jsxs("div", { className: "flex flex-col justify-start gap-4 w-full h-full", children: [_jsx("h4", { children: "Material icons" }), materialIcon.map((iconName) => (_jsxs("div", { className: "flex flex-row gap-6 items-center", children: [_jsx(Icon, Object.assign({}, props, { type: "material", name: iconName, variant: "solid", size: "sm" })), _jsx(Icon, Object.assign({}, props, { type: "material", name: iconName, variant: "outline", size: "sm" })), _jsx(Icon, Object.assign({}, props, { type: "material", name: iconName, variant: "outline", size: "md" })), _jsx(Icon, Object.assign({}, props, { type: "material", name: iconName, variant: "solid", size: "md" })), _jsx(Icon, Object.assign({}, props, { type: "material", name: iconName, variant: "outline", size: "lg" })), _jsx(Icon, Object.assign({}, props, { type: "material", name: iconName, variant: "solid", size: "lg" })), _jsx("p", { className: "ml-4", children: iconName })] }, iconName)))] }) }));
355
365
  },
@@ -18,7 +18,7 @@ const Popover = PopoverPrimitive.Root;
18
18
  const PopoverTrigger = PopoverPrimitive.Trigger;
19
19
  const PopoverContent = React.forwardRef((_a, ref) => {
20
20
  var { className, align = "center", sideOffset = 4 } = _a, props = __rest(_a, ["className", "align", "sideOffset"]);
21
- return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, Object.assign({ ref: ref, align: align, sideOffset: sideOffset, className: cn("z-50 min-w-72 rounded-md border bg-base-popup-highlight border-none overflow-hidden p-0 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props)) }));
21
+ return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, Object.assign({ ref: ref, align: align, sideOffset: sideOffset, className: cn("z-50 min-w-72 rounded-md border bg-surface border-none overflow-hidden p-0 text-surface-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props)) }));
22
22
  });
23
23
  PopoverContent.displayName = PopoverPrimitive.Content.displayName;
24
24
  export { Popover, PopoverTrigger, PopoverContent };
@@ -21,10 +21,7 @@ const RadioGroup = React.forwardRef((_a, ref) => {
21
21
  RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
22
22
  const RadioGroupItem = React.forwardRef((_a, ref) => {
23
23
  var { className } = _a, props = __rest(_a, ["className"]);
24
- return (_jsx(RadioGroupPrimitive.Item, Object.assign({ ref: ref, className: cn("aspect-square h-4 w-4 rounded-full border text-primary disabled:fill-state-disable-solid ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:state-disable-solid", {
25
- "border-primary-30 data-[state=checked]:border-primary": !props.disabled,
26
- "border-state-disable-solid data-disabled:border-state-disable-solid text-state-disable-solid fill-state-disable-solid": props.disabled,
27
- }, className) }, props, { children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "fill-current text-current", children: _jsx("circle", { cx: "5", cy: "5", r: "5", fill: "current" }) }) }) })));
24
+ return (_jsx(RadioGroupPrimitive.Item, Object.assign({ ref: ref, className: cn("aspect-square box-border size-4 rounded-full border border-primary text-primary", "hover:border-primary-hover", "focus:outline-none", "data-[state=checked]:border-secondary data-[state=checked]:text-secondary", "hover:data-[state=checked]:border-secondary-hover hover:data-[state=checked]:text-secondary-hover", "data-[disabled]:border-state-disable-solid data-[disabled]:fill-state-disable-solid data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none data-[disabled]:text-state-disable-solid", className) }, props, { children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "fill-current text-current", children: _jsx("circle", { cx: "5", cy: "5", r: "5", fill: "current" }) }) }) })));
28
25
  });
29
26
  RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
30
27
  export { RadioGroup, RadioGroupItem };
@@ -16,7 +16,7 @@ import * as SwitchPrimitives from "@radix-ui/react-switch";
16
16
  import { cn } from "@/utils/cn";
17
17
  const Switch = React.forwardRef((_a, ref) => {
18
18
  var { className } = _a, props = __rest(_a, ["className"]);
19
- return (_jsx(SwitchPrimitives.Root, Object.assign({ className: cn("peer inline-flex h-3 w-[32px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", "disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-secondary-active/[0.32] data-[state=unchecked]:bg-tertiary-active/[0.32]", className) }, props, { ref: ref, children: _jsx(SwitchPrimitives.Thumb, { className: cn("pointer-events-none block size-4 rounded-full bg-secondary-active shadow-lg ring-0", "transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:-translate-x-[2px] data-[state=unchecked]:bg-tertiary-active") }) })));
19
+ return (_jsx(SwitchPrimitives.Root, Object.assign({ className: cn("group inline-flex h-3 w-[32px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors", "data-[state=checked]:bg-secondary-active/[0.32] data-[state=unchecked]:bg-tertiary-active/[0.32]", "hover:data-[state=checked]:bg-secondary-active/[0.48] hover:data-[state=unchecked]:bg-tertiary-active/[0.48]", "data-[disabled]:cursor-not-allowed data-[disabled]:bg-state-disable-solid/[0.32] data-[disabled]:pointer-events-none ", className) }, props, { ref: ref, children: _jsx(SwitchPrimitives.Thumb, { className: cn(" block size-4 rounded-full bg-secondary-active shadow-lg transition-transform", "data-[state=checked]:translate-x-4 data-[state=unchecked]:-translate-x-[2px] data-[state=unchecked]:bg-tertiary-active", "group-hover:ring group-hover:data-[state=checked]:ring-secondary-hover-bg group-hover:data-[state=unchecked]:ring-tertiary-hover-bg", "group-disabled:bg-state-disable-solid") }) })));
20
20
  });
21
21
  Switch.displayName = SwitchPrimitives.Root.displayName;
22
22
  export { Switch };
@@ -29,10 +29,8 @@ const textVariants = cva(["text-foreground"], {
29
29
  // montserrat: ["Montserrat", "sans-serif"],
30
30
  // poppins: ["Poppins", "sans-serif"], font-montserrat, font-poppins
31
31
  // TODO font, fontBold, elipt
32
- const Text = (_a, ref) => {
32
+ const Text = forwardRef((_a, ref) => {
33
33
  var { variant = "body1", tag: Tag = "p", children, className = "", color, style } = _a, props = __rest(_a, ["variant", "tag", "children", "className", "color", "style"]);
34
34
  return (_jsx(Tag, Object.assign({ ref: ref, className: cn(`typography-${variant}`, textVariants({ color }), className), style: style }, props, { children: children })));
35
- };
36
- const ForwardedText = forwardRef(Text);
37
- ForwardedText.displayName = "Text";
38
- export default ForwardedText;
35
+ });
36
+ export default Text;
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import * as React from "react";
15
+ import * as ToastPrimitives from "@radix-ui/react-toast";
16
+ import { cn } from "@/utils/cn";
17
+ import Icon from "../Icon/Icon";
18
+ import { toastVariants, toastViewportVariants } from "./Toast.styles";
19
+ import ActionButton from "../ActionButton/ActionButton";
20
+ import Button from "../Button/Button";
21
+ const ToastProvider = ToastPrimitives.Provider;
22
+ const ToastViewport = React.forwardRef((_a, ref) => {
23
+ var { className, position } = _a, props = __rest(_a, ["className", "position"]);
24
+ return (_jsx(ToastPrimitives.Viewport, Object.assign({ ref: ref, className: cn(toastViewportVariants({ position }), className) }, props)));
25
+ });
26
+ ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
27
+ const Toast = React.forwardRef((_a, ref) => {
28
+ var { className, variant } = _a, props = __rest(_a, ["className", "variant"]);
29
+ return (_jsx(ToastPrimitives.Root, Object.assign({ ref: ref, className: cn(toastVariants({ variant }), className) }, props)));
30
+ });
31
+ Toast.displayName = ToastPrimitives.Root.displayName;
32
+ const ToastAction = React.forwardRef((_a, ref) => {
33
+ var { className, children } = _a, props = __rest(_a, ["className", "children"]);
34
+ return (_jsx(ToastPrimitives.Action, Object.assign({ ref: ref, className: cn("", className) }, props, { asChild: true, children: _jsx(Button, { variant: "outline", size: "sm", children: children }) })));
35
+ });
36
+ ToastAction.displayName = ToastPrimitives.Action.displayName;
37
+ const ToastClose = React.forwardRef((_a, ref) => {
38
+ var { className } = _a, props = __rest(_a, ["className"]);
39
+ return (_jsx(ToastPrimitives.Close, Object.assign({ ref: ref, className: cn("-mr-2 self-center text-input-default-text", className), "toast-close": "" }, props, { asChild: true, children: _jsx(ActionButton, { variant: "icon", size: "sm", children: _jsx(Icon, { type: "heroicons", name: "xmark" }) }) })));
40
+ });
41
+ ToastClose.displayName = ToastPrimitives.Close.displayName;
42
+ const ToastTitle = React.forwardRef((_a, ref) => {
43
+ var { className } = _a, props = __rest(_a, ["className"]);
44
+ return (_jsx(ToastPrimitives.Title, Object.assign({ ref: ref, className: cn("typography-subtitile6", className) }, props)));
45
+ });
46
+ ToastTitle.displayName = ToastPrimitives.Title.displayName;
47
+ const ToastDescription = React.forwardRef((_a, ref) => {
48
+ var { className } = _a, props = __rest(_a, ["className"]);
49
+ return (_jsx(ToastPrimitives.Description, Object.assign({ ref: ref, className: cn("typography-subtitile5 text-text-grey-dark", className) }, props)));
50
+ });
51
+ ToastDescription.displayName = ToastPrimitives.Description.displayName;
52
+ export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction, };
@@ -0,0 +1,82 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { Toast, ToastAction } from "./Toast";
4
+ import { Toaster } from "./Toaster";
5
+ import { useToast } from "./useToast";
6
+ import Button from "../Button/Button";
7
+ const meta = {
8
+ title: "Components/Toast",
9
+ component: Toast,
10
+ tags: ["autodocs"],
11
+ parameters: {
12
+ layout: "fullscreen",
13
+ },
14
+ decorators: [
15
+ (Story) => (_jsx("div", { className: "flex max-h-screen w-full", children: _jsx(Story, {}) })),
16
+ ],
17
+ };
18
+ export default meta;
19
+ export const Simple = {
20
+ argTypes: {
21
+ variant: {
22
+ control: "select",
23
+ options: ["default", "success", "info", "warning", "error"],
24
+ },
25
+ contentMode: {
26
+ control: "select",
27
+ options: ["horizontal", "vertical"],
28
+ },
29
+ position: {
30
+ control: "select",
31
+ options: [
32
+ "top-center",
33
+ "top-left",
34
+ "top-right",
35
+ "bottom-center",
36
+ "bottom-left",
37
+ "bottom-right",
38
+ ],
39
+ },
40
+ },
41
+ args: {
42
+ variant: "default",
43
+ contentMode: "horizontal",
44
+ position: "top-center",
45
+ },
46
+ render: (args) => {
47
+ console.log("args ", args);
48
+ const props = Object.assign({}, args);
49
+ const { toast } = useToast({
50
+ position: props.position,
51
+ });
52
+ useEffect(() => {
53
+ toast({
54
+ variant: props.variant,
55
+ title: "Success",
56
+ description: "This is an Info alert — check it out!",
57
+ contentMode: props.contentMode,
58
+ });
59
+ }, [props.variant, props.contentMode]);
60
+ return (_jsxs("div", { className: "flex flex-row gap-4 w-full", children: [_jsx(Toaster, {}), _jsx(Button, { onClick: () => {
61
+ toast({
62
+ title: "Scheduled: Catch up",
63
+ description: "Friday, February 10, 2023 at 5:57 PM",
64
+ });
65
+ }, children: "Show Toast" })] }));
66
+ },
67
+ };
68
+ export const WithAction = {
69
+ args: {},
70
+ render: (args) => {
71
+ console.log("args ", args);
72
+ const props = Object.assign({}, args);
73
+ const { toast } = useToast();
74
+ return (_jsxs("div", { className: "flex flex-row gap-4 w-full", children: [_jsx(Toaster, {}), _jsx(Button, { onClick: () => {
75
+ toast({
76
+ title: "Uh oh! Something went wrong.",
77
+ description: "There was a problem with your request.",
78
+ action: (_jsx(ToastAction, { altText: "Try again", onClick: () => alert("My action"), children: "Try again" })),
79
+ });
80
+ }, children: "Show Toast" })] }));
81
+ },
82
+ };
@@ -0,0 +1,60 @@
1
+ import { cva } from "class-variance-authority";
2
+ export const toastVariants = cva([
3
+ "group pointer-events-auto relative flex w-full",
4
+ "rounded-md shadow-lg px-4 py-3 gap-1",
5
+ "transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
6
+ "bg-base-popup text-base-popup-foreground",
7
+ ], {
8
+ variants: {
9
+ variant: {
10
+ default: "border",
11
+ success: "border border-success-stroke",
12
+ info: "border border-info-stroke",
13
+ warning: "border border-warning-stroke",
14
+ error: "border border-error-stroke",
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ variant: "success",
19
+ },
20
+ });
21
+ export const toastViewportVariants = cva(["fixed z-[100] flex w-full md:w-auto flex-col-reverse px-4"], {
22
+ variants: {
23
+ position: {
24
+ "top-center": "top-[40px] left-0 right-0 justify-self-center",
25
+ "top-left": "top-[40px] left-0 md:left-[40px]",
26
+ "top-right": "top-[40px] right-0 md:right-[40px]",
27
+ "bottom-center": "bottom-[40px] left-0 right-0 justify-self-center",
28
+ "bottom-left": "bottom-[40px] left-0 md:left-[40px]",
29
+ "bottom-right": "bottom-[40px] right-0 md:right-[40px]",
30
+ },
31
+ },
32
+ defaultVariants: {
33
+ position: "top-center",
34
+ },
35
+ });
36
+ export const toastIconVariants = cva(["flex items-center justify-center mr-2 rounded-full size-7"], {
37
+ variants: {
38
+ variant: {
39
+ default: "",
40
+ success: "bg-success-transparent-8 text-success",
41
+ info: "bg-info-transparent-8 text-info",
42
+ warning: "bg-warning-transparent-8 text-warning",
43
+ error: "bg-error-transparent-8 text-error",
44
+ },
45
+ },
46
+ defaultVariants: {
47
+ variant: "success",
48
+ },
49
+ });
50
+ export const toastContentVariants = cva(["flex flex-1"], {
51
+ variants: {
52
+ contentMode: {
53
+ horizontal: "items-center flex-row gap-2",
54
+ vertical: "flex-col gap-[2px]",
55
+ },
56
+ },
57
+ defaultVariants: {
58
+ contentMode: "vertical",
59
+ },
60
+ });
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, } from "./Toast";
15
+ import { useToast } from "./useToast";
16
+ import Icon from "../Icon/Icon";
17
+ import { toastContentVariants, toastIconVariants } from "./Toast.styles";
18
+ export function Toaster() {
19
+ const { toasts, position } = useToast();
20
+ return (_jsxs(ToastProvider, { children: [toasts.map(function (_a) {
21
+ var { id, title, description, action, contentMode } = _a, props = __rest(_a, ["id", "title", "description", "action", "contentMode"]);
22
+ return (_jsxs(Toast, Object.assign({}, props, { children: [_jsx("div", { className: toastIconVariants({ variant: props.variant }), children: _jsx(Icon, { type: "heroicons", name: "check-circle", className: "size-6" }) }), _jsxs("div", { className: toastContentVariants({ contentMode }), children: [title && _jsx(ToastTitle, { children: title }), description && (_jsx(ToastDescription, { children: description }))] }), _jsx("div", { className: "self-center ml-[var(--spacing-spacing-xl)]", children: action }), _jsx(ToastClose, {})] }), id));
23
+ }), _jsx(ToastViewport, { position: position })] }));
24
+ }
@@ -0,0 +1,121 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ // Inspired by react-hot-toast library
14
+ import * as React from "react";
15
+ const TOAST_LIMIT = 1;
16
+ const TOAST_REMOVE_DELAY = 6000;
17
+ const actionTypes = {
18
+ ADD_TOAST: "ADD_TOAST",
19
+ UPDATE_TOAST: "UPDATE_TOAST",
20
+ DISMISS_TOAST: "DISMISS_TOAST",
21
+ REMOVE_TOAST: "REMOVE_TOAST",
22
+ ADD_POSITION: "ADD_POSITION",
23
+ };
24
+ let count = 0;
25
+ function genId() {
26
+ count = (count + 1) % Number.MAX_SAFE_INTEGER;
27
+ return count.toString();
28
+ }
29
+ const toastTimeouts = new Map();
30
+ const addToRemoveQueue = (toastId) => {
31
+ if (toastTimeouts.has(toastId)) {
32
+ return;
33
+ }
34
+ const timeout = setTimeout(() => {
35
+ toastTimeouts.delete(toastId);
36
+ dispatch({
37
+ type: "REMOVE_TOAST",
38
+ toastId: toastId,
39
+ });
40
+ }, TOAST_REMOVE_DELAY);
41
+ toastTimeouts.set(toastId, timeout);
42
+ };
43
+ export const reducer = (state, action) => {
44
+ switch (action.type) {
45
+ case "ADD_TOAST":
46
+ return Object.assign(Object.assign({}, state), { toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT) });
47
+ case "UPDATE_TOAST":
48
+ return Object.assign(Object.assign({}, state), { toasts: state.toasts.map((t) => t.id === action.toast.id ? Object.assign(Object.assign({}, t), action.toast) : t) });
49
+ case "DISMISS_TOAST": {
50
+ const { toastId } = action;
51
+ // ! Side effects ! - This could be extracted into a dismissToast() action,
52
+ // but I'll keep it here for simplicity
53
+ if (toastId) {
54
+ addToRemoveQueue(toastId);
55
+ }
56
+ else {
57
+ state.toasts.forEach((toast) => {
58
+ addToRemoveQueue(toast.id);
59
+ });
60
+ }
61
+ return Object.assign(Object.assign({}, state), { toasts: state.toasts.map((t) => t.id === toastId || toastId === undefined
62
+ ? Object.assign(Object.assign({}, t), { open: false }) : t) });
63
+ }
64
+ case "REMOVE_TOAST":
65
+ if (action.toastId === undefined) {
66
+ return Object.assign(Object.assign({}, state), { toasts: [] });
67
+ }
68
+ return Object.assign(Object.assign({}, state), { toasts: state.toasts.filter((t) => t.id !== action.toastId) });
69
+ case "ADD_POSITION":
70
+ return Object.assign(Object.assign({}, state), { position: action.position });
71
+ }
72
+ };
73
+ const listeners = [];
74
+ let memoryState = { toasts: [], position: undefined };
75
+ function dispatch(action) {
76
+ memoryState = reducer(memoryState, action);
77
+ listeners.forEach((listener) => {
78
+ listener(memoryState);
79
+ });
80
+ }
81
+ function toast(_a) {
82
+ var props = __rest(_a, []);
83
+ const id = genId();
84
+ const update = (props) => dispatch({
85
+ type: "UPDATE_TOAST",
86
+ toast: Object.assign(Object.assign({}, props), { id }),
87
+ });
88
+ const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
89
+ dispatch({
90
+ type: "ADD_TOAST",
91
+ toast: Object.assign(Object.assign({}, props), { id, open: true, onOpenChange: (open) => {
92
+ if (!open)
93
+ dismiss();
94
+ } }),
95
+ });
96
+ return {
97
+ id: id,
98
+ dismiss,
99
+ update,
100
+ };
101
+ }
102
+ function useToast(options) {
103
+ const [state, setState] = React.useState(memoryState);
104
+ React.useEffect(() => {
105
+ listeners.push(setState);
106
+ return () => {
107
+ const index = listeners.indexOf(setState);
108
+ if (index > -1) {
109
+ listeners.splice(index, 1);
110
+ }
111
+ };
112
+ }, [state]);
113
+ React.useEffect(() => {
114
+ dispatch({
115
+ type: "ADD_POSITION",
116
+ position: options === null || options === void 0 ? void 0 : options.position,
117
+ });
118
+ }, [options === null || options === void 0 ? void 0 : options.position]);
119
+ return Object.assign(Object.assign({}, state), { toast, dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId }) });
120
+ }
121
+ export { useToast, toast };