@sikka/hawa 0.26.31 → 0.26.33

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 (218) hide show
  1. package/dist/{Toast-pOd4uGZz.d.ts → Toast-YaClwi7z.d.ts} +9 -1
  2. package/dist/{Toast-VBd4UvlM.d.mts → Toast-ySvjL_-K.d.mts} +9 -1
  3. package/dist/accordion/index.mjs +7 -4
  4. package/dist/accordion/index.mjs.map +1 -1
  5. package/dist/alert/index.js +4 -4
  6. package/dist/alert/index.js.map +1 -1
  7. package/dist/alert/index.mjs +11 -8
  8. package/dist/alert/index.mjs.map +1 -1
  9. package/dist/appLayout/index.js +2 -1
  10. package/dist/appLayout/index.js.map +1 -1
  11. package/dist/appLayout/index.mjs +9 -5
  12. package/dist/appLayout/index.mjs.map +1 -1
  13. package/dist/appMenubar/index.mjs +9 -4
  14. package/dist/appMenubar/index.mjs.map +1 -1
  15. package/dist/appTabs/index.mjs +9 -4
  16. package/dist/appTabs/index.mjs.map +1 -1
  17. package/dist/appTopbar/index.mjs +9 -4
  18. package/dist/appTopbar/index.mjs.map +1 -1
  19. package/dist/avatar/index.js +2 -1
  20. package/dist/avatar/index.js.map +1 -1
  21. package/dist/avatar/index.mjs +9 -5
  22. package/dist/avatar/index.mjs.map +1 -1
  23. package/dist/backToTop/index.js +6 -3
  24. package/dist/backToTop/index.js.map +1 -1
  25. package/dist/backToTop/index.mjs +13 -7
  26. package/dist/backToTop/index.mjs.map +1 -1
  27. package/dist/badge/index.js +4 -3
  28. package/dist/badge/index.js.map +1 -1
  29. package/dist/badge/index.mjs +13 -7
  30. package/dist/badge/index.mjs.map +1 -1
  31. package/dist/button/index.mjs +7 -4
  32. package/dist/button/index.mjs.map +1 -1
  33. package/dist/card/index.mjs +9 -4
  34. package/dist/card/index.mjs.map +1 -1
  35. package/dist/carousel/index.js +10 -10
  36. package/dist/carousel/index.js.map +1 -1
  37. package/dist/carousel/index.mjs +19 -14
  38. package/dist/carousel/index.mjs.map +1 -1
  39. package/dist/checkbox/index.mjs +9 -4
  40. package/dist/checkbox/index.mjs.map +1 -1
  41. package/dist/chip/index.mjs +9 -4
  42. package/dist/chip/index.mjs.map +1 -1
  43. package/dist/chunk-A3ERTYS4.mjs +29 -0
  44. package/dist/codeBlock/index.js +1 -1
  45. package/dist/codeBlock/index.js.map +1 -1
  46. package/dist/codeBlock/index.mjs +84 -24
  47. package/dist/codeBlock/index.mjs.map +1 -1
  48. package/dist/collapsible/index.mjs +0 -2
  49. package/dist/collapsible/index.mjs.map +1 -1
  50. package/dist/colorPicker/index.js +2 -1
  51. package/dist/colorPicker/index.js.map +1 -1
  52. package/dist/colorPicker/index.mjs +92 -20
  53. package/dist/colorPicker/index.mjs.map +1 -1
  54. package/dist/combobox/index.js +4 -3
  55. package/dist/combobox/index.js.map +1 -1
  56. package/dist/combobox/index.mjs +445 -27
  57. package/dist/combobox/index.mjs.map +1 -1
  58. package/dist/command/index.mjs +429 -11
  59. package/dist/command/index.mjs.map +1 -1
  60. package/dist/dataTable/index.js +36 -27
  61. package/dist/dataTable/index.js.map +1 -1
  62. package/dist/dataTable/index.mjs +43 -31
  63. package/dist/dataTable/index.mjs.map +1 -1
  64. package/dist/destroyableCard/index.js +2 -2
  65. package/dist/destroyableCard/index.js.map +1 -1
  66. package/dist/destroyableCard/index.mjs +9 -6
  67. package/dist/destroyableCard/index.mjs.map +1 -1
  68. package/dist/dialog/index.mjs +9 -4
  69. package/dist/dialog/index.mjs.map +1 -1
  70. package/dist/docsLayout/index.js +2 -2
  71. package/dist/docsLayout/index.js.map +1 -1
  72. package/dist/docsLayout/index.mjs +9 -6
  73. package/dist/docsLayout/index.mjs.map +1 -1
  74. package/dist/docsSidebar/index.js +2 -2
  75. package/dist/docsSidebar/index.js.map +1 -1
  76. package/dist/docsSidebar/index.mjs +11 -6
  77. package/dist/docsSidebar/index.mjs.map +1 -1
  78. package/dist/dropdownMenu/index.mjs +9 -4
  79. package/dist/dropdownMenu/index.mjs.map +1 -1
  80. package/dist/elements/index.d.mts +4 -2
  81. package/dist/elements/index.d.ts +4 -2
  82. package/dist/elements/index.js +8 -135
  83. package/dist/elements/index.mjs +10 -14
  84. package/dist/fileDropzone/index.js +12 -11
  85. package/dist/fileDropzone/index.js.map +1 -1
  86. package/dist/fileDropzone/index.mjs +21 -17
  87. package/dist/fileDropzone/index.mjs.map +1 -1
  88. package/dist/fileUploader/index.js +2 -1
  89. package/dist/fileUploader/index.js.map +1 -1
  90. package/dist/fileUploader/index.mjs +2 -1
  91. package/dist/fileUploader/index.mjs.map +1 -1
  92. package/dist/glow/index.js +24 -17
  93. package/dist/glow/index.js.map +1 -1
  94. package/dist/glow/index.mjs +24 -17
  95. package/dist/glow/index.mjs.map +1 -1
  96. package/dist/hooks/index.d.mts +9 -18
  97. package/dist/hooks/index.d.ts +9 -18
  98. package/dist/hooks/index.mjs +146 -27
  99. package/dist/index.d.mts +18 -17
  100. package/dist/index.d.ts +18 -17
  101. package/dist/index.js +167 -172
  102. package/dist/index.mjs +589 -594
  103. package/dist/input/index.js +3 -2
  104. package/dist/input/index.js.map +1 -1
  105. package/dist/input/index.mjs +118 -19
  106. package/dist/input/index.mjs.map +1 -1
  107. package/dist/interfaceSettings/index.js +6 -4
  108. package/dist/interfaceSettings/index.js.map +1 -1
  109. package/dist/interfaceSettings/index.mjs +130 -28
  110. package/dist/interfaceSettings/index.mjs.map +1 -1
  111. package/dist/label/index.mjs +7 -4
  112. package/dist/label/index.mjs.map +1 -1
  113. package/dist/loading/index.mjs +9 -4
  114. package/dist/loading/index.mjs.map +1 -1
  115. package/dist/navbar/index.js +3 -2
  116. package/dist/navbar/index.js.map +1 -1
  117. package/dist/navbar/index.mjs +10 -6
  118. package/dist/navbar/index.mjs.map +1 -1
  119. package/dist/navigationMenu/index.mjs +9 -4
  120. package/dist/navigationMenu/index.mjs.map +1 -1
  121. package/dist/pagination/index.mjs +9 -4
  122. package/dist/pagination/index.mjs.map +1 -1
  123. package/dist/passwordInput/index.js +3 -2
  124. package/dist/passwordInput/index.js.map +1 -1
  125. package/dist/passwordInput/index.mjs +12 -6
  126. package/dist/passwordInput/index.mjs.map +1 -1
  127. package/dist/phoneInput/index.js +10 -5
  128. package/dist/phoneInput/index.js.map +1 -1
  129. package/dist/phoneInput/index.mjs +19 -11
  130. package/dist/phoneInput/index.mjs.map +1 -1
  131. package/dist/pinInput/index.js +3 -3
  132. package/dist/pinInput/index.js.map +1 -1
  133. package/dist/pinInput/index.mjs +12 -7
  134. package/dist/pinInput/index.mjs.map +1 -1
  135. package/dist/popover/index.mjs +9 -4
  136. package/dist/popover/index.mjs.map +1 -1
  137. package/dist/progress/index.mjs +9 -4
  138. package/dist/progress/index.mjs.map +1 -1
  139. package/dist/progressCircle/index.js +2 -2
  140. package/dist/progressCircle/index.js.map +1 -1
  141. package/dist/progressCircle/index.mjs +11 -6
  142. package/dist/progressCircle/index.mjs.map +1 -1
  143. package/dist/radio/index.js +6 -4
  144. package/dist/radio/index.js.map +1 -1
  145. package/dist/radio/index.mjs +13 -8
  146. package/dist/radio/index.mjs.map +1 -1
  147. package/dist/scrollArea/index.mjs +9 -4
  148. package/dist/scrollArea/index.mjs.map +1 -1
  149. package/dist/scrollIndicator/index.js +2 -1
  150. package/dist/scrollIndicator/index.js.map +1 -1
  151. package/dist/scrollIndicator/index.mjs +2 -1
  152. package/dist/scrollIndicator/index.mjs.map +1 -1
  153. package/dist/select/index.js +6 -2
  154. package/dist/select/index.js.map +1 -1
  155. package/dist/select/index.mjs +15 -8
  156. package/dist/select/index.mjs.map +1 -1
  157. package/dist/separator/index.mjs +9 -4
  158. package/dist/separator/index.mjs.map +1 -1
  159. package/dist/sheet/index.mjs +9 -4
  160. package/dist/sheet/index.mjs.map +1 -1
  161. package/dist/sidebar/index.mjs +9 -4
  162. package/dist/sidebar/index.mjs.map +1 -1
  163. package/dist/signature/index.js +31 -11
  164. package/dist/signature/index.js.map +1 -1
  165. package/dist/signature/index.mjs +40 -15
  166. package/dist/signature/index.mjs.map +1 -1
  167. package/dist/simpleTable/index.js +18 -14
  168. package/dist/simpleTable/index.js.map +1 -1
  169. package/dist/simpleTable/index.mjs +25 -18
  170. package/dist/simpleTable/index.mjs.map +1 -1
  171. package/dist/skeleton/index.mjs +9 -4
  172. package/dist/skeleton/index.mjs.map +1 -1
  173. package/dist/slider/index.mjs +9 -4
  174. package/dist/slider/index.mjs.map +1 -1
  175. package/dist/sortButton/index.mjs +268 -11
  176. package/dist/sortButton/index.mjs.map +1 -1
  177. package/dist/splitButton/index.mjs +267 -12
  178. package/dist/splitButton/index.mjs.map +1 -1
  179. package/dist/switch/index.js +2 -1
  180. package/dist/switch/index.js.map +1 -1
  181. package/dist/switch/index.mjs +11 -5
  182. package/dist/switch/index.mjs.map +1 -1
  183. package/dist/table/index.mjs +9 -4
  184. package/dist/table/index.mjs.map +1 -1
  185. package/dist/tabs/index.mjs +7 -4
  186. package/dist/tabs/index.mjs.map +1 -1
  187. package/dist/textarea/index.js +4 -4
  188. package/dist/textarea/index.js.map +1 -1
  189. package/dist/textarea/index.mjs +11 -8
  190. package/dist/textarea/index.mjs.map +1 -1
  191. package/dist/toast/index.d.mts +9 -1
  192. package/dist/toast/index.d.ts +9 -1
  193. package/dist/toast/index.js +3 -3
  194. package/dist/toast/index.js.map +1 -1
  195. package/dist/toast/index.mjs +145 -10
  196. package/dist/toast/index.mjs.map +1 -1
  197. package/dist/toaster/index.d.mts +5 -0
  198. package/dist/toaster/index.d.ts +5 -0
  199. package/dist/toaster/index.js +17 -142
  200. package/dist/toaster/index.js.map +1 -1
  201. package/dist/toaster/index.mjs +142 -135
  202. package/dist/toaster/index.mjs.map +1 -1
  203. package/package.json +1 -1
  204. package/dist/chunk-3ODWQVIA.mjs +0 -12
  205. package/dist/chunk-3ODWQVIA.mjs.map +0 -1
  206. package/dist/chunk-53OZVR57.mjs +0 -108
  207. package/dist/chunk-53OZVR57.mjs.map +0 -1
  208. package/dist/chunk-CBRGWUZG.mjs +0 -11
  209. package/dist/chunk-CBRGWUZG.mjs.map +0 -1
  210. package/dist/chunk-HYXZRCZW.mjs +0 -265
  211. package/dist/chunk-HYXZRCZW.mjs.map +0 -1
  212. package/dist/chunk-JNUGOUYJ.mjs +0 -154
  213. package/dist/chunk-JX5YLRCU.mjs +0 -443
  214. package/dist/chunk-JX5YLRCU.mjs.map +0 -1
  215. package/dist/chunk-NV3KR5Y7.mjs +0 -82
  216. package/dist/chunk-NV3KR5Y7.mjs.map +0 -1
  217. package/dist/chunk-OQ7MNEYW.mjs +0 -151
  218. package/dist/chunk-OQ7MNEYW.mjs.map +0 -1
