@sikka/hawa 0.36.2-next → 0.37.1-next
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appLayout/index.js +1 -1
- package/dist/appLayout/index.js.map +1 -1
- package/dist/appLayout/index.mjs +1 -1
- package/dist/appLayout/index.mjs.map +1 -1
- package/dist/blocks/auth/index.js +24 -25
- package/dist/blocks/auth/index.mjs +4 -4
- package/dist/blocks/feedback/index.js +24 -25
- package/dist/blocks/feedback/index.mjs +5 -5
- package/dist/blocks/index.js +308 -192
- package/dist/blocks/index.mjs +3 -3
- package/dist/blocks/misc/index.js +270 -154
- package/dist/blocks/misc/index.mjs +53 -19
- package/dist/blocks/pricing/index.js +107 -22
- package/dist/blocks/pricing/index.mjs +4 -4
- package/dist/card/index.d.mts +3 -1
- package/dist/card/index.d.ts +3 -1
- package/dist/card/index.js +13 -11
- package/dist/card/index.js.map +1 -1
- package/dist/card/index.mjs +13 -11
- package/dist/card/index.mjs.map +1 -1
- package/dist/{chunk-WABHQMUI.mjs → chunk-BPHQFAWM.mjs} +1 -1
- package/dist/{chunk-MVKP55SZ.mjs → chunk-BTDR3VAG.mjs} +1 -1
- package/dist/{chunk-7L2JUNG2.mjs → chunk-DS3AACQJ.mjs} +1 -1
- package/dist/{chunk-BXBSZD5X.mjs → chunk-MDHDHEPZ.mjs} +1 -1
- package/dist/{chunk-6QIOEUE2.mjs → chunk-ODOCZAWC.mjs} +1 -1
- package/dist/{chunk-YP2CCKZG.mjs → chunk-PXGL7ZXQ.mjs} +13 -11
- package/dist/{chunk-HLYAX77R.mjs → chunk-QXH7ZDMN.mjs} +12 -15
- package/dist/{chunk-T33FXOHA.mjs → chunk-QYWOI3DO.mjs} +152 -41
- package/dist/{chunk-NNPNQK6F.mjs → chunk-RNFJAEEU.mjs} +13 -11
- package/dist/{chunk-OPYDG34F.mjs → chunk-ZBUBNKF6.mjs} +93 -1
- package/dist/{chunk-CJ57JBYA.mjs → chunk-ZTUWU652.mjs} +95 -12
- package/dist/combobox/index.d.mts +1 -4
- package/dist/combobox/index.d.ts +1 -4
- package/dist/combobox/index.js +2 -1
- package/dist/combobox/index.js.map +1 -1
- package/dist/combobox/index.mjs +2 -1
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/command/index.d.mts +4 -36
- package/dist/command/index.d.ts +4 -36
- package/dist/command/index.js +43 -5
- package/dist/command/index.js.map +1 -1
- package/dist/command/index.mjs +39 -3
- package/dist/command/index.mjs.map +1 -1
- package/dist/destroyableCard/index.js +13 -11
- package/dist/destroyableCard/index.js.map +1 -1
- package/dist/destroyableCard/index.mjs +13 -11
- package/dist/destroyableCard/index.mjs.map +1 -1
- package/dist/elements/index.d.mts +31 -3
- package/dist/elements/index.d.ts +31 -3
- package/dist/elements/index.js +450 -295
- package/dist/elements/index.mjs +43 -6
- package/dist/hooks/index.d.mts +25 -1
- package/dist/hooks/index.d.ts +25 -1
- package/dist/hooks/index.js +96 -0
- package/dist/hooks/index.mjs +9 -1
- package/dist/index-e_Ob_SnB.d.mts +63 -0
- package/dist/index-e_Ob_SnB.d.ts +63 -0
- package/dist/index.css +20 -3
- package/dist/index.d.mts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +966 -718
- package/dist/index.mjs +494 -252
- package/dist/layout/index.js +14 -12
- package/dist/layout/index.mjs +3 -3
- package/dist/phoneInput/index.js +11 -14
- package/dist/phoneInput/index.js.map +1 -1
- package/dist/phoneInput/index.mjs +11 -14
- package/dist/phoneInput/index.mjs.map +1 -1
- package/dist/scrollArea/index.js +94 -11
- package/dist/scrollArea/index.js.map +1 -1
- package/dist/scrollArea/index.mjs +94 -11
- package/dist/scrollArea/index.mjs.map +1 -1
- package/dist/select/index.js +11 -14
- package/dist/select/index.js.map +1 -1
- package/dist/select/index.mjs +11 -14
- package/dist/select/index.mjs.map +1 -1
- package/dist/stats/index.js +13 -11
- package/dist/stats/index.js.map +1 -1
- package/dist/stats/index.mjs +13 -11
- package/dist/stats/index.mjs.map +1 -1
- package/dist/tabs/index.d.mts +3 -1
- package/dist/tabs/index.d.ts +3 -1
- package/dist/tabs/index.js +189 -32
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +184 -27
- package/dist/tabs/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/scrollArea/index.js
CHANGED
@@ -48,17 +48,100 @@ function cn(...inputs) {
|
|
48
48
|
}
|
49
49
|
|
50
50
|
// elements/scrollArea/ScrollArea.tsx
|
51
|
-
var ScrollArea = React.forwardRef(({ className, children, orientation = "vertical", ...props }, ref) =>
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
)
|
51
|
+
var ScrollArea = React.forwardRef(({ className, children, orientation = "vertical", ...props }, ref) => {
|
52
|
+
const scrollAreaRef = React.useRef(null);
|
53
|
+
const isDragging = React.useRef(false);
|
54
|
+
const startPos = React.useRef({ x: 0, y: 0 });
|
55
|
+
const scrollPos = React.useRef({ top: 0, left: 0 });
|
56
|
+
const [showLeftFade, setShowLeftFade] = React.useState(false);
|
57
|
+
const [showRightFade, setShowRightFade] = React.useState(false);
|
58
|
+
const checkOverflow = () => {
|
59
|
+
if (scrollAreaRef.current) {
|
60
|
+
const { scrollLeft, scrollWidth, clientWidth } = scrollAreaRef.current;
|
61
|
+
setShowLeftFade(scrollLeft > 0);
|
62
|
+
setShowRightFade(scrollLeft + clientWidth < scrollWidth);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
const onMouseDown = (e) => {
|
66
|
+
isDragging.current = true;
|
67
|
+
startPos.current = { x: e.clientX, y: e.clientY };
|
68
|
+
if (scrollAreaRef.current) {
|
69
|
+
scrollPos.current = {
|
70
|
+
top: scrollAreaRef.current.scrollTop,
|
71
|
+
left: scrollAreaRef.current.scrollLeft
|
72
|
+
};
|
73
|
+
}
|
74
|
+
document.addEventListener("mousemove", onMouseMove);
|
75
|
+
document.addEventListener("mouseup", onMouseUp);
|
76
|
+
};
|
77
|
+
const onMouseMove = (e) => {
|
78
|
+
if (!isDragging.current || !scrollAreaRef.current)
|
79
|
+
return;
|
80
|
+
const dx = e.clientX - startPos.current.x;
|
81
|
+
const dy = e.clientY - startPos.current.y;
|
82
|
+
if (orientation === "vertical") {
|
83
|
+
scrollAreaRef.current.scrollTop = scrollPos.current.top - dy;
|
84
|
+
} else {
|
85
|
+
scrollAreaRef.current.scrollLeft = scrollPos.current.left - dx;
|
86
|
+
checkOverflow();
|
87
|
+
}
|
88
|
+
};
|
89
|
+
const onMouseUp = () => {
|
90
|
+
isDragging.current = false;
|
91
|
+
document.removeEventListener("mousemove", onMouseMove);
|
92
|
+
document.removeEventListener("mouseup", onMouseUp);
|
93
|
+
};
|
94
|
+
React.useEffect(() => {
|
95
|
+
checkOverflow();
|
96
|
+
if (scrollAreaRef.current) {
|
97
|
+
scrollAreaRef.current.addEventListener("scroll", checkOverflow);
|
98
|
+
window.addEventListener("resize", checkOverflow);
|
99
|
+
}
|
100
|
+
return () => {
|
101
|
+
if (scrollAreaRef.current) {
|
102
|
+
scrollAreaRef.current.removeEventListener("scroll", checkOverflow);
|
103
|
+
}
|
104
|
+
window.removeEventListener("resize", checkOverflow);
|
105
|
+
};
|
106
|
+
}, []);
|
107
|
+
return /* @__PURE__ */ React.createElement(
|
108
|
+
ScrollAreaPrimitive.Root,
|
109
|
+
{
|
110
|
+
ref,
|
111
|
+
className: cn("hawa-relative hawa-overflow-hidden", className),
|
112
|
+
...props
|
113
|
+
},
|
114
|
+
/* @__PURE__ */ React.createElement(
|
115
|
+
"div",
|
116
|
+
{
|
117
|
+
className: cn(
|
118
|
+
"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-h-full hawa-w-[50px] hawa-z-10 hawa-start-0 hawa-mask-fade-right",
|
119
|
+
showLeftFade ? "hawa-block" : "hawa-hidden"
|
120
|
+
)
|
121
|
+
}
|
122
|
+
),
|
123
|
+
/* @__PURE__ */ React.createElement(
|
124
|
+
"div",
|
125
|
+
{
|
126
|
+
className: cn(
|
127
|
+
"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-mask-fade-left hawa-end-0 hawa-h-full hawa-w-[50px] hawa-z-10 ",
|
128
|
+
showRightFade ? "hawa-block" : "hawa-hidden"
|
129
|
+
)
|
130
|
+
}
|
131
|
+
),
|
132
|
+
/* @__PURE__ */ React.createElement(
|
133
|
+
ScrollAreaPrimitive.Viewport,
|
134
|
+
{
|
135
|
+
ref: scrollAreaRef,
|
136
|
+
className: "hawa-h-full hawa-w-full hawa-rounded-[inherit]",
|
137
|
+
onMouseDown
|
138
|
+
},
|
139
|
+
children
|
140
|
+
),
|
141
|
+
/* @__PURE__ */ React.createElement(ScrollBar, { orientation }),
|
142
|
+
/* @__PURE__ */ React.createElement(ScrollAreaPrimitive.Corner, null)
|
143
|
+
);
|
144
|
+
});
|
62
145
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
63
146
|
var ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React.createElement(
|
64
147
|
ScrollAreaPrimitive.ScrollAreaScrollbar,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/scrollArea/index.ts","../../elements/scrollArea/ScrollArea.tsx","../../util/index.ts"],"sourcesContent":["export * from \"./ScrollArea\";\n","import * as React from \"react\";\n\nimport * as ScrollAreaPrimitive from \"@radix-ui/react-scroll-area\";\n\nimport { OrientationType } from \"@_types/commonTypes\";\n\nimport { cn } from \"@util/index\";\n\ntype ScrollAreaProps = React.ComponentPropsWithoutRef<\n typeof ScrollAreaPrimitive.Root\n> & {\n orientation?: OrientationType;\n};\n\nconst ScrollArea = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Root>,\n ScrollAreaProps\n>(({ className, children, orientation = \"vertical\", ...props }, ref) => (\n <ScrollAreaPrimitive.Root\n ref={ref}\n className={cn(\"hawa-relative hawa-overflow-hidden\", className)}\n {...props}\n >\n <ScrollAreaPrimitive.Viewport className=\"hawa-h-full hawa-w-full hawa-rounded-[inherit]\">\n {children}\n </ScrollAreaPrimitive.Viewport>\n <ScrollBar orientation={orientation} />\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n));\n\nScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;\n\nconst ScrollBar = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>\n>(({ className, orientation = \"vertical\", ...props }, ref) => (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n ref={ref}\n orientation={orientation}\n className={cn(\n \"hawa-flex hawa-touch-none hawa-select-none hawa-transition-colors\",\n orientation === \"vertical\" &&\n \"hawa-h-full hawa-w-2.5 hawa-border-l hawa-border-l-transparent hawa-p-[1px]\",\n orientation === \"horizontal\" &&\n \"hawa-h-2.5 hawa-border-t hawa-border-t-transparent hawa-p-[1px]\",\n className\n )}\n {...props}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb\n className={cn(\n \"hawa-relative hawa-rounded-full hawa-bg-border\",\n orientation === \"vertical\" && \"hawa-flex-1\"\n )}\n />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n));\n\nScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;\n\nexport { ScrollArea, ScrollBar };\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AAEvB,0BAAqC;;;ACFrC,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADSA,IAAM,aAAmB,iBAGvB,CAAC,EAAE,WAAW,UAAU,cAAc,YAAY,GAAG,MAAM,GAAG,QAC9D;AAAA,EAAqB;AAAA,EAApB;AAAA,IACC;AAAA,IACA,WAAW,GAAG,sCAAsC,SAAS;AAAA,IAC5D,GAAG;AAAA;AAAA,EAEJ,oCAAqB,8BAApB,EAA6B,WAAU,oDACrC,QACH;AAAA,EACA,oCAAC,aAAU,aAA0B;AAAA,EACrC,oCAAqB,4BAApB,IAA2B;AAC9B,CACD;AAED,WAAW,cAAkC,yBAAK;AAElD,IAAM,YAAkB,iBAGtB,CAAC,EAAE,WAAW,cAAc,YAAY,GAAG,MAAM,GAAG,QACpD;AAAA,EAAqB;AAAA,EAApB;AAAA,IACC;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA,gBAAgB,cACd;AAAA,MACF,gBAAgB,gBACd;AAAA,MACF;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AAAA,EAEJ;AAAA,IAAqB;AAAA,IAApB;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,gBAAgB,cAAc;AAAA,MAChC;AAAA;AAAA,EACF;AACF,CACD;AAED,UAAU,cAAkC,wCAAoB;","names":[]}
|
1
|
+
{"version":3,"sources":["../../elements/scrollArea/index.ts","../../elements/scrollArea/ScrollArea.tsx","../../util/index.ts"],"sourcesContent":["export * from \"./ScrollArea\";\n","import * as React from \"react\";\n\nimport * as ScrollAreaPrimitive from \"@radix-ui/react-scroll-area\";\nimport { cn } from \"@util/index\";\n\nimport { OrientationType } from \"@_types/commonTypes\";\n\ntype ScrollAreaProps = React.ComponentPropsWithoutRef<\n typeof ScrollAreaPrimitive.Root\n> & {\n orientation?: OrientationType;\n};\n\nconst ScrollArea = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Root>,\n ScrollAreaProps\n>(({ className, children, orientation = \"vertical\", ...props }, ref) => {\n const scrollAreaRef = React.useRef<HTMLDivElement | null>(null);\n const isDragging = React.useRef(false);\n const startPos = React.useRef({ x: 0, y: 0 });\n const scrollPos = React.useRef({ top: 0, left: 0 });\n\n const [showLeftFade, setShowLeftFade] = React.useState(false);\n const [showRightFade, setShowRightFade] = React.useState(false);\n\n const checkOverflow = () => {\n if (scrollAreaRef.current) {\n const { scrollLeft, scrollWidth, clientWidth } = scrollAreaRef.current;\n setShowLeftFade(scrollLeft > 0);\n setShowRightFade(scrollLeft + clientWidth < scrollWidth);\n }\n };\n\n const onMouseDown = (e: React.MouseEvent) => {\n isDragging.current = true;\n startPos.current = { x: e.clientX, y: e.clientY };\n if (scrollAreaRef.current) {\n scrollPos.current = {\n top: scrollAreaRef.current.scrollTop,\n left: scrollAreaRef.current.scrollLeft,\n };\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n };\n\n const onMouseMove = (e: MouseEvent) => {\n if (!isDragging.current || !scrollAreaRef.current) return;\n const dx = e.clientX - startPos.current.x;\n const dy = e.clientY - startPos.current.y;\n if (orientation === \"vertical\") {\n scrollAreaRef.current.scrollTop = scrollPos.current.top - dy;\n } else {\n scrollAreaRef.current.scrollLeft = scrollPos.current.left - dx;\n checkOverflow();\n }\n };\n\n const onMouseUp = () => {\n isDragging.current = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n\n React.useEffect(() => {\n checkOverflow();\n if (scrollAreaRef.current) {\n scrollAreaRef.current.addEventListener(\"scroll\", checkOverflow);\n window.addEventListener(\"resize\", checkOverflow);\n }\n return () => {\n if (scrollAreaRef.current) {\n scrollAreaRef.current.removeEventListener(\"scroll\", checkOverflow);\n }\n window.removeEventListener(\"resize\", checkOverflow);\n };\n }, []);\n\n return (\n <ScrollAreaPrimitive.Root\n ref={ref}\n className={cn(\"hawa-relative hawa-overflow-hidden\", className)}\n {...props}\n >\n <div\n className={cn(\n \"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-h-full hawa-w-[50px] hawa-z-10 hawa-start-0 hawa-mask-fade-right\",\n showLeftFade ? \"hawa-block\" : \"hawa-hidden\",\n )}\n />\n <div\n className={cn(\n \"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-mask-fade-left hawa-end-0 hawa-h-full hawa-w-[50px] hawa-z-10 \",\n showRightFade ? \"hawa-block\" : \"hawa-hidden\",\n )}\n />\n <ScrollAreaPrimitive.Viewport\n ref={scrollAreaRef}\n className=\"hawa-h-full hawa-w-full hawa-rounded-[inherit]\"\n onMouseDown={onMouseDown}\n >\n {children}\n </ScrollAreaPrimitive.Viewport>\n <ScrollBar orientation={orientation} />\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n );\n});\n\nScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;\n\nconst ScrollBar = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>\n>(({ className, orientation = \"vertical\", ...props }, ref) => (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n ref={ref}\n orientation={orientation}\n className={cn(\n \"hawa-flex hawa-touch-none hawa-select-none hawa-transition-colors\",\n orientation === \"vertical\" &&\n \"hawa-h-full hawa-w-2.5 hawa-border-l hawa-border-l-transparent hawa-p-[1px]\",\n orientation === \"horizontal\" &&\n \"hawa-h-2.5 hawa-border-t hawa-border-t-transparent hawa-p-[1px]\",\n className,\n )}\n {...props}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb\n className={cn(\n \"hawa-relative hawa-rounded-full hawa-bg-border\",\n orientation === \"vertical\" && \"hawa-flex-1\",\n )}\n />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n));\n\nScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;\n\nexport { ScrollArea, ScrollBar };\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AAEvB,0BAAqC;;;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W;AAAA,MACT;AAAA,MACA,gBAAgB,cACd;AAAA,MACF,gBAAgB,gBACd;AAAA,MACF;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AAAA,EAEJ;AAAA,IAAqB;AAAA,IAApB;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,gBAAgB,cAAc;AAAA,MAChC;AAAA;AAAA,EACF;AACF,CACD;AAED,UAAU,cAAkC,wCAAoB;","names":[]}
|
@@ -12,17 +12,100 @@ function cn(...inputs) {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
// elements/scrollArea/ScrollArea.tsx
|
15
|
-
var ScrollArea = React.forwardRef(({ className, children, orientation = "vertical", ...props }, ref) =>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
15
|
+
var ScrollArea = React.forwardRef(({ className, children, orientation = "vertical", ...props }, ref) => {
|
16
|
+
const scrollAreaRef = React.useRef(null);
|
17
|
+
const isDragging = React.useRef(false);
|
18
|
+
const startPos = React.useRef({ x: 0, y: 0 });
|
19
|
+
const scrollPos = React.useRef({ top: 0, left: 0 });
|
20
|
+
const [showLeftFade, setShowLeftFade] = React.useState(false);
|
21
|
+
const [showRightFade, setShowRightFade] = React.useState(false);
|
22
|
+
const checkOverflow = () => {
|
23
|
+
if (scrollAreaRef.current) {
|
24
|
+
const { scrollLeft, scrollWidth, clientWidth } = scrollAreaRef.current;
|
25
|
+
setShowLeftFade(scrollLeft > 0);
|
26
|
+
setShowRightFade(scrollLeft + clientWidth < scrollWidth);
|
27
|
+
}
|
28
|
+
};
|
29
|
+
const onMouseDown = (e) => {
|
30
|
+
isDragging.current = true;
|
31
|
+
startPos.current = { x: e.clientX, y: e.clientY };
|
32
|
+
if (scrollAreaRef.current) {
|
33
|
+
scrollPos.current = {
|
34
|
+
top: scrollAreaRef.current.scrollTop,
|
35
|
+
left: scrollAreaRef.current.scrollLeft
|
36
|
+
};
|
37
|
+
}
|
38
|
+
document.addEventListener("mousemove", onMouseMove);
|
39
|
+
document.addEventListener("mouseup", onMouseUp);
|
40
|
+
};
|
41
|
+
const onMouseMove = (e) => {
|
42
|
+
if (!isDragging.current || !scrollAreaRef.current)
|
43
|
+
return;
|
44
|
+
const dx = e.clientX - startPos.current.x;
|
45
|
+
const dy = e.clientY - startPos.current.y;
|
46
|
+
if (orientation === "vertical") {
|
47
|
+
scrollAreaRef.current.scrollTop = scrollPos.current.top - dy;
|
48
|
+
} else {
|
49
|
+
scrollAreaRef.current.scrollLeft = scrollPos.current.left - dx;
|
50
|
+
checkOverflow();
|
51
|
+
}
|
52
|
+
};
|
53
|
+
const onMouseUp = () => {
|
54
|
+
isDragging.current = false;
|
55
|
+
document.removeEventListener("mousemove", onMouseMove);
|
56
|
+
document.removeEventListener("mouseup", onMouseUp);
|
57
|
+
};
|
58
|
+
React.useEffect(() => {
|
59
|
+
checkOverflow();
|
60
|
+
if (scrollAreaRef.current) {
|
61
|
+
scrollAreaRef.current.addEventListener("scroll", checkOverflow);
|
62
|
+
window.addEventListener("resize", checkOverflow);
|
63
|
+
}
|
64
|
+
return () => {
|
65
|
+
if (scrollAreaRef.current) {
|
66
|
+
scrollAreaRef.current.removeEventListener("scroll", checkOverflow);
|
67
|
+
}
|
68
|
+
window.removeEventListener("resize", checkOverflow);
|
69
|
+
};
|
70
|
+
}, []);
|
71
|
+
return /* @__PURE__ */ React.createElement(
|
72
|
+
ScrollAreaPrimitive.Root,
|
73
|
+
{
|
74
|
+
ref,
|
75
|
+
className: cn("hawa-relative hawa-overflow-hidden", className),
|
76
|
+
...props
|
77
|
+
},
|
78
|
+
/* @__PURE__ */ React.createElement(
|
79
|
+
"div",
|
80
|
+
{
|
81
|
+
className: cn(
|
82
|
+
"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-h-full hawa-w-[50px] hawa-z-10 hawa-start-0 hawa-mask-fade-right",
|
83
|
+
showLeftFade ? "hawa-block" : "hawa-hidden"
|
84
|
+
)
|
85
|
+
}
|
86
|
+
),
|
87
|
+
/* @__PURE__ */ React.createElement(
|
88
|
+
"div",
|
89
|
+
{
|
90
|
+
className: cn(
|
91
|
+
"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-mask-fade-left hawa-end-0 hawa-h-full hawa-w-[50px] hawa-z-10 ",
|
92
|
+
showRightFade ? "hawa-block" : "hawa-hidden"
|
93
|
+
)
|
94
|
+
}
|
95
|
+
),
|
96
|
+
/* @__PURE__ */ React.createElement(
|
97
|
+
ScrollAreaPrimitive.Viewport,
|
98
|
+
{
|
99
|
+
ref: scrollAreaRef,
|
100
|
+
className: "hawa-h-full hawa-w-full hawa-rounded-[inherit]",
|
101
|
+
onMouseDown
|
102
|
+
},
|
103
|
+
children
|
104
|
+
),
|
105
|
+
/* @__PURE__ */ React.createElement(ScrollBar, { orientation }),
|
106
|
+
/* @__PURE__ */ React.createElement(ScrollAreaPrimitive.Corner, null)
|
107
|
+
);
|
108
|
+
});
|
26
109
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
27
110
|
var ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React.createElement(
|
28
111
|
ScrollAreaPrimitive.ScrollAreaScrollbar,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/scrollArea/ScrollArea.tsx","../../util/index.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport * as ScrollAreaPrimitive from \"@radix-ui/react-scroll-area\";\n\nimport { OrientationType } from \"@_types/commonTypes\";\n\nimport { cn } from \"@util/index\";\n\ntype ScrollAreaProps = React.ComponentPropsWithoutRef<\n typeof ScrollAreaPrimitive.Root\n> & {\n orientation?: OrientationType;\n};\n\nconst ScrollArea = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Root>,\n ScrollAreaProps\n>(({ className, children, orientation = \"vertical\", ...props }, ref) => (\n <ScrollAreaPrimitive.Root\n ref={ref}\n className={cn(\"hawa-relative hawa-overflow-hidden\", className)}\n {...props}\n >\n <ScrollAreaPrimitive.Viewport className=\"hawa-h-full hawa-w-full hawa-rounded-[inherit]\">\n {children}\n </ScrollAreaPrimitive.Viewport>\n <ScrollBar orientation={orientation} />\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n));\n\nScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;\n\nconst ScrollBar = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>\n>(({ className, orientation = \"vertical\", ...props }, ref) => (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n ref={ref}\n orientation={orientation}\n className={cn(\n \"hawa-flex hawa-touch-none hawa-select-none hawa-transition-colors\",\n orientation === \"vertical\" &&\n \"hawa-h-full hawa-w-2.5 hawa-border-l hawa-border-l-transparent hawa-p-[1px]\",\n orientation === \"horizontal\" &&\n \"hawa-h-2.5 hawa-border-t hawa-border-t-transparent hawa-p-[1px]\",\n className\n )}\n {...props}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb\n className={cn(\n \"hawa-relative hawa-rounded-full hawa-bg-border\",\n orientation === \"vertical\" && \"hawa-flex-1\"\n )}\n />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n));\n\nScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;\n\nexport { ScrollArea, ScrollBar };\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"],"mappings":";;;AAAA,YAAY,WAAW;AAEvB,YAAY,yBAAyB;;;ACFrC,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADSA,IAAM,aAAmB,iBAGvB,CAAC,EAAE,WAAW,UAAU,cAAc,YAAY,GAAG,MAAM,GAAG,QAC9D;AAAA,EAAqB;AAAA,EAApB;AAAA,IACC;AAAA,IACA,WAAW,GAAG,sCAAsC,SAAS;AAAA,IAC5D,GAAG;AAAA;AAAA,EAEJ,oCAAqB,8BAApB,EAA6B,WAAU,oDACrC,QACH;AAAA,EACA,oCAAC,aAAU,aAA0B;AAAA,EACrC,oCAAqB,4BAApB,IAA2B;AAC9B,CACD;AAED,WAAW,cAAkC,yBAAK;AAElD,IAAM,YAAkB,iBAGtB,CAAC,EAAE,WAAW,cAAc,YAAY,GAAG,MAAM,GAAG,QACpD;AAAA,EAAqB;AAAA,EAApB;AAAA,IACC;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA,gBAAgB,cACd;AAAA,MACF,gBAAgB,gBACd;AAAA,MACF;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AAAA,EAEJ;AAAA,IAAqB;AAAA,IAApB;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,gBAAgB,cAAc;AAAA,MAChC;AAAA;AAAA,EACF;AACF,CACD;AAED,UAAU,cAAkC,wCAAoB;","names":[]}
|
1
|
+
{"version":3,"sources":["../../elements/scrollArea/ScrollArea.tsx","../../util/index.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport * as ScrollAreaPrimitive from \"@radix-ui/react-scroll-area\";\nimport { cn } from \"@util/index\";\n\nimport { OrientationType } from \"@_types/commonTypes\";\n\ntype ScrollAreaProps = React.ComponentPropsWithoutRef<\n typeof ScrollAreaPrimitive.Root\n> & {\n orientation?: OrientationType;\n};\n\nconst ScrollArea = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Root>,\n ScrollAreaProps\n>(({ className, children, orientation = \"vertical\", ...props }, ref) => {\n const scrollAreaRef = React.useRef<HTMLDivElement | null>(null);\n const isDragging = React.useRef(false);\n const startPos = React.useRef({ x: 0, y: 0 });\n const scrollPos = React.useRef({ top: 0, left: 0 });\n\n const [showLeftFade, setShowLeftFade] = React.useState(false);\n const [showRightFade, setShowRightFade] = React.useState(false);\n\n const checkOverflow = () => {\n if (scrollAreaRef.current) {\n const { scrollLeft, scrollWidth, clientWidth } = scrollAreaRef.current;\n setShowLeftFade(scrollLeft > 0);\n setShowRightFade(scrollLeft + clientWidth < scrollWidth);\n }\n };\n\n const onMouseDown = (e: React.MouseEvent) => {\n isDragging.current = true;\n startPos.current = { x: e.clientX, y: e.clientY };\n if (scrollAreaRef.current) {\n scrollPos.current = {\n top: scrollAreaRef.current.scrollTop,\n left: scrollAreaRef.current.scrollLeft,\n };\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n };\n\n const onMouseMove = (e: MouseEvent) => {\n if (!isDragging.current || !scrollAreaRef.current) return;\n const dx = e.clientX - startPos.current.x;\n const dy = e.clientY - startPos.current.y;\n if (orientation === \"vertical\") {\n scrollAreaRef.current.scrollTop = scrollPos.current.top - dy;\n } else {\n scrollAreaRef.current.scrollLeft = scrollPos.current.left - dx;\n checkOverflow();\n }\n };\n\n const onMouseUp = () => {\n isDragging.current = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n\n React.useEffect(() => {\n checkOverflow();\n if (scrollAreaRef.current) {\n scrollAreaRef.current.addEventListener(\"scroll\", checkOverflow);\n window.addEventListener(\"resize\", checkOverflow);\n }\n return () => {\n if (scrollAreaRef.current) {\n scrollAreaRef.current.removeEventListener(\"scroll\", checkOverflow);\n }\n window.removeEventListener(\"resize\", checkOverflow);\n };\n }, []);\n\n return (\n <ScrollAreaPrimitive.Root\n ref={ref}\n className={cn(\"hawa-relative hawa-overflow-hidden\", className)}\n {...props}\n >\n <div\n className={cn(\n \"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-h-full hawa-w-[50px] hawa-z-10 hawa-start-0 hawa-mask-fade-right\",\n showLeftFade ? \"hawa-block\" : \"hawa-hidden\",\n )}\n />\n <div\n className={cn(\n \"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-mask-fade-left hawa-end-0 hawa-h-full hawa-w-[50px] hawa-z-10 \",\n showRightFade ? \"hawa-block\" : \"hawa-hidden\",\n )}\n />\n <ScrollAreaPrimitive.Viewport\n ref={scrollAreaRef}\n className=\"hawa-h-full hawa-w-full hawa-rounded-[inherit]\"\n onMouseDown={onMouseDown}\n >\n {children}\n </ScrollAreaPrimitive.Viewport>\n <ScrollBar orientation={orientation} />\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n );\n});\n\nScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;\n\nconst ScrollBar = React.forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>\n>(({ className, orientation = \"vertical\", ...props }, ref) => (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n ref={ref}\n orientation={orientation}\n className={cn(\n \"hawa-flex hawa-touch-none hawa-select-none hawa-transition-colors\",\n orientation === \"vertical\" &&\n \"hawa-h-full hawa-w-2.5 hawa-border-l hawa-border-l-transparent hawa-p-[1px]\",\n orientation === \"horizontal\" &&\n \"hawa-h-2.5 hawa-border-t hawa-border-t-transparent hawa-p-[1px]\",\n className,\n )}\n {...props}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb\n className={cn(\n \"hawa-relative hawa-rounded-full hawa-bg-border\",\n orientation === \"vertical\" && \"hawa-flex-1\",\n )}\n />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n));\n\nScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;\n\nexport { ScrollArea, ScrollBar };\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"],"mappings":";;;AAAA,YAAY,WAAW;AAEvB,YAAY,yBAAyB;;;ACFrC,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADQA,IAAM,aAAmB,iBA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qB;AAAA,IAApB;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,gBAAgB,cAAc;AAAA,MAChC;AAAA;AAAA,EACF;AACF,CACD;AAED,UAAU,cAAkC,wCAAoB;","names":[]}
|
package/dist/select/index.js
CHANGED
@@ -260,6 +260,10 @@ var Select = ({
|
|
260
260
|
children
|
261
261
|
);
|
262
262
|
};
|
263
|
+
let phoneCodeStyles = "hawa-min-w-[65px] hawa-text-right hawa-w-[100px] hawa-p-0 hawa-rounded-r-none hawa-h-[40px]";
|
264
|
+
let selectContainerStyles = "hawa-rounded hawa-block hawa-w-full hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm";
|
265
|
+
let selectPlaceholderStyles = "hawa-text-muted-foreground hawa-cursor-pointer hawa-px-1";
|
266
|
+
let selectIndicatorContainerStyles = "hawa-cursor-pointer hawa-text-muted-foreground hawa-absolute hawa-end-0 hawa-top-[50%] hawa-bottom-[50%] ";
|
263
267
|
return /* @__PURE__ */ import_react3.default.createElement(
|
264
268
|
"div",
|
265
269
|
{
|
@@ -281,26 +285,22 @@ var Select = ({
|
|
281
285
|
props.controlClassNames
|
282
286
|
),
|
283
287
|
container: () => cn(
|
284
|
-
|
285
|
-
props.phoneCode &&
|
286
|
-
"hawa-block hawa-w-full hawa-rounded hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm",
|
288
|
+
selectContainerStyles,
|
289
|
+
props.phoneCode && phoneCodeStyles,
|
287
290
|
props.disabled ? "hawa-cursor-not-allowed" : "hawa-cursor-pointer",
|
288
291
|
props.isMulti && "hawa-ps-0 "
|
289
292
|
),
|
290
|
-
placeholder: () =>
|
293
|
+
placeholder: () => selectPlaceholderStyles,
|
291
294
|
valueContainer: () => "hawa-text-foreground hawa-px-1 ",
|
292
295
|
singleValue: () => "hawa-text-foreground",
|
293
296
|
indicatorsContainer: () => cn(
|
294
|
-
|
297
|
+
selectIndicatorContainerStyles,
|
295
298
|
props.hideIndicator ? "hawa-invisible" : "hawa-px-1"
|
296
299
|
)
|
297
300
|
},
|
298
301
|
unstyled: true,
|
299
|
-
|
300
|
-
|
301
|
-
Menu,
|
302
|
-
IndicatorsContainer: () => null
|
303
|
-
} : {
|
302
|
+
autoFocus: false,
|
303
|
+
components: props.hideIndicator ? { Option, Menu, IndicatorsContainer: () => null } : {
|
304
304
|
Option,
|
305
305
|
Menu,
|
306
306
|
// Control: (e) => (
|
@@ -322,10 +322,7 @@ var Select = ({
|
|
322
322
|
MultiValueContainer: (e) => /* @__PURE__ */ import_react3.default.createElement(
|
323
323
|
"div",
|
324
324
|
{
|
325
|
-
className:
|
326
|
-
// e.className,
|
327
|
-
"hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row"
|
328
|
-
),
|
325
|
+
className: "hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row",
|
329
326
|
...e
|
330
327
|
}
|
331
328
|
)
|
package/dist/select/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/select/index.ts","../../elements/select/Select.tsx","../../util/index.ts","../../elements/label/Label.tsx","../../elements/tooltip/Tooltip.tsx","../../elements/skeleton/Skeleton.tsx"],"sourcesContent":["export * from \"./Select\";","import React, { FC } from \"react\";\nimport ReactSelect, { MenuProps } from \"react-select\";\nimport CreatableSelect from \"react-select/creatable\";\n\nimport { cn } from \"@util/index\";\nimport clsx from \"clsx\";\n\nimport { Label, LabelProps } from \"../label\";\nimport { Skeleton } from \"../skeleton\";\n\ntype ControlTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\n// The options container\ntype MenuTypes = MenuProps & {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n};\n\n// The single options\ntype OptionTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\nexport type SelectOptionProps = {\n value: any;\n label: any;\n};\n\ntype SelectTypes = {\n label?: string;\n hideHelperText?: boolean;\n options: SelectOptionProps[];\n labelKey?: string;\n isCreatable?: boolean;\n isClearable?: boolean;\n isMulti?: boolean;\n isSearchable?: boolean;\n controlClassNames?: string;\n containerClassNames?: string;\n onChange: any;\n helperText?: string;\n onInputChange?: any;\n native?: any;\n width?: \"full\" | \"small\" | \"fit\";\n value?: any;\n children?: any;\n getOptionLabel?: any;\n disabled?: boolean;\n defaultValue?: any;\n handleCreateOption?: () => void;\n placeholder?: string;\n hideIndicator?: boolean;\n phoneCode?: boolean;\n isLoading?: any;\n labelProps?: LabelProps;\n texts?: {\n noOptions?: string;\n createLabel?: string;\n };\n};\n\nexport const Select: FC<SelectTypes> = ({\n labelProps,\n labelKey = \"label\",\n ...props\n}) => {\n const NoOption = () => {\n return <div>{props.texts?.noOptions ?? \"No Items Found\"}</div>;\n };\n const Control: FC<ControlTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={clsx(\n \"hawa-flex hawa-w-full hawa-rounded hawa-border hawa-bg-background hawa-p-2 hawa-text-sm hawa-text-gray-900 focus:hawa-border-blue-500 focus:hawa-ring-blue-500 dark:focus:hawa-ring-blue-500\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Option: FC<OptionTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={cn(\n \"hawa-flex hawa-cursor-pointer hawa-select-none hawa-flex-row hawa-items-center hawa-justify-between hawa-rounded-inner hawa-p-1 hawa-px-2 hawa-transition-all hover:hawa-bg-primary hover:hawa-text-primary-foreground\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Menu: FC<MenuTypes> = ({\n cx,\n children,\n getStyles,\n innerProps,\n innerRef,\n ...menuProps\n }) => {\n const menuOpen = menuProps.selectProps.menuIsOpen;\n return (\n <div\n className={cn(\n \"dark:dark-shadow hawa-absolute hawa-z-10 -hawa-mx-1 hawa-mt-1 hawa-flex hawa-flex-col hawa-justify-start hawa-rounded hawa-border hawa-bg-background hawa-shadow-md\",\n props.phoneCode ? \"hawa-p-1.5\" : \"hawa-w-full hawa-p-1.5\",\n menuOpen && \"hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 \",\n )}\n ref={innerRef}\n {...innerProps}\n // {...props}\n >\n {children}\n </div>\n );\n };\n\n return (\n <div\n className={cn(\n \"hawa-flex hawa-flex-col hawa-gap-2\",\n props.width === \"fit\" ? \"hawa-w-fit\" : \"hawa-w-full\",\n )}\n >\n {props.label && <Label {...labelProps}>{props.label}</Label>}\n {props.isLoading ? (\n <Skeleton className=\"hawa-h-[40px] hawa-w-full\" />\n ) : !props.isCreatable ? (\n // TODO: enable keyboard to go to the next item in the list\n <ReactSelect\n noOptionsMessage={NoOption}\n classNames={{\n control: () =>\n cn(\n props.phoneCode && \"hawa-rounded-r-none\",\n props.controlClassNames,\n ),\n container: () =>\n cn(\n \"hawa-rounded \",\n props.phoneCode &&\n \"hawa-min-w-[65px] hawa-text-right hawa-w-[100px] hawa-p-0 hawa-rounded-r-none hawa-h-[40px] \",\n\n \"hawa-block hawa-w-full hawa-rounded hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm\",\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n\n props.isMulti && \"hawa-ps-0 \",\n ),\n\n placeholder: () =>\n \"hawa-text-muted-foreground hawa-cursor-pointer hawa-px-1\",\n valueContainer: () => \"hawa-text-foreground hawa-px-1 \",\n singleValue: () => \"hawa-text-foreground\",\n indicatorsContainer: () =>\n cn(\n \"hawa-cursor-pointer hawa-text-muted-foreground hawa-absolute hawa-end-0 hawa-top-[50%] hawa-bottom-[50%] \",\n props.hideIndicator ? \"hawa-invisible\" : \"hawa-px-1\",\n ),\n }}\n unstyled\n // autoFocus\n components={\n props.hideIndicator\n ? {\n Option,\n Menu,\n IndicatorsContainer: () => null,\n }\n : {\n Option,\n Menu,\n // Control: (e) => (\n // <div\n // className={cn(e.className, \"hawa-flex hawa-flex-row\")}\n // {...e}\n // />\n // ),\n\n ValueContainer: (e) => (\n <div\n className={cn(\n e.className,\n \"hawa-gap-1 hawa-flex hawa-flex-row hawa-flex-wrap hawa-p-1\",\n )}\n {...e}\n />\n ),\n MultiValueContainer: (e) => (\n <div\n className={cn(\n // e.className,\n \"hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row\",\n )}\n {...e}\n />\n ),\n }\n }\n onChange={(newValue: any, action) => props.onChange(newValue, action)}\n options={props.options}\n getOptionLabel={props.getOptionLabel}\n defaultValue={props.defaultValue}\n placeholder={props.placeholder}\n isDisabled={props.disabled}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n />\n ) : (\n <CreatableSelect\n formatCreateLabel={(inputValue) =>\n `${props.texts?.createLabel ?? \"Create\"} \"${inputValue}\"`\n }\n classNames={{\n container: () =>\n cn(\n \"hawa-rounded\",\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n ),\n placeholder: () => \"hawa-px-2 hawa-text-muted-foreground\",\n input: () => \"hawa-text-primary hawa-px-2\",\n valueContainer: () =>\n \"hawa-text-white dark:hawa-text-muted-foreground\",\n singleValue: () => \"hawa-text-black dark:hawa-text-white hawa-px-2\",\n indicatorsContainer: () =>\n \" hawa-px-2 hawa-cursor-pointer hawa-text-muted-foreground\",\n }}\n unstyled\n options={props.options}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n placeholder={props.placeholder}\n onCreateOption={props.handleCreateOption}\n onChange={(newValue, action) => props.onChange(newValue, action)}\n components={{ Control, Option, Menu }}\n onInputChange={(newValue, action) =>\n props.onInputChange(newValue, action)\n }\n />\n )}\n {!props.hideHelperText && (\n <p\n className={cn(\n \"hawa-my-0 hawa-text-start hawa-text-xs hawa-text-helper-color hawa-transition-all\",\n props.helperText\n ? \"hawa-h-4 hawa-opacity-100\"\n : \"hawa-h-0 hawa-opacity-0\",\n )}\n >\n {props.helperText}\n </p>\n )}\n </div>\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 { 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\";\nimport { cn } from \"@util/index\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {\n size?: \"default\" | \"small\" | \"large\";\n }\n>(({ className, sideOffset = 4, size = \"default\", ...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 {\n \"hawa-text-xs\": size === \"small\",\n \"hawa-text-xl\": size === \"large\"\n },\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 /** Size of the tooltip. */\n size?: \"default\" | \"small\" | \"large\";\n /** Disables the tooltip. */\n disabled?: boolean;\n triggerProps?: TooltipPrimitive.TooltipTriggerProps;\n contentProps?: TooltipPrimitive.TooltipContentProps;\n providerProps?: TooltipPrimitive.TooltipProviderProps;\n};\n\nconst Tooltip: React.FunctionComponent<TooltipTypes> = ({\n side,\n size,\n open,\n content,\n children,\n disabled,\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={!disabled && open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n {...props}\n >\n <TooltipPrimitive.Trigger {...triggerProps}>\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipContent\n size={size}\n side={side}\n align=\"center\"\n {...contentProps}\n style={{\n ...contentProps?.style,\n maxWidth: \"var(--radix-tooltip-content-available-width)\",\n maxHeight: \"var(--radix-tooltip-content-available-height)\"\n }}\n >\n {content}\n </TooltipContent>\n </TooltipPrimitive.Root>\n </TooltipPrimitive.TooltipProvider>\n );\n};\n\nexport { Tooltip };\n","import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ninterface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n animation?: \"none\" | \"pulse\" | \"shimmer\";\n content?: any;\n fade?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}\n\nfunction Skeleton({\n className,\n content,\n animation = \"pulse\",\n fade,\n ...props\n}: SkeletonProps) {\n const animationStyles = {\n none: \"hawa-rounded hawa-bg-muted\",\n pulse: \"hawa-animate-pulse hawa-rounded hawa-bg-muted\",\n shimmer:\n \"hawa-space-y-5 hawa-rounded hawa-bg-muted hawa-p-4 hawa-relative before:hawa-absolute before:hawa-inset-0 before:hawa--translate-x-full before:hawa-animate-[shimmer_2s_infinite] before:hawa-bg-gradient-to-r before:hawa-from-transparent before:hawa-via-gray-300/40 dark:before:hawa-via-white/10 before:hawa-to-transparent hawa-isolate hawa-overflow-hidden before:hawa-border-t before:hawa-border-rose-100/10\",\n };\n const fadeStyle = {\n bottom: \"hawa-mask-fade-bottom\",\n top: \"hawa-mask-fade-top\",\n right: \"hawa-mask-fade-right\",\n left: \"hawa-mask-fade-left \",\n };\n\n return (\n <div\n className={cn(\n animationStyles[animation],\n content &&\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n fade && fadeStyle[fade],\n className,\n )}\n {...props}\n >\n {content && content}\n </div>\n );\n}\n\nexport { Skeleton };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA0B;AAC1B,0BAAuC;AACvC,uBAA4B;;;ACF5B,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADAA,IAAAC,eAAiB;;;AELjB,IAAAC,SAAuB;;;ACAvB,mBAAkB;AAElB,uBAAkC;AAKlC,IAAM,iBAAiB,aAAAC,QAAM,WAK3B,CAAC,EAAE,WAAW,aAAa,GAAG,OAAO,WAAW,GAAG,MAAM,GAAG,QAC5D,6BAAAA,QAAA;AAAA,EAAkB;AAAA,EAAjB;AAAA,IACC;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,QACE,gBAAgB,SAAS;AAAA,QACzB,gBAAgB,SAAS;AAAA,MAC3B;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,eAAe,cAA+B,yBAAQ;AAEtD,IAAM,eAAe,aAAAA,QAAM,WAGzB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B,6BAAAA,QAAA,cAAkB,wBAAjB,EAAuB,KAAU,WAAW,GAAG,SAAS,GAAI,GAAG,OAAO,CACxE;AACD,aAAa,cAA+B,uBAAM;AA0BlD,IAAM,UAAiD,CAAC;AAAA,EACtD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AAAA,QACJ;AAAA,QACA,UAAQ;AAAA,QACR,SAAS,MAAM;AAAA,QACf,aAAa,MAAM;AAAA,QACnB,SAAS,MAAM;AAAA,QACf,cAAc,MAAM;AAAA,QACpB,aAAa,MAAM;AAAA,QACnB,gBAAgB,MAAM;AAAA,QACtB,UAAU,CAAC,UAAU,WAAW,MAAM,SAAS,UAAU,MAAM;AAAA,QAC/D,YAAY,EAAE,SAAS,QAAQ,KAAK;AAAA,QACpC,eAAe,CAAC,UAAU,WACxB,MAAM,cAAc,UAAU,MAAM;AAAA;AAAA,IAExC;AAAA,IAED,CAAC,MAAM,kBACN,8BAAAH,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,MAAM,aACF,8BACA;AAAA,QACN;AAAA;AAAA,MAEC,MAAM;AAAA,IACT;AAAA,EAEJ;AAEJ;","names":["import_react","import_clsx","React","React","import_react","React","React","clsx","ReactSelect","CreatableSelect"]}
|
1
|
+
{"version":3,"sources":["../../elements/select/index.ts","../../elements/select/Select.tsx","../../util/index.ts","../../elements/label/Label.tsx","../../elements/tooltip/Tooltip.tsx","../../elements/skeleton/Skeleton.tsx"],"sourcesContent":["export * from \"./Select\";","import React, { FC } from \"react\";\nimport ReactSelect, { MenuProps } from \"react-select\";\nimport CreatableSelect from \"react-select/creatable\";\n\nimport { cn } from \"@util/index\";\nimport clsx from \"clsx\";\n\nimport { Label, LabelProps } from \"../label\";\nimport { Skeleton } from \"../skeleton\";\n\ntype ControlTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\n// The options container\ntype MenuTypes = MenuProps & {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n};\n\n// The single options\ntype OptionTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\nexport type SelectOptionProps = {\n value: any;\n label: any;\n};\n\ntype SelectTypes = {\n label?: string;\n hideHelperText?: boolean;\n options: SelectOptionProps[];\n labelKey?: string;\n isCreatable?: boolean;\n isClearable?: boolean;\n isMulti?: boolean;\n isSearchable?: boolean;\n controlClassNames?: string;\n containerClassNames?: string;\n onChange: any;\n helperText?: string;\n onInputChange?: any;\n native?: any;\n width?: \"full\" | \"small\" | \"fit\";\n value?: any;\n children?: any;\n getOptionLabel?: any;\n disabled?: boolean;\n defaultValue?: any;\n handleCreateOption?: () => void;\n placeholder?: string;\n hideIndicator?: boolean;\n phoneCode?: boolean;\n isLoading?: any;\n labelProps?: LabelProps;\n texts?: {\n noOptions?: string;\n createLabel?: string;\n };\n};\n\nexport const Select: FC<SelectTypes> = ({\n labelProps,\n labelKey = \"label\",\n ...props\n}) => {\n const NoOption = () => {\n return <div>{props.texts?.noOptions ?? \"No Items Found\"}</div>;\n };\n const Control: FC<ControlTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={clsx(\n \"hawa-flex hawa-w-full hawa-rounded hawa-border hawa-bg-background hawa-p-2 hawa-text-sm hawa-text-gray-900 focus:hawa-border-blue-500 focus:hawa-ring-blue-500 dark:focus:hawa-ring-blue-500\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Option: FC<OptionTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={cn(\n \"hawa-flex hawa-cursor-pointer hawa-select-none hawa-flex-row hawa-items-center hawa-justify-between hawa-rounded-inner hawa-p-1 hawa-px-2 hawa-transition-all hover:hawa-bg-primary hover:hawa-text-primary-foreground\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Menu: FC<MenuTypes> = ({\n cx,\n children,\n getStyles,\n innerProps,\n innerRef,\n ...menuProps\n }) => {\n const menuOpen = menuProps.selectProps.menuIsOpen;\n return (\n <div\n className={cn(\n \"dark:dark-shadow hawa-absolute hawa-z-10 -hawa-mx-1 hawa-mt-1 hawa-flex hawa-flex-col hawa-justify-start hawa-rounded hawa-border hawa-bg-background hawa-shadow-md\",\n props.phoneCode ? \"hawa-p-1.5\" : \"hawa-w-full hawa-p-1.5\",\n menuOpen && \"hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 \",\n )}\n ref={innerRef}\n {...innerProps}\n // {...props}\n >\n {children}\n </div>\n );\n };\n\n let phoneCodeStyles =\n \"hawa-min-w-[65px] hawa-text-right hawa-w-[100px] hawa-p-0 hawa-rounded-r-none hawa-h-[40px]\";\n let selectContainerStyles =\n \"hawa-rounded hawa-block hawa-w-full hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm\";\n let selectPlaceholderStyles =\n \"hawa-text-muted-foreground hawa-cursor-pointer hawa-px-1\";\n let selectIndicatorContainerStyles =\n \"hawa-cursor-pointer hawa-text-muted-foreground hawa-absolute hawa-end-0 hawa-top-[50%] hawa-bottom-[50%] \";\n return (\n <div\n className={cn(\n \"hawa-flex hawa-flex-col hawa-gap-2\",\n props.width === \"fit\" ? \"hawa-w-fit\" : \"hawa-w-full\",\n )}\n >\n {props.label && <Label {...labelProps}>{props.label}</Label>}\n {props.isLoading ? (\n <Skeleton className=\"hawa-h-[40px] hawa-w-full\" />\n ) : !props.isCreatable ? (\n // TODO: enable keyboard to go to the next item in the list\n <ReactSelect\n noOptionsMessage={NoOption}\n classNames={{\n control: () =>\n cn(\n props.phoneCode && \"hawa-rounded-r-none\",\n props.controlClassNames,\n ),\n container: () =>\n cn(\n selectContainerStyles,\n props.phoneCode && phoneCodeStyles,\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n props.isMulti && \"hawa-ps-0 \",\n ),\n placeholder: () => selectPlaceholderStyles,\n valueContainer: () => \"hawa-text-foreground hawa-px-1 \",\n singleValue: () => \"hawa-text-foreground\",\n indicatorsContainer: () =>\n cn(\n selectIndicatorContainerStyles,\n props.hideIndicator ? \"hawa-invisible\" : \"hawa-px-1\",\n ),\n }}\n unstyled\n autoFocus={false}\n components={\n props.hideIndicator\n ? { Option, Menu, IndicatorsContainer: () => null }\n : {\n Option,\n Menu,\n // Control: (e) => (\n // <div\n // className={cn(e.className, \"hawa-flex hawa-flex-row\")}\n // {...e}\n // />\n // ),\n\n ValueContainer: (e) => (\n <div\n className={cn(\n e.className,\n \"hawa-gap-1 hawa-flex hawa-flex-row hawa-flex-wrap hawa-p-1\",\n )}\n {...e}\n />\n ),\n MultiValueContainer: (e) => (\n <div\n className=\"hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row\"\n {...e}\n />\n ),\n }\n }\n onChange={(newValue: any, action) => props.onChange(newValue, action)}\n options={props.options}\n getOptionLabel={props.getOptionLabel}\n defaultValue={props.defaultValue}\n placeholder={props.placeholder}\n isDisabled={props.disabled}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n />\n ) : (\n <CreatableSelect\n formatCreateLabel={(inputValue) =>\n `${props.texts?.createLabel ?? \"Create\"} \"${inputValue}\"`\n }\n classNames={{\n container: () =>\n cn(\n \"hawa-rounded\",\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n ),\n placeholder: () => \"hawa-px-2 hawa-text-muted-foreground\",\n input: () => \"hawa-text-primary hawa-px-2\",\n valueContainer: () =>\n \"hawa-text-white dark:hawa-text-muted-foreground\",\n singleValue: () => \"hawa-text-black dark:hawa-text-white hawa-px-2\",\n indicatorsContainer: () =>\n \" hawa-px-2 hawa-cursor-pointer hawa-text-muted-foreground\",\n }}\n unstyled\n options={props.options}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n placeholder={props.placeholder}\n onCreateOption={props.handleCreateOption}\n onChange={(newValue, action) => props.onChange(newValue, action)}\n components={{ Control, Option, Menu }}\n onInputChange={(newValue, action) =>\n props.onInputChange(newValue, action)\n }\n />\n )}\n {!props.hideHelperText && (\n <p\n className={cn(\n \"hawa-my-0 hawa-text-start hawa-text-xs hawa-text-helper-color hawa-transition-all\",\n props.helperText\n ? \"hawa-h-4 hawa-opacity-100\"\n : \"hawa-h-0 hawa-opacity-0\",\n )}\n >\n {props.helperText}\n </p>\n )}\n </div>\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 { 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\";\nimport { cn } from \"@util/index\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {\n size?: \"default\" | \"small\" | \"large\";\n }\n>(({ className, sideOffset = 4, size = \"default\", ...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 {\n \"hawa-text-xs\": size === \"small\",\n \"hawa-text-xl\": size === \"large\"\n },\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 /** Size of the tooltip. */\n size?: \"default\" | \"small\" | \"large\";\n /** Disables the tooltip. */\n disabled?: boolean;\n triggerProps?: TooltipPrimitive.TooltipTriggerProps;\n contentProps?: TooltipPrimitive.TooltipContentProps;\n providerProps?: TooltipPrimitive.TooltipProviderProps;\n};\n\nconst Tooltip: React.FunctionComponent<TooltipTypes> = ({\n side,\n size,\n open,\n content,\n children,\n disabled,\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={!disabled && open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n {...props}\n >\n <TooltipPrimitive.Trigger {...triggerProps}>\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipContent\n size={size}\n side={side}\n align=\"center\"\n {...contentProps}\n style={{\n ...contentProps?.style,\n maxWidth: \"var(--radix-tooltip-content-available-width)\",\n maxHeight: \"var(--radix-tooltip-content-available-height)\"\n }}\n >\n {content}\n </TooltipContent>\n </TooltipPrimitive.Root>\n </TooltipPrimitive.TooltipProvider>\n );\n};\n\nexport { Tooltip };\n","import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ninterface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n animation?: \"none\" | \"pulse\" | \"shimmer\";\n content?: any;\n fade?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}\n\nfunction Skeleton({\n className,\n content,\n animation = \"pulse\",\n fade,\n ...props\n}: SkeletonProps) {\n const animationStyles = {\n none: \"hawa-rounded hawa-bg-muted\",\n pulse: \"hawa-animate-pulse hawa-rounded hawa-bg-muted\",\n shimmer:\n \"hawa-space-y-5 hawa-rounded hawa-bg-muted hawa-p-4 hawa-relative before:hawa-absolute before:hawa-inset-0 before:hawa--translate-x-full before:hawa-animate-[shimmer_2s_infinite] before:hawa-bg-gradient-to-r before:hawa-from-transparent before:hawa-via-gray-300/40 dark:before:hawa-via-white/10 before:hawa-to-transparent hawa-isolate hawa-overflow-hidden before:hawa-border-t before:hawa-border-rose-100/10\",\n };\n const fadeStyle = {\n bottom: \"hawa-mask-fade-bottom\",\n top: \"hawa-mask-fade-top\",\n right: \"hawa-mask-fade-right\",\n left: \"hawa-mask-fade-left \",\n };\n\n return (\n <div\n className={cn(\n animationStyles[animation],\n content &&\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n fade && fadeStyle[fade],\n className,\n )}\n {...props}\n >\n {content && content}\n </div>\n );\n}\n\nexport { Skeleton };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA0B;AAC1B,0BAAuC;AACvC,uBAA4B;;;ACF5B,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADAA,IAAAC,eAAiB;;;AELjB,IAAAC,SAAuB;;;ACAvB,mBAAkB;AAElB,uBAAkC;AAKlC,IAAM,iBAAiB,aAAAC,QAAM,WAK3B,CAAC,EAAE,WAAW,aAAa,GAAG,OAAO,WAAW,GAAG,MAAM,GAAG,QAC5D,6BAAAA,QAAA;AAAA,EAAkB;AAAA,EAAjB;AAAA,IACC;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,QACE,gBAAgB,SAAS;AAAA,QACzB,gBAAgB,SAAS;AAAA,MAC3B;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,eAAe,cAA+B,yBAAQ;AAEtD,IAAM,eAAe,aAAAA,QAAM,WAGzB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B,6BAAAA,QAAA,cAAkB,wBAAjB,EAAuB,KAAU,WAAW,GAAG,SAAS,GAAI,GAAG,OAAO,CACxE;AACD,aAAa,cAA+B,uBAAM;AA0BlD,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MACd;AAAA,UACF,aAAa,MAAM;AAAA,UACnB,qBAAqB,MACnB;AAAA,QACJ;AAAA,QACA,UAAQ;AAAA,QACR,SAAS,MAAM;AAAA,QACf,aAAa,MAAM;AAAA,QACnB,SAAS,MAAM;AAAA,QACf,cAAc,MAAM;AAAA,QACpB,aAAa,MAAM;AAAA,QACnB,gBAAgB,MAAM;AAAA,QACtB,UAAU,CAAC,UAAU,WAAW,MAAM,SAAS,UAAU,MAAM;AAAA,QAC/D,YAAY,EAAE,SAAS,QAAQ,KAAK;AAAA,QACpC,eAAe,CAAC,UAAU,WACxB,MAAM,cAAc,UAAU,MAAM;AAAA;AAAA,IAExC;AAAA,IAED,CAAC,MAAM,kBACN,8BAAAH,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,MAAM,aACF,8BACA;AAAA,QACN;AAAA;AAAA,MAEC,MAAM;AAAA,IACT;AAAA,EAEJ;AAEJ;","names":["import_react","import_clsx","React","React","import_react","React","React","clsx","ReactSelect","CreatableSelect"]}
|
package/dist/select/index.mjs
CHANGED
@@ -225,6 +225,10 @@ var Select = ({
|
|
225
225
|
children
|
226
226
|
);
|
227
227
|
};
|
228
|
+
let phoneCodeStyles = "hawa-min-w-[65px] hawa-text-right hawa-w-[100px] hawa-p-0 hawa-rounded-r-none hawa-h-[40px]";
|
229
|
+
let selectContainerStyles = "hawa-rounded hawa-block hawa-w-full hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm";
|
230
|
+
let selectPlaceholderStyles = "hawa-text-muted-foreground hawa-cursor-pointer hawa-px-1";
|
231
|
+
let selectIndicatorContainerStyles = "hawa-cursor-pointer hawa-text-muted-foreground hawa-absolute hawa-end-0 hawa-top-[50%] hawa-bottom-[50%] ";
|
228
232
|
return /* @__PURE__ */ React4.createElement(
|
229
233
|
"div",
|
230
234
|
{
|
@@ -246,26 +250,22 @@ var Select = ({
|
|
246
250
|
props.controlClassNames
|
247
251
|
),
|
248
252
|
container: () => cn(
|
249
|
-
|
250
|
-
props.phoneCode &&
|
251
|
-
"hawa-block hawa-w-full hawa-rounded hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm",
|
253
|
+
selectContainerStyles,
|
254
|
+
props.phoneCode && phoneCodeStyles,
|
252
255
|
props.disabled ? "hawa-cursor-not-allowed" : "hawa-cursor-pointer",
|
253
256
|
props.isMulti && "hawa-ps-0 "
|
254
257
|
),
|
255
|
-
placeholder: () =>
|
258
|
+
placeholder: () => selectPlaceholderStyles,
|
256
259
|
valueContainer: () => "hawa-text-foreground hawa-px-1 ",
|
257
260
|
singleValue: () => "hawa-text-foreground",
|
258
261
|
indicatorsContainer: () => cn(
|
259
|
-
|
262
|
+
selectIndicatorContainerStyles,
|
260
263
|
props.hideIndicator ? "hawa-invisible" : "hawa-px-1"
|
261
264
|
)
|
262
265
|
},
|
263
266
|
unstyled: true,
|
264
|
-
|
265
|
-
|
266
|
-
Menu,
|
267
|
-
IndicatorsContainer: () => null
|
268
|
-
} : {
|
267
|
+
autoFocus: false,
|
268
|
+
components: props.hideIndicator ? { Option, Menu, IndicatorsContainer: () => null } : {
|
269
269
|
Option,
|
270
270
|
Menu,
|
271
271
|
// Control: (e) => (
|
@@ -287,10 +287,7 @@ var Select = ({
|
|
287
287
|
MultiValueContainer: (e) => /* @__PURE__ */ React4.createElement(
|
288
288
|
"div",
|
289
289
|
{
|
290
|
-
className:
|
291
|
-
// e.className,
|
292
|
-
"hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row"
|
293
|
-
),
|
290
|
+
className: "hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row",
|
294
291
|
...e
|
295
292
|
}
|
296
293
|
)
|