@@ -1,145 +1,155 @@
1
- import {
2
- Toast,
3
- ToastClose,
4
- ToastDescription,
5
- ToastProvider,
6
- ToastTitle,
7
- ToastViewport
8
- } from "../chunk-OQ7MNEYW.mjs";
9
- import {
10
- cn
11
- } from "../chunk-CBRGWUZG.mjs";
12
-
13
1
  // elements/toaster/Toaster.tsx
14
2
  import React2 from "react";
15
3
 
16
- // hooks/useToast.ts
17
- import * as React from "react";
18
- var TOAST_LIMIT = 5;
19
- var TOAST_REMOVE_DELAY = 1e5;
20
- var count = 0;
21
- function genId() {
22
- count = (count + 1) % Number.MAX_VALUE;
23
- return count.toString();
4
+ // util/index.ts
5
+ import { clsx } from "clsx";
6
+ import { twMerge } from "tailwind-merge";
7
+ function cn(...inputs) {
8
+ return twMerge(clsx(inputs));
24
9
  }
25
- var toastTimeouts = /* @__PURE__ */ new Map();
26
- var addToRemoveQueue = (toastId) => {
27
- if (toastTimeouts.has(toastId)) {
28
- return;
29
- }
30
- const timeout = setTimeout(() => {
31
- toastTimeouts.delete(toastId);
32
- dispatch({
33
- type: "REMOVE_TOAST",
34
- toastId
35
- });
36
- }, TOAST_REMOVE_DELAY);
37
- toastTimeouts.set(toastId, timeout);
38
- };
39
- var reducer = (state, action) => {
40
- switch (action.type) {
41
- case "ADD_TOAST":
42
- console.log("adding toast case");
43
- return {
44
- ...state,
45
- toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT)
46
- };
47
- case "UPDATE_TOAST":
48
- return {
49
- ...state,
50
- toasts: state.toasts.map(
51
- (t) => t.id === action.toast.id ? { ...t, ...action.toast } : t
52
- )
53
- };
54
- case "DISMISS_TOAST": {
55
- const { toastId } = action;
56
- if (toastId) {
57
- addToRemoveQueue(toastId);
58
- } else {
59
- state.toasts.forEach((toast2) => {
60
- addToRemoveQueue(toast2.id);
61
- });
62
- }
63
- return {
64
- ...state,
65
- toasts: state.toasts.map(
66
- (t) => t.id === toastId || toastId === void 0 ? { ...t, open: false } : t
67
- )
68
- };
69
- }
70
- case "REMOVE_TOAST":
71
- if (action.toastId === void 0) {
72
- return { ...state, toasts: [] };
10
+
11
+ // elements/toast/Toast.tsx
12
+ import * as React from "react";
13
+ import * as ToastPrimitives from "@radix-ui/react-toast";
14
+ import { cva } from "class-variance-authority";
15
+ var toastVariants = cva(
16
+ "hawa-group hawa-z-[900] hawa-pointer-events-auto hawa-relative hawa-flex hawa-w-full hawa-items-center hawa-justify-between hawa-overflow-hidden hawa-rounded-md hawa-border hawa-shadow-lg hawa-transition-all data-[swipe=cancel]:hawa-translate-x-0 data-[swipe=end]:hawa-translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:hawa-translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:hawa-transition-none data-[state=open]:hawa-animate-in data-[state=closed]:hawa-animate-out data-[swipe=end]:hawa-animate-out data-[state=closed]:hawa-fade-out-80 data-[state=open]:hawa-slide-in-from-top-full data-[state=open]:sm:hawa-slide-in-from-bottom-full",
17
+ {
18
+ variants: {
19
+ variant: {
20
+ default: "hawa-border hawa-bg-background hawa-text-foreground",
21
+ destructive: "hawa-destructive hawa-group hawa-border-destructive hawa-bg-destructive hawa-text-destructive-foreground"
22
+ },
23
+ severity: {
24
+ info: "hawa-info hawa-group hawa-text-info-foreground hawa-bg-info",
25
+ warning: "hawa-warning hawa-group hawa-text-warning-foreground hawa-bg-warning",
26
+ error: "hawa-error hawa-group hawa-border-error hawa-bg-error hawa-text-white",
27
+ success: "hawa-success hawa-group hawa-text-success-foreground hawa-bg-success",
28
+ none: ""
73
29
  }
74
- return {
75
- ...state,
76
- toasts: state.toasts.filter((t) => t.id !== action.toastId)
77
- };
30
+ },
31
+ defaultVariants: { variant: "default" }
78
32
  }
33
+ );
34
+ var sizeStyles = {
35
+ default: "hawa-text-sm",
36
+ // Update this based on the desired padding for rtl
37
+ sm: "hawa-text-xs"
79
38
  };
80
- var listeners = [];
81
- var memoryState = { toasts: [] };
82
- function dispatch(action) {
83
- console.log("dispatching toast");
84
- memoryState = reducer(memoryState, action);
85
- listeners.forEach((listener) => {
86
- console.log("mapping through listerners in dispathc");
87
- listener(memoryState);
88
- });
89
- }
90
- function toast({ ...props }) {
91
- const id = genId();
92
- const update = (props2) => dispatch({
93
- type: "UPDATE_TOAST",
94
- toast: { ...props2, id }
95
- });
96
- const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
97
- dispatch({
98
- type: "ADD_TOAST",
99
- toast: {
100
- ...props,
101
- id,
102
- open: true,
103
- onOpenChange: (open) => {
104
- if (!open)
105
- dismiss();
106
- }
39
+ var ToastProvider = ToastPrimitives.Provider;
40
+ var ToastViewport = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
41
+ ToastPrimitives.Viewport,
42
+ {
43
+ ref,
44
+ className: cn(
45
+ "hawa-fixed hawa-top-0 hawa-z-[100] hawa-flex hawa-max-h-screen hawa-w-full hawa-flex-col-reverse hawa-p-4 sm:hawa-bottom-0 sm:hawa-right-0 sm:hawa-top-auto sm:hawa-flex-col md:hawa-max-w-[420px]",
46
+ className
47
+ ),
48
+ ...props
49
+ }
50
+ ));
51
+ ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
52
+ var Toast = React.forwardRef(({ className, variant, severity = "none", direction, ...props }, ref) => {
53
+ return /* @__PURE__ */ React.createElement(
54
+ ToastPrimitives.Root,
55
+ {
56
+ ref,
57
+ className: cn(
58
+ toastVariants({ variant, severity }),
59
+ className,
60
+ direction === "rtl" ? "data-[state=closed]:hawa-slide-out-to-left-full" : "data-[state=closed]:hawa-slide-out-to-right-full"
61
+ ),
62
+ dir: direction,
63
+ ...props
107
64
  }
108
- });
109
- return {
110
- id,
111
- dismiss,
112
- update
113
- };
114
- }
115
- function useToast() {
116
- const [state, setState] = React.useState(memoryState);
117
- React.useEffect(() => {
118
- console.log("useToast triggered in useEffect");
119
- console.log("toast state", state);
120
- console.log("listerners BEFORE", listeners);
121
- console.log("TOAST: setState is ", setState);
122
- listeners.push(setState);
123
- return () => {
124
- const index = listeners.indexOf(setState);
125
- console.log("listerners AFTER", listeners);
126
- if (index > -1) {
127
- listeners.splice(index, 1);
65
+ );
66
+ });
67
+ Toast.displayName = ToastPrimitives.Root.displayName;
68
+ var ToastAction = React.forwardRef(({ className, ...props }, ref) => {
69
+ return /* @__PURE__ */ React.createElement(
70
+ ToastPrimitives.Action,
71
+ {
72
+ ref,
73
+ className: cn(
74
+ "hawa-inline-flex hawa-h-8 hawa-shrink-0 hawa-items-center hawa-justify-center hawa-rounded-md hawa-border hawa-bg-transparent hawa-px-3 hawa-text-sm hawa-font-medium hawa-ring-offset-background hawa-transition-colors hover:hawa-bg-secondary hover:hawa-text-secondary-foreground focus:hawa-outline-none focus:hawa-ring-2 focus:hawa-ring-ring focus:hawa-ring-offset-2 disabled:hawa-pointer-events-none disabled:hawa-opacity-50",
75
+ "group-[.info]:hawa-border-muted/40 group-[.info]:hover:hawa-border-info/30 group-[.info]:hover:hawa-bg-info group-[.info]:hover:hawa-text-info-foreground group-[.info]:focus:hawa-ring-info",
76
+ "group-[.error]:hawa-border-muted/40 group-[.error]:hover:hawa-border-error/30 group-[.error]:hover:hawa-bg-error group-[.error]:hover:hawa-text-error-foreground group-[.error]:focus:hawa-ring-error",
77
+ "group-[.success]:hawa-border-muted/40 group-[.success]:hover:hawa-border-success/30 group-[.success]:hover:hawa-bg-success group-[.success]:hover:hawa-text-success-foreground group-[.success]:focus:hawa-ring-success",
78
+ "group-[.warning]:hawa-border-muted/40 group-[.warning]:hover:hawa-border-warning/30 group-[.warning]:hover:hawa-bg-warning group-[.warning]:hover:hawa-text-warning-foreground group-[.warning]:focus:hawa-ring-warning",
79
+ "hawa-whitespace-nowrap",
80
+ className
81
+ ),
82
+ ...props
83
+ }
84
+ );
85
+ });
86
+ ToastAction.displayName = ToastPrimitives.Action.displayName;
87
+ var ToastClose = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
88
+ ToastPrimitives.Close,
89
+ {
90
+ ref,
91
+ className: cn(
92
+ // "hawa-absolute hawa-start-2 hawa-top-2",
93
+ // "group-hover:hawa-opacity-100",
94
+ "hawa-opacity-100",
95
+ "hawa-rounded-md hawa-p-1 hawa-text-foreground/50 hawa-transition-opacity hover:hawa-text-foreground focus:hawa-opacity-100 focus:hawa-outline-none focus:hawa-ring-2 group-[.destructive]:hawa-text-red-300 group-[.destructive]:hover:hawa-text-red-50 group-[.destructive]:focus:hawa-ring-red-400 group-[.destructive]:focus:hawa-ring-offset-red-600",
96
+ className
97
+ ),
98
+ "toast-close": "",
99
+ ...props
100
+ },
101
+ /* @__PURE__ */ React.createElement(
102
+ "svg",
103
+ {
104
+ "aria-label": "Close Icon",
105
+ "aria-hidden": "true",
106
+ className: "hawa-icon",
107
+ fill: "currentColor",
108
+ viewBox: "0 0 20 20"
109
+ },
110
+ /* @__PURE__ */ React.createElement(
111
+ "path",
112
+ {
113
+ fillRule: "evenodd",
114
+ d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
115
+ clipRule: "evenodd"
128
116
  }
129
- };
130
- }, [state]);
131
- return {
132
- ...state,
133
- toast,
134
- dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId })
135
- };
136
- }
117
+ )
118
+ )
119
+ ));
120
+ ToastClose.displayName = ToastPrimitives.Close.displayName;
121
+ var ToastTitle = React.forwardRef(({ className, size = "default", ...props }, ref) => /* @__PURE__ */ React.createElement(
122
+ ToastPrimitives.Title,
123
+ {
124
+ ref,
125
+ className: cn(
126
+ "hawa-select-text hawa-text-sm hawa-font-semibold",
127
+ sizeStyles[size],
128
+ className
129
+ ),
130
+ ...props
131
+ }
132
+ ));
133
+ ToastTitle.displayName = ToastPrimitives.Title.displayName;
134
+ var ToastDescription = React.forwardRef(({ className, size = "default", ...props }, ref) => /* @__PURE__ */ React.createElement(
135
+ ToastPrimitives.Description,
136
+ {
137
+ ref,
138
+ className: cn(
139
+ "hawa-select-text hawa-opacity-90",
140
+ sizeStyles[size],
141
+ className
142
+ ),
143
+ ...props
144
+ }
145
+ ));
146
+ ToastDescription.displayName = ToastPrimitives.Description.displayName;
137
147
 
138
148
  // elements/toaster/Toaster.tsx
139
149
  function Toaster(props) {
140
- const { toasts } = useToast();
150
+ var _a;
141
151
  let isRTL = props.direction === "rtl";
142
- return /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement("div", null, "I AM INSIDE MAIN TOASTER"), /* @__PURE__ */ React2.createElement(ToastProvider, { swipeDirection: isRTL ? "left" : "right" }, /* @__PURE__ */ React2.createElement("div", null, "I AM INSIDE TOASTPROVIDER"), toasts.map(function({
152
+ return /* @__PURE__ */ React2.createElement(ToastProvider, { swipeDirection: isRTL ? "left" : "right" }, (_a = props.toasts) == null ? void 0 : _a.map(function({
143
153
  id,
144
154
  title,
145
155
  description,
@@ -147,7 +157,7 @@ function Toaster(props) {
147
157
  action,
148
158
  ...toastProps
149
159
  }) {
150
- return /* @__PURE__ */ React2.createElement(Toast, { direction: props.direction, key: id, ...toastProps }, /* @__PURE__ */ React2.createElement("div", null, "I AM INSIDE TOAST"), /* @__PURE__ */ React2.createElement(
160
+ return /* @__PURE__ */ React2.createElement(Toast, { direction: props.direction, key: id, ...toastProps }, /* @__PURE__ */ React2.createElement(
151
161
  "div",
152
162
  {
153
163
  className: cn(
@@ -162,10 +172,7 @@ function Toaster(props) {
162
172
  {
163
173
  className: cn(
164
174
  "hawa-flex hawa-w-full hawa-flex-row hawa-justify-between hawa-gap-2",
165
- {
166
- "hawa-p-4": size === "default",
167
- "hawa-p-2": size === "sm"
168
- }
175
+ { "hawa-p-4": size === "default", "hawa-p-2": size === "sm" }
169
176
  )
170
177
  },
171
178
  /* @__PURE__ */ React2.createElement("div", { className: "hawa-grid hawa-gap-1 hawa-text-start" }, title && /* @__PURE__ */ React2.createElement(ToastTitle, { size }, title), description && /* @__PURE__ */ React2.createElement(ToastDescription, { size }, description)),
@@ -177,7 +184,7 @@ function Toaster(props) {
177
184
  {
178
185
  className: cn("hawa-gap-2", isRTL && "hawa-fixed hawa-left-0")
179
186
  }
180
- )));
187
+ ));
181
188
  }
182
189
  export {
183
190
  Toaster
@@ -1 +1 @@
1
- {"version":3,"sources":["../../elements/toaster/Toaster.tsx","../../hooks/useToast.ts"],"sourcesContent":["import React from \"react\";\n\nimport { useToast } from \"@hooks/useToast\";\nimport { cn } from \"@util/index\";\n\nimport { DirectionType } from \"@_types/commonTypes\";\n\nimport {\n Toast,\n ToastClose,\n ToastDescription,\n ToastProvider,\n ToastTitle,\n ToastViewport\n} from \"../toast\";\n\ntype ToasterProps = {\n direction?: DirectionType;\n};\n\nexport function Toaster(props: ToasterProps) {\n const { toasts } = useToast();\n let isRTL = props.direction === \"rtl\";\n return (\n <div>\n <div>I AM INSIDE MAIN TOASTER</div>\n <ToastProvider swipeDirection={isRTL ? \"left\" : \"right\"}>\n <div>I AM INSIDE TOASTPROVIDER</div>\n {toasts.map(function ({\n id,\n title,\n description,\n size = \"default\",\n action,\n ...toastProps\n }) {\n return (\n <Toast direction={props.direction} key={id} {...toastProps}>\n <div>I AM INSIDE TOAST</div>\n <div\n className={cn(\n \"hawa-flex hawa-w-full hawa-flex-row hawa-gap-2\",\n action && \"hawa-justify-between\"\n )}\n >\n <div className=\"hawa-flex hawa-h-full hawa-flex-col hawa-p-2 hawa-pe-0\">\n <ToastClose />\n </div>\n <div className=\"hawa-mx-0 hawa-h-auto hawa-max-h-full hawa-w-px hawa-bg-primary-foreground/10\"></div>\n <div\n className={cn(\n \"hawa-flex hawa-w-full hawa-flex-row hawa-justify-between hawa-gap-2\",\n {\n \"hawa-p-4\": size === \"default\",\n \"hawa-p-2\": size === \"sm\"\n }\n )}\n >\n <div className={\"hawa-grid hawa-gap-1 hawa-text-start\"}>\n {title && <ToastTitle size={size}>{title}</ToastTitle>}\n {description && (\n <ToastDescription size={size}>\n {description}\n </ToastDescription>\n )}\n </div>\n {action && (\n <div className=\"hawa-flex hawa-flex-col hawa-justify-center\">\n {action}\n </div>\n )}\n </div>\n </div>\n </Toast>\n );\n })}\n <ToastViewport\n className={cn(\"hawa-gap-2\", isRTL && \"hawa-fixed hawa-left-0\")}\n />\n </ToastProvider>\n </div>\n );\n}\n","// Inspired by react-hot-toast library\nimport * as React from \"react\";\n\nimport type { ToastActionElement, ToastProps } from \"@elements/toast\";\n\nconst TOAST_LIMIT = 5;\nconst TOAST_REMOVE_DELAY = 100000;\n\ntype ToasterToast = ToastProps & {\n id: string;\n title?: React.ReactNode;\n description?: React.ReactNode;\n severity?: \"info\" | \"warning\" | \"error\" | \"success\" | \"none\";\n action?: ToastActionElement;\n size?: \"default\" | \"sm\";\n};\n\nconst actionTypes = {\n ADD_TOAST: \"ADD_TOAST\",\n UPDATE_TOAST: \"UPDATE_TOAST\",\n DISMISS_TOAST: \"DISMISS_TOAST\",\n REMOVE_TOAST: \"REMOVE_TOAST\"\n} as const;\n\nlet count = 0;\n\nfunction genId() {\n count = (count + 1) % Number.MAX_VALUE;\n return count.toString();\n}\n\ntype ActionType = typeof actionTypes;\n\ntype Action =\n | {\n type: ActionType[\"ADD_TOAST\"];\n toast: ToasterToast;\n }\n | {\n type: ActionType[\"UPDATE_TOAST\"];\n toast: Partial<ToasterToast>;\n }\n | {\n type: ActionType[\"DISMISS_TOAST\"];\n toastId?: ToasterToast[\"id\"];\n }\n | {\n type: ActionType[\"REMOVE_TOAST\"];\n toastId?: ToasterToast[\"id\"];\n };\n\ninterface State {\n toasts: ToasterToast[];\n}\n\nconst toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();\n\nconst addToRemoveQueue = (toastId: string) => {\n if (toastTimeouts.has(toastId)) {\n return;\n }\n\n const timeout = setTimeout(() => {\n toastTimeouts.delete(toastId);\n dispatch({\n type: \"REMOVE_TOAST\",\n toastId: toastId\n });\n }, TOAST_REMOVE_DELAY);\n\n toastTimeouts.set(toastId, timeout);\n};\n\nexport const reducer = (state: State, action: Action): State => {\n switch (action.type) {\n case \"ADD_TOAST\":\n console.log(\"adding toast case\");\n return {\n ...state,\n toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT)\n };\n\n case \"UPDATE_TOAST\":\n return {\n ...state,\n toasts: state.toasts.map((t) =>\n t.id === action.toast.id ? { ...t, ...action.toast } : t\n )\n };\n\n case \"DISMISS_TOAST\": {\n const { toastId } = action;\n\n // ! Side effects ! - This could be extracted into a dismissToast() action,\n // but I'll keep it here for simplicity\n if (toastId) {\n addToRemoveQueue(toastId);\n } else {\n state.toasts.forEach((toast) => {\n addToRemoveQueue(toast.id);\n });\n }\n\n return {\n ...state,\n toasts: state.toasts.map((t) =>\n t.id === toastId || toastId === undefined ? { ...t, open: false } : t\n )\n };\n }\n case \"REMOVE_TOAST\":\n if (action.toastId === undefined) {\n return { ...state, toasts: [] };\n }\n return {\n ...state,\n toasts: state.toasts.filter((t) => t.id !== action.toastId)\n };\n }\n};\n\nconst listeners: Array<(state: State) => void> = [];\n\nlet memoryState: State = { toasts: [] };\n\nfunction dispatch(action: Action) {\n console.log(\"dispatching toast\");\n memoryState = reducer(memoryState, action);\n listeners.forEach((listener) => {\n console.log(\"mapping through listerners in dispathc\");\n listener(memoryState);\n });\n}\n\ntype Toast = Omit<ToasterToast, \"id\">;\n\nfunction toast({ ...props }: Toast) {\n const id = genId();\n\n const update = (props: ToasterToast) =>\n dispatch({\n type: \"UPDATE_TOAST\",\n toast: { ...props, id }\n });\n const dismiss = () => dispatch({ type: \"DISMISS_TOAST\", toastId: id });\n\n dispatch({\n type: \"ADD_TOAST\",\n toast: {\n ...props,\n id,\n open: true,\n onOpenChange: (open) => {\n if (!open) dismiss();\n }\n }\n });\n\n return {\n id: id,\n dismiss,\n update\n };\n}\n\nfunction useToast() {\n const [state, setState] = React.useState<State>(memoryState);\n\n React.useEffect(() => {\n console.log(\"useToast triggered in useEffect\");\n console.log(\"toast state\", state);\n console.log(\"listerners BEFORE\", listeners);\n console.log(\"TOAST: setState is \", setState);\n listeners.push(setState);\n return () => {\n const index = listeners.indexOf(setState);\n console.log(\"listerners AFTER\", listeners);\n if (index > -1) {\n listeners.splice(index, 1);\n }\n };\n }, [state]);\n\n return {\n ...state,\n toast,\n dismiss: (toastId?: string) => dispatch({ type: \"DISMISS_TOAST\", toastId })\n };\n}\n\nexport { useToast, toast };\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,YAAW;;;ACClB,YAAY,WAAW;AAIvB,IAAM,cAAc;AACpB,IAAM,qBAAqB;AAkB3B,IAAI,QAAQ;AAEZ,SAAS,QAAQ;AACf,WAAS,QAAQ,KAAK,OAAO;AAC7B,SAAO,MAAM,SAAS;AACxB;AA0BA,IAAM,gBAAgB,oBAAI,IAA2C;AAErE,IAAM,mBAAmB,CAAC,YAAoB;AAC5C,MAAI,cAAc,IAAI,OAAO,GAAG;AAC9B;AAAA,EACF;AAEA,QAAM,UAAU,WAAW,MAAM;AAC/B,kBAAc,OAAO,OAAO;AAC5B,aAAS;AAAA,MACP,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,GAAG,kBAAkB;AAErB,gBAAc,IAAI,SAAS,OAAO;AACpC;AAEO,IAAM,UAAU,CAAC,OAAc,WAA0B;AAC9D,UAAQ,OA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,cAAC,aACC,gBAAAA,OAAA,cAAC,aAAI,0BAAwB,GAC7B,gBAAAA,OAAA,cAAC,iBAAc,gBAAgB,QAAQ,SAAS,WAC9C,gBAAAA,OAAA,cAAC,aAAI,2BAAyB,GAC7B,OAAO,IAAI,SAAU;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,GAAG;AAAA,EACL,GAAG;AACD,WACE,gBAAAA,OAAA,cAAC,SAAM,WAAW,MAAM,WAAW,KAAK,IAAK,GAAG,cAC9C,gBAAAA,OAAA,cAAC,aAAI,mBAAiB,GACtB,gBAAAA,OAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,UAAU;AAAA,QACZ;AAAA;AAAA,MAEA,gBAAAA,OAAA,cAAC,SAAI,WAAU,4DACb,gBAAAA,OAAA,cAAC,gBAAW,CACd;AAAA,MACA,gBAAAA,OAAA,cAAC,SAAI,WAAU,iFAAgF;AAAA,MAC/F,gBAAAA,OAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW;AAAA,YACT;AAAA,YACA;AAAA,cACE,YAAY,SAAS;AAAA,cACrB,YAAY,SAAS;AAAA,YACvB;AAAA,UACF;AAAA;AAAA,QAEA,gBAAAA,OAAA,cAAC,SAAI,WAAW,0CACb,SAAS,gBAAAA,OAAA,cAAC,cAAW,QAAa,KAAM,GACxC,eACC,gBAAAA,OAAA,cAAC,oBAAiB,QACf,WACH,CAEJ;AAAA,QACC,UACC,gBAAAA,OAAA,cAAC,SAAI,WAAU,kDACZ,MACH;AAAA,MAEJ;AAAA,IACF,CACF;AAAA,EAEJ,CAAC,GACD,gBAAAA,OAAA;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,cAAc,SAAS,wBAAwB;AAAA;AAAA,EAC/D,CACF,CACF;AAEJ;","names":["React","toast","props","React"]}
1
+ {"version":3,"sources":["../../elements/toaster/Toaster.tsx","../../util/index.ts","../../elements/toast/Toast.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\nimport { DirectionType } from \"@_types/commonTypes\";\n\nimport { useToast } from \"../../hooks/useToast\";\nimport {\n Toast,\n ToastClose,\n ToastDescription,\n ToastProvider,\n ToastTitle,\n ToastViewport,\n ToasterToastProps\n} from \"../toast\";\n\ntype ToasterProps = {\n direction?: DirectionType;\n toasts?: ToasterToastProps[];\n};\n\nexport function Toaster(props: ToasterProps) {\n let isRTL = props.direction === \"rtl\";\n return (\n <ToastProvider swipeDirection={isRTL ? \"left\" : \"right\"}>\n {props.toasts?.map(function ({\n id,\n title,\n description,\n size = \"default\",\n action,\n ...toastProps\n }) {\n return (\n <Toast direction={props.direction} key={id} {...toastProps}>\n <div\n className={cn(\n \"hawa-flex hawa-w-full hawa-flex-row hawa-gap-2\",\n action && \"hawa-justify-between\"\n )}\n >\n <div className=\"hawa-flex hawa-h-full hawa-flex-col hawa-p-2 hawa-pe-0\">\n <ToastClose />\n </div>\n <div className=\"hawa-mx-0 hawa-h-auto hawa-max-h-full hawa-w-px hawa-bg-primary-foreground/10\"></div>\n <div\n className={cn(\n \"hawa-flex hawa-w-full hawa-flex-row hawa-justify-between hawa-gap-2\",\n { \"hawa-p-4\": size === \"default\", \"hawa-p-2\": size === \"sm\" }\n )}\n >\n <div className={\"hawa-grid hawa-gap-1 hawa-text-start\"}>\n {title && <ToastTitle size={size}>{title}</ToastTitle>}\n {description && (\n <ToastDescription size={size}>\n {description}\n </ToastDescription>\n )}\n </div>\n {action && (\n <div className=\"hawa-flex hawa-flex-col hawa-justify-center\">\n {action}\n </div>\n )}\n </div>\n </div>\n </Toast>\n );\n })}\n <ToastViewport\n className={cn(\"hawa-gap-2\", isRTL && \"hawa-fixed hawa-left-0\")}\n />\n </ToastProvider>\n );\n}\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\ntype Palette = {\n name: string;\n colors: {\n [key: number]: string;\n };\n};\ntype Rgb = {\n r: number;\n g: number;\n b: number;\n};\nfunction hexToRgb(hex: string): Rgb | null {\n const sanitizedHex = hex.replaceAll(\"##\", \"#\");\n const colorParts = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(\n sanitizedHex\n );\n\n if (!colorParts) {\n return null;\n }\n\n const [, r, g, b] = colorParts;\n\n return {\n r: parseInt(r, 16),\n g: parseInt(g, 16),\n b: parseInt(b, 16)\n } as Rgb;\n}\n\nfunction rgbToHex(r: number, g: number, b: number): string {\n const toHex = (c: number) => `0${c.toString(16)}`.slice(-2);\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\nexport function getTextColor(color: string): \"#FFF\" | \"#333\" {\n const rgbColor = hexToRgb(color);\n\n if (!rgbColor) {\n return \"#333\";\n }\n\n const { r, g, b } = rgbColor;\n const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n return luma < 120 ? \"#FFF\" : \"#333\";\n}\n\nfunction lighten(hex: string, intensity: number): string {\n const color = hexToRgb(`#${hex}`);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r + (255 - color.r) * intensity);\n const g = Math.round(color.g + (255 - color.g) * intensity);\n const b = Math.round(color.b + (255 - color.b) * intensity);\n\n return rgbToHex(r, g, b);\n}\n\nfunction darken(hex: string, intensity: number): string {\n const color = hexToRgb(hex);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r * intensity);\n const g = Math.round(color.g * intensity);\n const b = Math.round(color.b * intensity);\n\n return rgbToHex(r, g, b);\n}\nconst parseColor = (color: any) => {\n if (color.startsWith(\"#\")) {\n // Convert hex to RGB\n let r = parseInt(color.slice(1, 3), 16);\n let g = parseInt(color.slice(3, 5), 16);\n let b = parseInt(color.slice(5, 7), 16);\n return [r, g, b];\n } else if (color.startsWith(\"rgb\")) {\n // Extract RGB values from rgb() format\n return color.match(/\\d+/g).map(Number);\n }\n // Default to white if format is unrecognized\n return [255, 255, 255];\n};\nexport const calculateLuminance = (color: any) => {\n const [r, g, b] = parseColor(color)?.map((c: any) => {\n c /= 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nfunction getPallette(baseColor: string): Palette {\n const name = baseColor;\n\n const response: Palette = {\n name,\n colors: {\n 500: `#${baseColor}`.replace(\"##\", \"#\")\n }\n };\n\n const intensityMap: {\n [key: number]: number;\n } = {\n 50: 0.95,\n 100: 0.9,\n 200: 0.75,\n 300: 0.6,\n 400: 0.3,\n 600: 0.9,\n 700: 0.75,\n 800: 0.6,\n 900: 0.49\n };\n\n [50, 100, 200, 300, 400].forEach((level) => {\n response.colors[level] = lighten(baseColor, intensityMap[level]);\n });\n [600, 700, 800, 900].forEach((level) => {\n response.colors[level] = darken(baseColor, intensityMap[level]);\n });\n\n return response as Palette;\n}\n\nexport { getPallette };\n\n// const hexToRgb = (hex) => {\n// let d = hex?.split(\"#\")[1];\n// var aRgbHex = d?.match(/.{1,2}/g);\n// var aRgb = [\n// parseInt(aRgbHex[0], 16),\n// parseInt(aRgbHex[1], 16),\n// parseInt(aRgbHex[2], 16)\n// ];\n// return aRgb;\n// };\n// const getTextColor = (backColor) => {\n// let rgbArray = hexToRgb(backColor);\n// if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {\n// return \"#000000\";\n// } else {\n// return \"#ffffff\";\n// }\n// };\n// const replaceAt = function (string, index, replacement) {\n// // if (replacement == \"\" || replacement == \" \") {\n// // return (\n// // string.substring(0, index) +\n// // string.substring(index + replacement.length )\n// // );\n// // }\n// const replaced = string.substring(0, index) + replacement + string.substring(index + 1)\n// return replaced\n// };\n\n// export { hexToRgb, getTextColor, replaceAt };\n","import * as React from \"react\";\n\nimport * as ToastPrimitives from \"@radix-ui/react-toast\";\nimport { cn } from \"@util/index\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { DirectionType } from \"@_types/commonTypes\";\n\nconst toastVariants = cva(\n \"hawa-group hawa-z-[900] hawa-pointer-events-auto hawa-relative hawa-flex hawa-w-full hawa-items-center hawa-justify-between hawa-overflow-hidden hawa-rounded-md hawa-border hawa-shadow-lg hawa-transition-all data-[swipe=cancel]:hawa-translate-x-0 data-[swipe=end]:hawa-translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:hawa-translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:hawa-transition-none data-[state=open]:hawa-animate-in data-[state=closed]:hawa-animate-out data-[swipe=end]:hawa-animate-out data-[state=closed]:hawa-fade-out-80 data-[state=open]:hawa-slide-in-from-top-full data-[state=open]:sm:hawa-slide-in-from-bottom-full\",\n {\n variants: {\n variant: {\n default: \"hawa-border hawa-bg-background hawa-text-foreground\",\n destructive:\n \"hawa-destructive hawa-group hawa-border-destructive hawa-bg-destructive hawa-text-destructive-foreground\"\n },\n severity: {\n info: \"hawa-info hawa-group hawa-text-info-foreground hawa-bg-info\",\n warning:\n \"hawa-warning hawa-group hawa-text-warning-foreground hawa-bg-warning\",\n error:\n \"hawa-error hawa-group hawa-border-error hawa-bg-error hawa-text-white\",\n success:\n \"hawa-success hawa-group hawa-text-success-foreground hawa-bg-success\",\n none: \"\"\n }\n },\n\n defaultVariants: { variant: \"default\" }\n }\n);\n\nlet sizeStyles = {\n default: \"hawa-text-sm\", // Update this based on the desired padding for rtl\n sm: \"hawa-text-xs\"\n};\nconst ToastProvider = ToastPrimitives.Provider;\n\nconst ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Viewport>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Viewport\n ref={ref}\n className={cn(\n \"hawa-fixed hawa-top-0 hawa-z-[100] hawa-flex hawa-max-h-screen hawa-w-full hawa-flex-col-reverse hawa-p-4 sm:hawa-bottom-0 sm:hawa-right-0 sm:hawa-top-auto sm:hawa-flex-col md:hawa-max-w-[420px]\",\n className\n )}\n {...props}\n />\n));\nToastViewport.displayName = ToastPrimitives.Viewport.displayName;\n\nconst Toast = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Root>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &\n VariantProps<typeof toastVariants> & {\n direction?: DirectionType;\n }\n>(({ className, variant, severity = \"none\", direction, ...props }, ref) => {\n return (\n <ToastPrimitives.Root\n ref={ref}\n className={cn(\n toastVariants({ variant, severity }),\n className,\n direction === \"rtl\"\n ? \"data-[state=closed]:hawa-slide-out-to-left-full\"\n : \"data-[state=closed]:hawa-slide-out-to-right-full\"\n )}\n dir={direction}\n {...props}\n />\n );\n});\nToast.displayName = ToastPrimitives.Root.displayName;\n\nconst ToastAction = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Action>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>\n>(({ className, ...props }, ref) => {\n return (\n <ToastPrimitives.Action\n ref={ref}\n className={cn(\n \"hawa-inline-flex hawa-h-8 hawa-shrink-0 hawa-items-center hawa-justify-center hawa-rounded-md hawa-border hawa-bg-transparent hawa-px-3 hawa-text-sm hawa-font-medium hawa-ring-offset-background hawa-transition-colors hover:hawa-bg-secondary hover:hawa-text-secondary-foreground focus:hawa-outline-none focus:hawa-ring-2 focus:hawa-ring-ring focus:hawa-ring-offset-2 disabled:hawa-pointer-events-none disabled:hawa-opacity-50\",\n \"group-[.info]:hawa-border-muted/40 group-[.info]:hover:hawa-border-info/30 group-[.info]:hover:hawa-bg-info group-[.info]:hover:hawa-text-info-foreground group-[.info]:focus:hawa-ring-info\",\n \"group-[.error]:hawa-border-muted/40 group-[.error]:hover:hawa-border-error/30 group-[.error]:hover:hawa-bg-error group-[.error]:hover:hawa-text-error-foreground group-[.error]:focus:hawa-ring-error\",\n \"group-[.success]:hawa-border-muted/40 group-[.success]:hover:hawa-border-success/30 group-[.success]:hover:hawa-bg-success group-[.success]:hover:hawa-text-success-foreground group-[.success]:focus:hawa-ring-success\",\n \"group-[.warning]:hawa-border-muted/40 group-[.warning]:hover:hawa-border-warning/30 group-[.warning]:hover:hawa-bg-warning group-[.warning]:hover:hawa-text-warning-foreground group-[.warning]:focus:hawa-ring-warning\",\n \"hawa-whitespace-nowrap\",\n className\n )}\n {...props}\n />\n );\n});\nToastAction.displayName = ToastPrimitives.Action.displayName;\n\nconst ToastClose = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Close>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Close\n ref={ref}\n className={cn(\n // \"hawa-absolute hawa-start-2 hawa-top-2\",\n // \"group-hover:hawa-opacity-100\",\n \"hawa-opacity-100\",\n \"hawa-rounded-md hawa-p-1 hawa-text-foreground/50 hawa-transition-opacity hover:hawa-text-foreground focus:hawa-opacity-100 focus:hawa-outline-none focus:hawa-ring-2 group-[.destructive]:hawa-text-red-300 group-[.destructive]:hover:hawa-text-red-50 group-[.destructive]:focus:hawa-ring-red-400 group-[.destructive]:focus:hawa-ring-offset-red-600\",\n className\n )}\n toast-close=\"\"\n {...props}\n >\n <svg\n aria-label=\"Close Icon\"\n aria-hidden=\"true\"\n className=\"hawa-icon\"\n fill=\"currentColor\"\n viewBox=\"0 0 20 20\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\"\n clipRule=\"evenodd\"\n ></path>\n </svg>\n </ToastPrimitives.Close>\n));\nToastClose.displayName = ToastPrimitives.Close.displayName;\n\nconst ToastTitle = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Title>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title> & {\n size: \"default\" | \"sm\";\n }\n>(({ className, size = \"default\", ...props }, ref) => (\n <ToastPrimitives.Title\n ref={ref}\n className={cn(\n \"hawa-select-text hawa-text-sm hawa-font-semibold\",\n sizeStyles[size],\n className\n )}\n {...props}\n />\n));\nToastTitle.displayName = ToastPrimitives.Title.displayName;\n\nconst ToastDescription = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Description>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description> & {\n size: \"default\" | \"sm\";\n }\n>(({ className, size = \"default\", ...props }, ref) => (\n <ToastPrimitives.Description\n ref={ref}\n className={cn(\n \"hawa-select-text hawa-opacity-90\",\n sizeStyles[size],\n className\n )}\n {...props}\n />\n));\nToastDescription.displayName = ToastPrimitives.Description.displayName;\n\ntype ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;\ntype ToastActionElement = React.ReactElement<typeof ToastAction>;\nexport type ToasterToastProps = ToastProps & {\n id: string;\n title?: React.ReactNode;\n description?: React.ReactNode;\n severity?: \"info\" | \"warning\" | \"error\" | \"success\" | \"none\";\n action?: ToastActionElement;\n size?: \"default\" | \"sm\";\n};\nexport {\n type ToastProps,\n type ToastActionElement,\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastClose,\n ToastAction\n};\n"],"mappings":";AAAA,OAAOA,YAAW;;;ACAlB,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ACLA,YAAY,WAAW;AAEvB,YAAY,qBAAqB;AAEjC,SAAS,WAA8B;AAIvC,IAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,aACE;AAAA,MACJ;AAAA,MACA,UAAU;AAAA,QACR,MAAM;AAAA,QACN,SACE;AAAA,QACF,OACE;AAAA,QACF,SACE;AAAA,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AA,MAEA,gBAAAA,OAAA,cAAC,SAAI,WAAU,4DACb,gBAAAA,OAAA,cAAC,gBAAW,CACd;AAAA,MACA,gBAAAA,OAAA,cAAC,SAAI,WAAU,iFAAgF;AAAA,MAC/F,gBAAAA,OAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW;AAAA,YACT;AAAA,YACA,EAAE,YAAY,SAAS,WAAW,YAAY,SAAS,KAAK;AAAA,UAC9D;AAAA;AAAA,QAEA,gBAAAA,OAAA,cAAC,SAAI,WAAW,0CACb,SAAS,gBAAAA,OAAA,cAAC,cAAW,QAAa,KAAM,GACxC,eACC,gBAAAA,OAAA,cAAC,oBAAiB,QACf,WACH,CAEJ;AAAA,QACC,UACC,gBAAAA,OAAA,cAAC,SAAI,WAAU,kDACZ,MACH;AAAA,MAEJ;AAAA,IACF,CACF;AAAA,EAEJ,IACA,gBAAAA,OAAA;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,cAAc,SAAS,wBAAwB;AAAA;AAAA,EAC/D,CACF;AAEJ;","names":["React","React"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.26.31",
3
+ "version": "0.26.33",
4
4
  "description": "Modern UI Kit made with Tailwind",
5
5
  "author": {
6
6
  "name": "Sikka Software",
@@ -1,12 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- export {
10
- __require
11
- };
12
- //# sourceMappingURL=chunk-3ODWQVIA.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,108 +0,0 @@
1
- // util/index.ts
2
- import { clsx } from "clsx";
3
- import { twMerge } from "tailwind-merge";
4
- function cn(...inputs) {
5
- return twMerge(clsx(inputs));
6
- }
7
-
8
- // elements/label/Label.tsx
9
- import * as React2 from "react";
10
-
11
- // elements/tooltip/Tooltip.tsx
12
- import React from "react";
13
- import * as TooltipPrimitive from "@radix-ui/react-tooltip";
14
- var TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React.createElement(
15
- TooltipPrimitive.Content,
16
- {
17
- ref,
18
- sideOffset,
19
- className: cn(
20
- "hawa-z-50 hawa-overflow-hidden hawa-rounded-md hawa-border hawa-bg-popover hawa-px-3 hawa-py-1.5 hawa-text-sm hawa-text-popover-foreground hawa-shadow-md hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=closed]:hawa-zoom-out-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2",
21
- className
22
- ),
23
- ...props
24
- }
25
- ));
26
- TooltipContent.displayName = TooltipPrimitive.Content.displayName;
27
- var TooltipArrow = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(TooltipPrimitive.Arrow, { ref, className: cn(className), ...props }));
28
- TooltipArrow.displayName = TooltipPrimitive.Arrow.displayName;
29
- var Tooltip = ({
30
- side,
31
- open,
32
- content,
33
- children,
34
- defaultOpen,
35
- onOpenChange,
36
- triggerProps,
37
- contentProps,
38
- providerProps,
39
- delayDuration = 300,
40
- ...props
41
- }) => {
42
- return /* @__PURE__ */ React.createElement(
43
- TooltipPrimitive.TooltipProvider,
44
- {
45
- delayDuration,
46
- ...providerProps
47
- },
48
- /* @__PURE__ */ React.createElement(
49
- TooltipPrimitive.Root,
50
- {
51
- open,
52
- defaultOpen,
53
- onOpenChange,
54
- ...props
55
- },
56
- /* @__PURE__ */ React.createElement(TooltipPrimitive.Trigger, { ...triggerProps }, children),
57
- /* @__PURE__ */ React.createElement(TooltipContent, { side, align: "center", ...contentProps }, content)
58
- )
59
- );
60
- };
61
-
62
- // elements/label/Label.tsx
63
- var Label = React2.forwardRef(({ className, hint, hintSide, required, children, ...props }, ref) => /* @__PURE__ */ React2.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-1 hawa-transition-all" }, /* @__PURE__ */ React2.createElement(
64
- "label",
65
- {
66
- ref,
67
- className: cn(
68
- "hawa-text-sm hawa-font-medium hawa-leading-none peer-disabled:hawa-cursor-not-allowed peer-disabled:hawa-opacity-70",
69
- className
70
- ),
71
- ...props
72
- },
73
- children,
74
- required && /* @__PURE__ */ React2.createElement("span", { className: "hawa-mx-0.5 hawa-text-red-500" }, "*")
75
- ), hint && /* @__PURE__ */ React2.createElement(
76
- Tooltip,
77
- {
78
- content: hint,
79
- side: hintSide,
80
- triggerProps: {
81
- tabIndex: -1,
82
- onClick: (event) => event.preventDefault()
83
- }
84
- },
85
- /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(
86
- "svg",
87
- {
88
- xmlns: "http://www.w3.org/2000/svg",
89
- className: "hawa-h-[14px] hawa-w-[14px] hawa-cursor-help",
90
- viewBox: "0 0 24 24",
91
- fill: "none",
92
- stroke: "currentColor",
93
- strokeWidth: "2",
94
- strokeLinecap: "round",
95
- strokeLinejoin: "round"
96
- },
97
- /* @__PURE__ */ React2.createElement("circle", { cx: "12", cy: "12", r: "10" }),
98
- /* @__PURE__ */ React2.createElement("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }),
99
- /* @__PURE__ */ React2.createElement("path", { d: "M12 17h.01" })
100
- ))
101
- )));
102
- Label.displayName = "Label";
103
-
104
- export {
105
- cn,
106
- Label
107
- };
108
- //# sourceMappingURL=chunk-53OZVR57.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../util/index.ts","../elements/label/Label.tsx","../elements/tooltip/Tooltip.tsx"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\ntype Palette = {\n name: string;\n colors: {\n [key: number]: string;\n };\n};\ntype Rgb = {\n r: number;\n g: number;\n b: number;\n};\nfunction hexToRgb(hex: string): Rgb | null {\n const sanitizedHex = hex.replaceAll(\"##\", \"#\");\n const colorParts = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(\n sanitizedHex\n );\n\n if (!colorParts) {\n return null;\n }\n\n const [, r, g, b] = colorParts;\n\n return {\n r: parseInt(r, 16),\n g: parseInt(g, 16),\n b: parseInt(b, 16)\n } as Rgb;\n}\n\nfunction rgbToHex(r: number, g: number, b: number): string {\n const toHex = (c: number) => `0${c.toString(16)}`.slice(-2);\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\nexport function getTextColor(color: string): \"#FFF\" | \"#333\" {\n const rgbColor = hexToRgb(color);\n\n if (!rgbColor) {\n return \"#333\";\n }\n\n const { r, g, b } = rgbColor;\n const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n return luma < 120 ? \"#FFF\" : \"#333\";\n}\n\nfunction lighten(hex: string, intensity: number): string {\n const color = hexToRgb(`#${hex}`);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r + (255 - color.r) * intensity);\n const g = Math.round(color.g + (255 - color.g) * intensity);\n const b = Math.round(color.b + (255 - color.b) * intensity);\n\n return rgbToHex(r, g, b);\n}\n\nfunction darken(hex: string, intensity: number): string {\n const color = hexToRgb(hex);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r * intensity);\n const g = Math.round(color.g * intensity);\n const b = Math.round(color.b * intensity);\n\n return rgbToHex(r, g, b);\n}\nconst parseColor = (color: any) => {\n if (color.startsWith(\"#\")) {\n // Convert hex to RGB\n let r = parseInt(color.slice(1, 3), 16);\n let g = parseInt(color.slice(3, 5), 16);\n let b = parseInt(color.slice(5, 7), 16);\n return [r, g, b];\n } else if (color.startsWith(\"rgb\")) {\n // Extract RGB values from rgb() format\n return color.match(/\\d+/g).map(Number);\n }\n // Default to white if format is unrecognized\n return [255, 255, 255];\n};\nexport const calculateLuminance = (color: any) => {\n const [r, g, b] = parseColor(color)?.map((c: any) => {\n c /= 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nfunction getPallette(baseColor: string): Palette {\n const name = baseColor;\n\n const response: Palette = {\n name,\n colors: {\n 500: `#${baseColor}`.replace(\"##\", \"#\")\n }\n };\n\n const intensityMap: {\n [key: number]: number;\n } = {\n 50: 0.95,\n 100: 0.9,\n 200: 0.75,\n 300: 0.6,\n 400: 0.3,\n 600: 0.9,\n 700: 0.75,\n 800: 0.6,\n 900: 0.49\n };\n\n [50, 100, 200, 300, 400].forEach((level) => {\n response.colors[level] = lighten(baseColor, intensityMap[level]);\n });\n [600, 700, 800, 900].forEach((level) => {\n response.colors[level] = darken(baseColor, intensityMap[level]);\n });\n\n return response as Palette;\n}\n\nexport { getPallette };\n\n// const hexToRgb = (hex) => {\n// let d = hex?.split(\"#\")[1];\n// var aRgbHex = d?.match(/.{1,2}/g);\n// var aRgb = [\n// parseInt(aRgbHex[0], 16),\n// parseInt(aRgbHex[1], 16),\n// parseInt(aRgbHex[2], 16)\n// ];\n// return aRgb;\n// };\n// const getTextColor = (backColor) => {\n// let rgbArray = hexToRgb(backColor);\n// if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {\n// return \"#000000\";\n// } else {\n// return \"#ffffff\";\n// }\n// };\n// const replaceAt = function (string, index, replacement) {\n// // if (replacement == \"\" || replacement == \" \") {\n// // return (\n// // string.substring(0, index) +\n// // string.substring(index + replacement.length )\n// // );\n// // }\n// const replaced = string.substring(0, index) + replacement + string.substring(index + 1)\n// return replaced\n// };\n\n// export { hexToRgb, getTextColor, replaceAt };\n","import * as React from \"react\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nimport { cn } from \"@util/index\";\nimport { Tooltip } from \"../tooltip\";\n\nexport type LabelProps = {\n hint?: React.ReactNode;\n hintSide?: PositionType;\n htmlFor?: string;\n required?: boolean;\n};\n\nconst Label = React.forwardRef<\n HTMLLabelElement,\n React.LabelHTMLAttributes<HTMLLabelElement> & LabelProps\n>(({ className, hint, hintSide, required, children, ...props }, ref) => (\n <div className=\"hawa-flex hawa-flex-row hawa-items-center hawa-gap-1 hawa-transition-all\">\n <label\n ref={ref}\n className={cn(\n \"hawa-text-sm hawa-font-medium hawa-leading-none peer-disabled:hawa-cursor-not-allowed peer-disabled:hawa-opacity-70\",\n className\n )}\n {...props}\n >\n {children}\n {required && <span className=\"hawa-mx-0.5 hawa-text-red-500\">*</span>}\n </label>\n {hint && (\n <Tooltip\n content={hint}\n side={hintSide}\n triggerProps={{\n tabIndex: -1,\n onClick: (event) => event.preventDefault()\n }}\n >\n <div>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"hawa-h-[14px] hawa-w-[14px] hawa-cursor-help\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3\" />\n <path d=\"M12 17h.01\" />\n </svg>\n </div>\n </Tooltip>\n )}\n </div>\n));\n\nLabel.displayName = \"Label\";\n\nexport { Label };\n","import React from \"react\";\n\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nimport { cn } from \"@util/index\";\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>\n>(({ className, sideOffset = 4, ...props }, ref) => (\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"hawa-z-50 hawa-overflow-hidden hawa-rounded-md hawa-border hawa-bg-popover hawa-px-3 hawa-py-1.5 hawa-text-sm hawa-text-popover-foreground hawa-shadow-md hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=closed]:hawa-zoom-out-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2\",\n className\n )}\n {...props}\n />\n));\nTooltipContent.displayName = TooltipPrimitive.Content.displayName;\n\nconst TooltipArrow = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Arrow>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Arrow>\n>(({ className, ...props }, ref) => (\n <TooltipPrimitive.Arrow ref={ref} className={cn(className)} {...props} />\n));\nTooltipArrow.displayName = TooltipPrimitive.Arrow.displayName;\n\ntype TooltipTypes = {\n /** Controls the open state of the tooltip. */\n open?: any;\n /** Specifies the side where the tooltip will appear. */\n side?: PositionType;\n /** Content to be displayed within the tooltip. */\n content?: any;\n /** Elements to which the tooltip is anchored. */\n children?: any;\n /** Sets the default open state of the tooltip. */\n defaultOpen?: any;\n /** Event handler for open state changes. */\n onOpenChange?: any;\n /** Duration of the delay before the tooltip appears. */\n delayDuration?: any;\n triggerProps?: TooltipPrimitive.TooltipTriggerProps;\n contentProps?: TooltipPrimitive.TooltipContentProps;\n providerProps?: TooltipPrimitive.TooltipProviderProps;\n};\n\nconst Tooltip: React.FunctionComponent<TooltipTypes> = ({\n side,\n open,\n content,\n children,\n defaultOpen,\n onOpenChange,\n triggerProps,\n contentProps,\n providerProps,\n delayDuration = 300,\n ...props\n}) => {\n return (\n <TooltipPrimitive.TooltipProvider\n delayDuration={delayDuration}\n {...providerProps}\n >\n <TooltipPrimitive.Root\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n {...props}\n >\n <TooltipPrimitive.Trigger {...triggerProps}>\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipContent side={side} align=\"center\" {...contentProps}>\n {content}\n </TooltipContent>\n </TooltipPrimitive.Root>\n </TooltipPrimitive.TooltipProvider>\n );\n};\n\nexport { Tooltip };\n"],"mappings":";AAAA,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ACLA,YAAYA,YAAW;;;ACAvB,OAAO,WAAW;AAElB,YAAY,sBAAsB;AAMlC,IAAM,iBAAiB,MAAM,WAG3B,CAAC,EAAE,WAAW,aAAa,GAAG,GAAG,MAAM,GAAG,QAC1C;AAAA,EAAkB;AAAA,EAAjB;AAAA,IACC;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,eAAe,cAA+B,yBAAQ;AAEtD,IAAM,eAAe,MAAM,WAGzB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B,oCAAkB,wBAAjB,EAAuB,KAAU,WAAW,GAAG,SAAS,GAAI,GAAG,OAAO,CACxE;AACD,aAAa,cAA+B,uBAAM;AAsBlD,IAAM,UAAiD,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,GAAG;AACL,MAAM;AACJ,SACE;AAAA,IAAkB;AAAA,IAAjB;AAAA,MACC;AAAA,MACC,GAAG;AAAA;AAAA,IAEJ;AAAA,MAAkB;AAAA,MAAjB;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,MAEJ,oCAAkB,0BAAjB,EAA0B,GAAG,gBAC3B,QACH;AAAA,MACA,oCAAC,kBAAe,MAAY,OAAM,UAAU,GAAG,gBAC5C,OACH;AAAA,IACF;AAAA,EACF;AAEJ;;;ADvEA,IAAM,QAAc,kBAGlB,CAAC,EAAE,WAAW,MAAM,UAAU,UAAU,UAAU,GAAG,MAAM,GAAG,QAC9D,qCAAC,SAAI,WAAU,8EACb;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AAAA,EAEH;AAAA,EACA,YAAY,qCAAC,UAAK,WAAU,mCAAgC,GAAC;AAChE,GACC,QACC;AAAA,EAAC;AAAA;AAAA,IACC,SAAS;AAAA,IACT,MAAM;AAAA,IACN,cAAc;AAAA,MACZ,UAAU;AAAA,MACV,SAAS,CAAC,UAAU,MAAM,eAAe;AAAA,IAC3C;AAAA;AAAA,EAEA,qCAAC,aACC;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,WAAU;AAAA,MACV,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA;AAAA,IAEf,qCAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,MAAK;AAAA,IAC/B,qCAAC,UAAK,GAAE,wCAAuC;AAAA,IAC/C,qCAAC,UAAK,GAAE,cAAa;AAAA,EACvB,CACF;AACF,CAEJ,CACD;AAED,MAAM,cAAc;","names":["React"]}
@@ -1,11 +0,0 @@
1
- // util/index.ts
2
- import { clsx } from "clsx";
3
- import { twMerge } from "tailwind-merge";
4
- function cn(...inputs) {
5
- return twMerge(clsx(inputs));
6
- }
7
-
8
- export {
9
- cn
10
- };
11
- //# sourceMappingURL=chunk-CBRGWUZG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../util/index.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\ntype Palette = {\n name: string;\n colors: {\n [key: number]: string;\n };\n};\ntype Rgb = {\n r: number;\n g: number;\n b: number;\n};\nfunction hexToRgb(hex: string): Rgb | null {\n const sanitizedHex = hex.replaceAll(\"##\", \"#\");\n const colorParts = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(\n sanitizedHex\n );\n\n if (!colorParts) {\n return null;\n }\n\n const [, r, g, b] = colorParts;\n\n return {\n r: parseInt(r, 16),\n g: parseInt(g, 16),\n b: parseInt(b, 16)\n } as Rgb;\n}\n\nfunction rgbToHex(r: number, g: number, b: number): string {\n const toHex = (c: number) => `0${c.toString(16)}`.slice(-2);\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\nexport function getTextColor(color: string): \"#FFF\" | \"#333\" {\n const rgbColor = hexToRgb(color);\n\n if (!rgbColor) {\n return \"#333\";\n }\n\n const { r, g, b } = rgbColor;\n const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n return luma < 120 ? \"#FFF\" : \"#333\";\n}\n\nfunction lighten(hex: string, intensity: number): string {\n const color = hexToRgb(`#${hex}`);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r + (255 - color.r) * intensity);\n const g = Math.round(color.g + (255 - color.g) * intensity);\n const b = Math.round(color.b + (255 - color.b) * intensity);\n\n return rgbToHex(r, g, b);\n}\n\nfunction darken(hex: string, intensity: number): string {\n const color = hexToRgb(hex);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r * intensity);\n const g = Math.round(color.g * intensity);\n const b = Math.round(color.b * intensity);\n\n return rgbToHex(r, g, b);\n}\nconst parseColor = (color: any) => {\n if (color.startsWith(\"#\")) {\n // Convert hex to RGB\n let r = parseInt(color.slice(1, 3), 16);\n let g = parseInt(color.slice(3, 5), 16);\n let b = parseInt(color.slice(5, 7), 16);\n return [r, g, b];\n } else if (color.startsWith(\"rgb\")) {\n // Extract RGB values from rgb() format\n return color.match(/\\d+/g).map(Number);\n }\n // Default to white if format is unrecognized\n return [255, 255, 255];\n};\nexport const calculateLuminance = (color: any) => {\n const [r, g, b] = parseColor(color)?.map((c: any) => {\n c /= 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nfunction getPallette(baseColor: string): Palette {\n const name = baseColor;\n\n const response: Palette = {\n name,\n colors: {\n 500: `#${baseColor}`.replace(\"##\", \"#\")\n }\n };\n\n const intensityMap: {\n [key: number]: number;\n } = {\n 50: 0.95,\n 100: 0.9,\n 200: 0.75,\n 300: 0.6,\n 400: 0.3,\n 600: 0.9,\n 700: 0.75,\n 800: 0.6,\n 900: 0.49\n };\n\n [50, 100, 200, 300, 400].forEach((level) => {\n response.colors[level] = lighten(baseColor, intensityMap[level]);\n });\n [600, 700, 800, 900].forEach((level) => {\n response.colors[level] = darken(baseColor, intensityMap[level]);\n });\n\n return response as Palette;\n}\n\nexport { getPallette };\n\n// const hexToRgb = (hex) => {\n// let d = hex?.split(\"#\")[1];\n// var aRgbHex = d?.match(/.{1,2}/g);\n// var aRgb = [\n// parseInt(aRgbHex[0], 16),\n// parseInt(aRgbHex[1], 16),\n// parseInt(aRgbHex[2], 16)\n// ];\n// return aRgb;\n// };\n// const getTextColor = (backColor) => {\n// let rgbArray = hexToRgb(backColor);\n// if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {\n// return \"#000000\";\n// } else {\n// return \"#ffffff\";\n// }\n// };\n// const replaceAt = function (string, index, replacement) {\n// // if (replacement == \"\" || replacement == \" \") {\n// // return (\n// // string.substring(0, index) +\n// // string.substring(index + replacement.length )\n// // );\n// // }\n// const replaced = string.substring(0, index) + replacement + string.substring(index + 1)\n// return replaced\n// };\n\n// export { hexToRgb, getTextColor, replaceAt };\n"],"mappings":";AAAA,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;","names":[]}