@sikka/hawa 0.30.1-next → 0.30.3-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/Label-9FHRF7Ex.d.mts +14 -0
- package/dist/Label-9FHRF7Ex.d.ts +14 -0
- package/dist/blocks/auth/index.js +29 -3
- package/dist/blocks/auth/index.mjs +2 -2
- package/dist/blocks/index.js +31 -5
- package/dist/blocks/index.mjs +2 -2
- package/dist/blocks/misc/index.js +28 -2
- package/dist/blocks/misc/index.mjs +1 -1
- package/dist/{chunk-KZCOE6V3.mjs → chunk-E6VRANQ3.mjs} +28 -2
- package/dist/{chunk-Q754X27Z.mjs → chunk-N4O2A727.mjs} +30 -4
- package/dist/dataTable/index.js +28 -2
- package/dist/dataTable/index.js.map +1 -1
- package/dist/dataTable/index.mjs +28 -2
- package/dist/dataTable/index.mjs.map +1 -1
- package/dist/elements/index.d.mts +7 -2
- package/dist/elements/index.d.ts +7 -2
- package/dist/elements/index.js +35 -24
- package/dist/elements/index.mjs +6 -21
- package/dist/index.css +0 -10
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +36 -25
- package/dist/index.mjs +36 -25
- package/dist/input/index.d.mts +2 -0
- package/dist/input/index.d.ts +2 -0
- package/dist/input/index.js +28 -2
- package/dist/input/index.js.map +1 -1
- package/dist/input/index.mjs +28 -2
- package/dist/input/index.mjs.map +1 -1
- package/dist/passwordInput/index.js +28 -2
- package/dist/passwordInput/index.js.map +1 -1
- package/dist/passwordInput/index.mjs +28 -2
- package/dist/passwordInput/index.mjs.map +1 -1
- package/dist/progress/index.d.mts +5 -1
- package/dist/progress/index.d.ts +5 -1
- package/dist/progress/index.js +120 -4
- package/dist/progress/index.js.map +1 -1
- package/dist/progress/index.mjs +120 -4
- package/dist/progress/index.mjs.map +1 -1
- package/dist/progressCircle/index.d.mts +1 -1
- package/dist/progressCircle/index.d.ts +1 -1
- package/dist/progressCircle/index.js +5 -20
- package/dist/progressCircle/index.js.map +1 -1
- package/dist/progressCircle/index.mjs +5 -20
- package/dist/progressCircle/index.mjs.map +1 -1
- package/dist/radio/index.d.mts +1 -12
- package/dist/radio/index.d.ts +1 -12
- package/package.json +1 -1
package/dist/progress/index.js
CHANGED
@@ -36,7 +36,7 @@ __export(progress_exports, {
|
|
36
36
|
module.exports = __toCommonJS(progress_exports);
|
37
37
|
|
38
38
|
// elements/progress/Progress.tsx
|
39
|
-
var
|
39
|
+
var React3 = __toESM(require("react"));
|
40
40
|
var ProgressPrimitive = __toESM(require("@radix-ui/react-progress"));
|
41
41
|
|
42
42
|
// util/index.ts
|
@@ -46,8 +46,124 @@ function cn(...inputs) {
|
|
46
46
|
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
47
47
|
}
|
48
48
|
|
49
|
+
// elements/label/Label.tsx
|
50
|
+
var React2 = __toESM(require("react"));
|
51
|
+
|
52
|
+
// elements/tooltip/Tooltip.tsx
|
53
|
+
var import_react = __toESM(require("react"));
|
54
|
+
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
|
55
|
+
var TooltipContent = import_react.default.forwardRef(({ className, sideOffset = 4, size = "default", ...props }, ref) => /* @__PURE__ */ import_react.default.createElement(
|
56
|
+
TooltipPrimitive.Content,
|
57
|
+
{
|
58
|
+
ref,
|
59
|
+
sideOffset,
|
60
|
+
className: cn(
|
61
|
+
"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",
|
62
|
+
{
|
63
|
+
"hawa-text-xs": size === "small",
|
64
|
+
"hawa-text-xl": size === "large"
|
65
|
+
},
|
66
|
+
className
|
67
|
+
),
|
68
|
+
...props
|
69
|
+
}
|
70
|
+
));
|
71
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
72
|
+
var TooltipArrow = import_react.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ import_react.default.createElement(TooltipPrimitive.Arrow, { ref, className: cn(className), ...props }));
|
73
|
+
TooltipArrow.displayName = TooltipPrimitive.Arrow.displayName;
|
74
|
+
var Tooltip = ({
|
75
|
+
side,
|
76
|
+
size,
|
77
|
+
open,
|
78
|
+
content,
|
79
|
+
children,
|
80
|
+
disabled,
|
81
|
+
defaultOpen,
|
82
|
+
onOpenChange,
|
83
|
+
triggerProps,
|
84
|
+
contentProps,
|
85
|
+
providerProps,
|
86
|
+
delayDuration = 300,
|
87
|
+
...props
|
88
|
+
}) => {
|
89
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
90
|
+
TooltipPrimitive.TooltipProvider,
|
91
|
+
{
|
92
|
+
delayDuration,
|
93
|
+
...providerProps
|
94
|
+
},
|
95
|
+
/* @__PURE__ */ import_react.default.createElement(
|
96
|
+
TooltipPrimitive.Root,
|
97
|
+
{
|
98
|
+
open: !disabled && open,
|
99
|
+
defaultOpen,
|
100
|
+
onOpenChange,
|
101
|
+
...props
|
102
|
+
},
|
103
|
+
/* @__PURE__ */ import_react.default.createElement(TooltipPrimitive.Trigger, { ...triggerProps }, children),
|
104
|
+
/* @__PURE__ */ import_react.default.createElement(
|
105
|
+
TooltipContent,
|
106
|
+
{
|
107
|
+
size,
|
108
|
+
side,
|
109
|
+
align: "center",
|
110
|
+
...contentProps,
|
111
|
+
style: {
|
112
|
+
...contentProps == null ? void 0 : contentProps.style,
|
113
|
+
maxWidth: "var(--radix-tooltip-content-available-width)",
|
114
|
+
maxHeight: "var(--radix-tooltip-content-available-height)"
|
115
|
+
}
|
116
|
+
},
|
117
|
+
content
|
118
|
+
)
|
119
|
+
)
|
120
|
+
);
|
121
|
+
};
|
122
|
+
|
123
|
+
// elements/label/Label.tsx
|
124
|
+
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(
|
125
|
+
"label",
|
126
|
+
{
|
127
|
+
ref,
|
128
|
+
className: cn(
|
129
|
+
"hawa-text-sm hawa-font-medium hawa-leading-none peer-disabled:hawa-cursor-not-allowed peer-disabled:hawa-opacity-70",
|
130
|
+
className
|
131
|
+
),
|
132
|
+
...props
|
133
|
+
},
|
134
|
+
children,
|
135
|
+
required && /* @__PURE__ */ React2.createElement("span", { className: "hawa-mx-0.5 hawa-text-red-500" }, "*")
|
136
|
+
), hint && /* @__PURE__ */ React2.createElement(
|
137
|
+
Tooltip,
|
138
|
+
{
|
139
|
+
content: hint,
|
140
|
+
side: hintSide,
|
141
|
+
triggerProps: {
|
142
|
+
tabIndex: -1,
|
143
|
+
onClick: (event) => event.preventDefault()
|
144
|
+
}
|
145
|
+
},
|
146
|
+
/* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(
|
147
|
+
"svg",
|
148
|
+
{
|
149
|
+
xmlns: "http://www.w3.org/2000/svg",
|
150
|
+
className: "hawa-h-[14px] hawa-w-[14px] hawa-cursor-help",
|
151
|
+
viewBox: "0 0 24 24",
|
152
|
+
fill: "none",
|
153
|
+
stroke: "currentColor",
|
154
|
+
strokeWidth: "2",
|
155
|
+
strokeLinecap: "round",
|
156
|
+
strokeLinejoin: "round"
|
157
|
+
},
|
158
|
+
/* @__PURE__ */ React2.createElement("circle", { cx: "12", cy: "12", r: "10" }),
|
159
|
+
/* @__PURE__ */ React2.createElement("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }),
|
160
|
+
/* @__PURE__ */ React2.createElement("path", { d: "M12 17h.01" })
|
161
|
+
))
|
162
|
+
)));
|
163
|
+
Label.displayName = "Label";
|
164
|
+
|
49
165
|
// elements/progress/Progress.tsx
|
50
|
-
var Progress =
|
166
|
+
var Progress = React3.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-2" }, props.label && /* @__PURE__ */ React3.createElement(Label, { ...props.labelProps }, props.label), /* @__PURE__ */ React3.createElement(
|
51
167
|
ProgressPrimitive.Root,
|
52
168
|
{
|
53
169
|
ref,
|
@@ -57,14 +173,14 @@ var Progress = React.forwardRef(({ className, value, ...props }, ref) => /* @__P
|
|
57
173
|
),
|
58
174
|
...props
|
59
175
|
},
|
60
|
-
/* @__PURE__ */
|
176
|
+
/* @__PURE__ */ React3.createElement(
|
61
177
|
ProgressPrimitive.Indicator,
|
62
178
|
{
|
63
179
|
className: "hawa-h-full hawa-w-full hawa-flex-1 hawa-bg-primary hawa-transition-all",
|
64
180
|
style: { transform: `translateX(-${100 - (value || 0)}%)` }
|
65
181
|
}
|
66
182
|
)
|
67
|
-
));
|
183
|
+
)));
|
68
184
|
Progress.displayName = ProgressPrimitive.Root.displayName;
|
69
185
|
// Annotate the CommonJS export names for ESM import in node:
|
70
186
|
0 && (module.exports = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/progress/index.ts","../../elements/progress/Progress.tsx","../../util/index.ts"],"sourcesContent":["export * from \"./Progress\";\n","import * as React from \"react\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\n\nimport { cn } from \"@util/index\";\n\nconst Progress = React.forwardRef<\n React.ElementRef<typeof ProgressPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>\n>(({ className, value, ...props }, ref) => (\n <ProgressPrimitive.Root\n ref={ref}\n className={cn(\n \"hawa-relative hawa-h-4 hawa-w-full hawa-overflow-hidden hawa-rounded hawa-bg-secondary\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n className=\"hawa-h-full hawa-w-full hawa-flex-1 hawa-bg-primary hawa-transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n));\nProgress.displayName = ProgressPrimitive.Root.displayName;\n\nexport { Progress };\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;;;ACAA,YAAuB;AAEvB,wBAAmC;;;ACFnC,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADCA,IAAM,WAAiB,iBAGrB,CAAC,EAAE,WAAW,OAAO,GAAG,MAAM,GAAG,QACjC;AAAA,EAAmB;AAAA,EAAlB;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AAAA,EAEJ;AAAA,IAAmB;AAAA,IAAlB;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,WAAW,eAAe,OAAO,SAAS,EAAE,KAAK;AAAA;AAAA,EAC5D;AACF,CACD;AACD,SAAS,cAAgC,uBAAK;","names":[]}
|
1
|
+
{"version":3,"sources":["../../elements/progress/index.ts","../../elements/progress/Progress.tsx","../../util/index.ts","../../elements/label/Label.tsx","../../elements/tooltip/Tooltip.tsx"],"sourcesContent":["export * from \"./Progress\";\n","import * as React from \"react\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\nimport { cn } from \"@util/index\";\n\nimport { Label, LabelProps } from \"../label\";\n\nconst Progress = React.forwardRef<\n React.ElementRef<typeof ProgressPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> & {\n label?: string;\n labelProps?: LabelProps;\n }\n>(({ className, value, ...props }, ref) => (\n <div className=\"hawa-flex hawa-flex-col hawa-gap-2\">\n {props.label && <Label {...props.labelProps}>{props.label}</Label>}\n <ProgressPrimitive.Root\n ref={ref}\n className={cn(\n \"hawa-relative hawa-h-4 hawa-w-full hawa-overflow-hidden hawa-rounded hawa-bg-secondary\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n className=\"hawa-h-full hawa-w-full hawa-flex-1 hawa-bg-primary hawa-transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n </div>\n));\nProgress.displayName = ProgressPrimitive.Root.displayName;\n\nexport { Progress };\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;AAEvB,wBAAmC;;;ACFnC,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ACLA,IAAAC,SAAuB;;;ACAvB,mBAAkB;AAElB,uBAAkC;AAKlC,IAAM,iBAAiB,aAAAC,QAAM,WAK3B,CAAC,EAAE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F,CACF,CACD;AACD,SAAS,cAAgC,uBAAK;","names":["React","React","React"]}
|
package/dist/progress/index.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
3
|
// elements/progress/Progress.tsx
|
4
|
-
import * as
|
4
|
+
import * as React3 from "react";
|
5
5
|
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
6
6
|
|
7
7
|
// util/index.ts
|
@@ -11,8 +11,124 @@ function cn(...inputs) {
|
|
11
11
|
return twMerge(clsx(inputs));
|
12
12
|
}
|
13
13
|
|
14
|
+
// elements/label/Label.tsx
|
15
|
+
import * as React2 from "react";
|
16
|
+
|
17
|
+
// elements/tooltip/Tooltip.tsx
|
18
|
+
import React from "react";
|
19
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
20
|
+
var TooltipContent = React.forwardRef(({ className, sideOffset = 4, size = "default", ...props }, ref) => /* @__PURE__ */ React.createElement(
|
21
|
+
TooltipPrimitive.Content,
|
22
|
+
{
|
23
|
+
ref,
|
24
|
+
sideOffset,
|
25
|
+
className: cn(
|
26
|
+
"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",
|
27
|
+
{
|
28
|
+
"hawa-text-xs": size === "small",
|
29
|
+
"hawa-text-xl": size === "large"
|
30
|
+
},
|
31
|
+
className
|
32
|
+
),
|
33
|
+
...props
|
34
|
+
}
|
35
|
+
));
|
36
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
37
|
+
var TooltipArrow = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(TooltipPrimitive.Arrow, { ref, className: cn(className), ...props }));
|
38
|
+
TooltipArrow.displayName = TooltipPrimitive.Arrow.displayName;
|
39
|
+
var Tooltip = ({
|
40
|
+
side,
|
41
|
+
size,
|
42
|
+
open,
|
43
|
+
content,
|
44
|
+
children,
|
45
|
+
disabled,
|
46
|
+
defaultOpen,
|
47
|
+
onOpenChange,
|
48
|
+
triggerProps,
|
49
|
+
contentProps,
|
50
|
+
providerProps,
|
51
|
+
delayDuration = 300,
|
52
|
+
...props
|
53
|
+
}) => {
|
54
|
+
return /* @__PURE__ */ React.createElement(
|
55
|
+
TooltipPrimitive.TooltipProvider,
|
56
|
+
{
|
57
|
+
delayDuration,
|
58
|
+
...providerProps
|
59
|
+
},
|
60
|
+
/* @__PURE__ */ React.createElement(
|
61
|
+
TooltipPrimitive.Root,
|
62
|
+
{
|
63
|
+
open: !disabled && open,
|
64
|
+
defaultOpen,
|
65
|
+
onOpenChange,
|
66
|
+
...props
|
67
|
+
},
|
68
|
+
/* @__PURE__ */ React.createElement(TooltipPrimitive.Trigger, { ...triggerProps }, children),
|
69
|
+
/* @__PURE__ */ React.createElement(
|
70
|
+
TooltipContent,
|
71
|
+
{
|
72
|
+
size,
|
73
|
+
side,
|
74
|
+
align: "center",
|
75
|
+
...contentProps,
|
76
|
+
style: {
|
77
|
+
...contentProps == null ? void 0 : contentProps.style,
|
78
|
+
maxWidth: "var(--radix-tooltip-content-available-width)",
|
79
|
+
maxHeight: "var(--radix-tooltip-content-available-height)"
|
80
|
+
}
|
81
|
+
},
|
82
|
+
content
|
83
|
+
)
|
84
|
+
)
|
85
|
+
);
|
86
|
+
};
|
87
|
+
|
88
|
+
// elements/label/Label.tsx
|
89
|
+
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(
|
90
|
+
"label",
|
91
|
+
{
|
92
|
+
ref,
|
93
|
+
className: cn(
|
94
|
+
"hawa-text-sm hawa-font-medium hawa-leading-none peer-disabled:hawa-cursor-not-allowed peer-disabled:hawa-opacity-70",
|
95
|
+
className
|
96
|
+
),
|
97
|
+
...props
|
98
|
+
},
|
99
|
+
children,
|
100
|
+
required && /* @__PURE__ */ React2.createElement("span", { className: "hawa-mx-0.5 hawa-text-red-500" }, "*")
|
101
|
+
), hint && /* @__PURE__ */ React2.createElement(
|
102
|
+
Tooltip,
|
103
|
+
{
|
104
|
+
content: hint,
|
105
|
+
side: hintSide,
|
106
|
+
triggerProps: {
|
107
|
+
tabIndex: -1,
|
108
|
+
onClick: (event) => event.preventDefault()
|
109
|
+
}
|
110
|
+
},
|
111
|
+
/* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(
|
112
|
+
"svg",
|
113
|
+
{
|
114
|
+
xmlns: "http://www.w3.org/2000/svg",
|
115
|
+
className: "hawa-h-[14px] hawa-w-[14px] hawa-cursor-help",
|
116
|
+
viewBox: "0 0 24 24",
|
117
|
+
fill: "none",
|
118
|
+
stroke: "currentColor",
|
119
|
+
strokeWidth: "2",
|
120
|
+
strokeLinecap: "round",
|
121
|
+
strokeLinejoin: "round"
|
122
|
+
},
|
123
|
+
/* @__PURE__ */ React2.createElement("circle", { cx: "12", cy: "12", r: "10" }),
|
124
|
+
/* @__PURE__ */ React2.createElement("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }),
|
125
|
+
/* @__PURE__ */ React2.createElement("path", { d: "M12 17h.01" })
|
126
|
+
))
|
127
|
+
)));
|
128
|
+
Label.displayName = "Label";
|
129
|
+
|
14
130
|
// elements/progress/Progress.tsx
|
15
|
-
var Progress =
|
131
|
+
var Progress = React3.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-2" }, props.label && /* @__PURE__ */ React3.createElement(Label, { ...props.labelProps }, props.label), /* @__PURE__ */ React3.createElement(
|
16
132
|
ProgressPrimitive.Root,
|
17
133
|
{
|
18
134
|
ref,
|
@@ -22,14 +138,14 @@ var Progress = React.forwardRef(({ className, value, ...props }, ref) => /* @__P
|
|
22
138
|
),
|
23
139
|
...props
|
24
140
|
},
|
25
|
-
/* @__PURE__ */
|
141
|
+
/* @__PURE__ */ React3.createElement(
|
26
142
|
ProgressPrimitive.Indicator,
|
27
143
|
{
|
28
144
|
className: "hawa-h-full hawa-w-full hawa-flex-1 hawa-bg-primary hawa-transition-all",
|
29
145
|
style: { transform: `translateX(-${100 - (value || 0)}%)` }
|
30
146
|
}
|
31
147
|
)
|
32
|
-
));
|
148
|
+
)));
|
33
149
|
Progress.displayName = ProgressPrimitive.Root.displayName;
|
34
150
|
export {
|
35
151
|
Progress
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/progress/Progress.tsx","../../util/index.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\n\nimport { cn } from \"@util/index\";\n\nconst Progress = React.forwardRef<\n React.ElementRef<typeof ProgressPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>\n>(({ className, value, ...props }, ref) => (\n <ProgressPrimitive.Root\n ref={ref}\n className={cn(\n \"hawa-relative hawa-h-4 hawa-w-full hawa-overflow-hidden hawa-rounded hawa-bg-secondary\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n className=\"hawa-h-full hawa-w-full hawa-flex-1 hawa-bg-primary hawa-transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n));\nProgress.displayName = ProgressPrimitive.Root.displayName;\n\nexport { Progress };\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,uBAAuB;;;ACFnC,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADCA,IAAM,WAAiB,iBAGrB,CAAC,EAAE,WAAW,OAAO,GAAG,MAAM,GAAG,QACjC;AAAA,EAAmB;AAAA,EAAlB;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AAAA,EAEJ;AAAA,IAAmB;AAAA,IAAlB;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,WAAW,eAAe,OAAO,SAAS,EAAE,KAAK;AAAA;AAAA,EAC5D;AACF,CACD;AACD,SAAS,cAAgC,uBAAK;","names":[]}
|
1
|
+
{"version":3,"sources":["../../elements/progress/Progress.tsx","../../util/index.ts","../../elements/label/Label.tsx","../../elements/tooltip/Tooltip.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\nimport { cn } from \"@util/index\";\n\nimport { Label, LabelProps } from \"../label\";\n\nconst Progress = React.forwardRef<\n React.ElementRef<typeof ProgressPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> & {\n label?: string;\n labelProps?: LabelProps;\n }\n>(({ className, value, ...props }, ref) => (\n <div className=\"hawa-flex hawa-flex-col hawa-gap-2\">\n {props.label && <Label {...props.labelProps}>{props.label}</Label>}\n <ProgressPrimitive.Root\n ref={ref}\n className={cn(\n \"hawa-relative hawa-h-4 hawa-w-full hawa-overflow-hidden hawa-rounded hawa-bg-secondary\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n className=\"hawa-h-full hawa-w-full hawa-flex-1 hawa-bg-primary hawa-transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n </div>\n));\nProgress.displayName = ProgressPrimitive.Root.displayName;\n\nexport { Progress };\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"],"mappings":";;;AAAA,YAAYA,YAAW;AAEvB,YAAY,uBAAuB;;;ACFnC,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ACLA,YAAYC,YAAW;;;ACAvB,OAAO,WAAW;AAElB,YAAY,sBAAsB;AAKlC,IAAM,iBAAiB,MAAM,WAK3B,CAAC,EAAE,WAAW,aAAa,GAAG,OAAO,WAAW,GAAG,MAAM,GAAG,QAC5D;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,MAAM,WAGzB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B,oCAAkB,wBAAjB,EAAuB,KAAU,WAAW,GAAG,SAAS,GAAI,GAAG,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AA,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;;;AFrDpB,IAAM,WAAiB,kBAMrB,CAAC,EAAE,WAAW,OAAO,GAAG,MAAM,GAAG,QACjC,qCAAC,SAAI,WAAU,wCACZ,MAAM,SAAS,qCAAC,SAAO,GAAG,MAAM,cAAa,MAAM,KAAM,GAC1D;AAAA,EAAmB;AAAA,EAAlB;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AAAA,EAEJ;AAAA,IAAmB;AAAA,IAAlB;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,WAAW,eAAe,OAAO,SAAS,EAAE,KAAK;AAAA;AAAA,EAC5D;AACF,CACF,CACD;AACD,SAAS,cAAgC,uBAAK;","names":["React","React"]}
|
@@ -47,26 +47,11 @@ function cn(...inputs) {
|
|
47
47
|
|
48
48
|
// elements/progressCircle/ProgressCircle.tsx
|
49
49
|
var size2config = {
|
50
|
-
xs: {
|
51
|
-
|
52
|
-
|
53
|
-
},
|
54
|
-
|
55
|
-
radius: 19,
|
56
|
-
strokeWidth: 4
|
57
|
-
},
|
58
|
-
md: {
|
59
|
-
radius: 32,
|
60
|
-
strokeWidth: 6
|
61
|
-
},
|
62
|
-
lg: {
|
63
|
-
radius: 52,
|
64
|
-
strokeWidth: 8
|
65
|
-
},
|
66
|
-
xl: {
|
67
|
-
radius: 80,
|
68
|
-
strokeWidth: 10
|
69
|
-
}
|
50
|
+
xs: { radius: 15, strokeWidth: 3 },
|
51
|
+
sm: { radius: 19, strokeWidth: 4 },
|
52
|
+
md: { radius: 32, strokeWidth: 6 },
|
53
|
+
lg: { radius: 52, strokeWidth: 8 },
|
54
|
+
xl: { radius: 80, strokeWidth: 10 }
|
70
55
|
};
|
71
56
|
function getLimitedValue(input) {
|
72
57
|
if (input === void 0) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/progressCircle/index.ts","../../elements/progressCircle/ProgressCircle.tsx","../../util/index.ts"],"sourcesContent":["export * from \"./ProgressCircle\";\n","import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ntype GaugeType = {\n value: number; // Value between 0 and 100\n maxValue: number; // Value between 0 and 100\n design?: \"full-circle\" | \"half-circle\";\n};\n\ntype Size = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\ninterface ProgressCircleProps extends React.HTMLAttributes<HTMLDivElement> {\n value?: number;\n size?: Size;\n color?: any;\n showAnimation?: boolean;\n tooltip?: string;\n radius?: number;\n strokeWidth?: number;\n children?: React.ReactNode;\n}\n\nconst size2config: Record<Size, { strokeWidth: number; radius: number }> = {\n xs: {\n radius: 15,\n strokeWidth: 3\n },\n sm: {\n radius: 19,\n strokeWidth: 4\n },\n md: {\n radius: 32,\n strokeWidth: 6\n },\n lg: {\n radius: 52,\n strokeWidth: 8\n },\n xl: {\n radius: 80,\n strokeWidth: 10\n }\n};\n\nfunction getLimitedValue(input: number | undefined) {\n if (input === undefined) {\n return 0;\n } else if (input > 100) {\n return 100;\n } else {\n return input;\n }\n}\nexport const ProgressCircle = React.forwardRef<\n HTMLDivElement,\n ProgressCircleProps\n>((props, ref) => {\n const {\n value: inputValue,\n size = \"md\",\n className,\n showAnimation = true,\n color,\n tooltip,\n radius: inputRadius,\n strokeWidth: inputStrokeWidth,\n children,\n ...other\n } = props;\n\n const value = getLimitedValue(inputValue);\n const radius = inputRadius ?? size2config[size].radius;\n const strokeWidth = inputStrokeWidth ?? size2config[size].strokeWidth;\n const normalizedRadius = radius - strokeWidth / 2;\n const circumference = normalizedRadius * 2 * Math.PI;\n const strokeDashoffset = (value / 100) * circumference;\n const offset = circumference - strokeDashoffset;\n\n return (\n <>\n <div\n ref={ref}\n className={cn(\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n className\n )}\n >\n <svg\n width={radius * 2}\n height={radius * 2}\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\n className=\"hawa-rotate-180 hawa-transform\"\n >\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \" hawa-stroke-primary/20\"\n )}\n />\n {value > 0 ? (\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n strokeDasharray={circumference + \" \" + circumference}\n strokeDashoffset={offset}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \"hawa-stroke-primary\",\n showAnimation\n ? \"hawa-transition-all hawa-duration-300 hawa-ease-in-out\"\n : \"\"\n )}\n />\n ) : null}\n </svg>\n <div className={cn(\"hawa-absolute hawa-flex\")}>{children}</div>\n </div>\n </>\n );\n});\n\nProgressCircle.displayName = \"ProgressCircle\";\n\n// export const Gauge: React.FC<GaugeType> = ({\n// value = 0,\n// maxValue = 100,\n// children,\n// design = \"full-circle\",\n// }) => {\n// // const radius = 16;\n// // const fullCircumference = 2 * Math.PI * radius; // Full circle circumference\n// // const halfCircumference = Math.PI * radius; // Half circle circumference, updated\n// // const percentage = value / maxValue;\n// // const fullOffset = fullCircumference - percentage * fullCircumference;\n// // const halfOffset = halfCircumference - percentage * halfCircumference; // Updated offset for half-circle\n// // const strokeDasharray = percentage * halfCircumference;\n// // const strokeDashoffset = halfCircumference * (1 - percentage);\n\n// // const FullCircle = () => (\n// // <svg className={\"hawa-h-36 hawa-w-36\"} viewBox=\"0 0 36 36\">\n// // <circle\n// // cx=\"18\"\n// // cy=\"18\"\n// // r={radius}\n// // strokeWidth=\"2\"\n// // stroke=\"lightgray\"\n// // fill=\"none\"\n// // />\n// // <circle\n// // cx=\"18\"\n// // cy=\"18\"\n// // r={radius}\n// // strokeWidth=\"2\"\n// // stroke=\"#009\"\n// // fill=\"none\"\n// // strokeLinecap=\"round\"\n// // strokeDasharray={fullCircumference}\n// // strokeDashoffset={fullOffset}\n// // style={{\n// // transition: \"stroke-dashoffset 0.35s\",\n// // transform: \"rotate(180deg)\",\n// // transformOrigin: \"50% 50%\",\n// // }}\n// // />\n// // <text\n// // x=\"50%\"\n// // y=\"50%\"\n// // alignmentBaseline=\"middle\"\n// // textAnchor=\"middle\"\n// // fontSize=\"10\"\n// // fill=\"#000\"\n// // >\n// // {value}\n// // </text>\n// // </svg>\n// // );\n// // const HalfCircle = () => (\n// // <svg className={\"hawa-h-36 hawa-w-36\"} viewBox=\"0 0 36 36\">\n// // <path\n// // d=\"M 4,18 A 14,14 0 0,1 32,18\"\n// // strokeWidth=\"4\"\n// // stroke=\"lightgray\"\n// // fill=\"none\"\n// // />\n// // <path\n// // d=\"M 4,18 A 14,14 0 0,1 32,18\"\n// // strokeWidth=\"4\"\n// // stroke=\"#00f\"\n// // fill=\"none\"\n// // // strokeDasharray={`${strokeDasharray}`}\n// // // strokeDashoffset={`${strokeDashoffset}`}\n// // strokeDasharray={50}\n// // strokeDashoffset={50}\n// // style={{\n// // transition: \"stroke-dashoffset 0.35s\",\n// // transformOrigin: \"50% 50%\",\n// // }}\n// // />\n// // <text\n// // x=\"50%\"\n// // y=\"45%\"\n// // alignmentBaseline=\"middle\"\n// // textAnchor=\"middle\"\n// // fontSize=\"8\"\n// // fill=\"#000\"\n// // >\n// // {value}\n// // </text>\n// // </svg>\n// // );\n// return (\n// <div className=\"hawa-flex hawa-flex-row hawa-gap-x-3\">\n// <div aria-label=\"Gauge\" role=\"status\">\n// {/* {design === \"full-circle\" ? <FullCircle /> : <HalfCircle />} */}\n// <AlmostFullCircle value={value} size=\"lg\">\n// {children}\n// </AlmostFullCircle>\n// </div>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;;;ACAlB,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADkBA,IAAM,cAAqE;AAAA,EACzE,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AACF;AAEA,SAAS,gBAAgB,OAA2B;AAClD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT,WAAW,QAAQ,KAAK;AACtB,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF;AACO,IAAM,iBAAiB,aAAAA,QAAM,WAGlC,CAAC,OAAO,QAAQ;AAChB,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,aAAa;AAAA,IACb;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,QAAQ,gBAAgB,UAAU;AACxC,QAAM,SAAS,oCAAe,YAAY,IAAI,EAAE;AAChD,QAAM,cAAc,8CAAoB,YAAY,IAAI,EAAE;AAC1D,QAAM,mBAAmB,SAAS,cAAc;AAChD,QAAM,gBAAgB,mBAAmB,IAAI,KAAK;AAClD,QAAM,mBAAoB,QAAQ,MAAO;AACzC,QAAM,SAAS,gBAAgB;AAE/B,SACE,6BAAAA,QAAA,2BAAAA,QAAA,gBACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA;AAAA,IAEA,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,SAAS;AAAA,QAChB,QAAQ,SAAS;AAAA,QACjB,SAAS,OAAO,SAAS,CAAC,IAAI,SAAS,CAAC;AAAA,QACxC,WAAU;AAAA;AAAA,MAEV,6BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UACC,GAAG;AAAA,UACH,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ;AAAA,UACA,MAAK;AAAA,UACL,QAAO;AAAA,UACP,eAAc;AAAA,UACd,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA;AAAA,MACF;AAAA,MACC,QAAQ,IACP,6BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UACC,GAAG;AAAA,UACH,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ;AAAA,UACA,iBAAiB,gBAAgB,MAAM;AAAA,UACvC,kBAAkB;AAAA,UAClB,MAAK;AAAA,UACL,QAAO;AAAA,UACP,eAAc;AAAA,UACd,WAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA,gBACI,2DACA;AAAA,UACN;AAAA;AAAA,MACF,IACE;AAAA,IACN;AAAA,IACA,6BAAAA,QAAA,cAAC,SAAI,WAAW,GAAG,yBAAyB,KAAI,QAAS;AAAA,EAC3D,CACF;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["React"]}
|
1
|
+
{"version":3,"sources":["../../elements/progressCircle/index.ts","../../elements/progressCircle/ProgressCircle.tsx","../../util/index.ts"],"sourcesContent":["export * from \"./ProgressCircle\";\n","import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ntype Size = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\ninterface ProgressCircleProps extends React.HTMLAttributes<HTMLDivElement> {\n value: number;\n size?: Size;\n color?: any;\n showAnimation?: boolean;\n tooltip?: string;\n radius?: number;\n strokeWidth?: number;\n children?: React.ReactNode;\n}\n\nconst size2config: Record<Size, { strokeWidth: number; radius: number }> = {\n xs: { radius: 15, strokeWidth: 3 },\n sm: { radius: 19, strokeWidth: 4 },\n md: { radius: 32, strokeWidth: 6 },\n lg: { radius: 52, strokeWidth: 8 },\n xl: { radius: 80, strokeWidth: 10 }\n};\n\nfunction getLimitedValue(input: number | undefined) {\n if (input === undefined) {\n return 0;\n } else if (input > 100) {\n return 100;\n } else {\n return input;\n }\n}\nexport const ProgressCircle = React.forwardRef<\n HTMLDivElement,\n ProgressCircleProps\n>((props, ref) => {\n const {\n value: inputValue,\n size = \"md\",\n className,\n showAnimation = true,\n color,\n tooltip,\n radius: inputRadius,\n strokeWidth: inputStrokeWidth,\n children,\n ...other\n } = props;\n\n const value = getLimitedValue(inputValue);\n const radius = inputRadius ?? size2config[size].radius;\n const strokeWidth = inputStrokeWidth ?? size2config[size].strokeWidth;\n const normalizedRadius = radius - strokeWidth / 2;\n const circumference = normalizedRadius * 2 * Math.PI;\n const strokeDashoffset = (value / 100) * circumference;\n const offset = circumference - strokeDashoffset;\n\n return (\n <>\n <div\n ref={ref}\n className={cn(\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n className\n )}\n >\n <svg\n width={radius * 2}\n height={radius * 2}\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\n className=\"hawa-rotate-180 hawa-transform\"\n >\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \" hawa-stroke-primary/20\"\n )}\n />\n {value > 0 ? (\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n strokeDasharray={circumference + \" \" + circumference}\n strokeDashoffset={offset}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \"hawa-stroke-primary\",\n showAnimation\n ? \"hawa-transition-all hawa-duration-300 hawa-ease-in-out\"\n : \"\"\n )}\n />\n ) : null}\n </svg>\n <div className={cn(\"hawa-absolute hawa-flex\")}>{children}</div>\n </div>\n </>\n );\n});\n\nProgressCircle.displayName = \"ProgressCircle\";\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;;;ACAA,mBAAkB;;;ACAlB,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADYA,IAAM,cAAqE;AAAA,EACzE,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,GAAG;AACpC;AAEA,SAAS,gBAAgB,OAA2B;AAClD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT,WAAW,QAAQ,KAAK;AACtB,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF;AACO,IAAM,iBAAiB,aAAAA,QAAM,WAGlC,CAAC,OAAO,QAAQ;AAChB,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,aAAa;AAAA,IACb;AAAA,I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AC3D,CACF;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["React"]}
|
@@ -12,26 +12,11 @@ function cn(...inputs) {
|
|
12
12
|
|
13
13
|
// elements/progressCircle/ProgressCircle.tsx
|
14
14
|
var size2config = {
|
15
|
-
xs: {
|
16
|
-
|
17
|
-
|
18
|
-
},
|
19
|
-
|
20
|
-
radius: 19,
|
21
|
-
strokeWidth: 4
|
22
|
-
},
|
23
|
-
md: {
|
24
|
-
radius: 32,
|
25
|
-
strokeWidth: 6
|
26
|
-
},
|
27
|
-
lg: {
|
28
|
-
radius: 52,
|
29
|
-
strokeWidth: 8
|
30
|
-
},
|
31
|
-
xl: {
|
32
|
-
radius: 80,
|
33
|
-
strokeWidth: 10
|
34
|
-
}
|
15
|
+
xs: { radius: 15, strokeWidth: 3 },
|
16
|
+
sm: { radius: 19, strokeWidth: 4 },
|
17
|
+
md: { radius: 32, strokeWidth: 6 },
|
18
|
+
lg: { radius: 52, strokeWidth: 8 },
|
19
|
+
xl: { radius: 80, strokeWidth: 10 }
|
35
20
|
};
|
36
21
|
function getLimitedValue(input) {
|
37
22
|
if (input === void 0) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/progressCircle/ProgressCircle.tsx","../../util/index.ts"],"sourcesContent":["import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ntype GaugeType = {\n value: number; // Value between 0 and 100\n maxValue: number; // Value between 0 and 100\n design?: \"full-circle\" | \"half-circle\";\n};\n\ntype Size = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\ninterface ProgressCircleProps extends React.HTMLAttributes<HTMLDivElement> {\n value?: number;\n size?: Size;\n color?: any;\n showAnimation?: boolean;\n tooltip?: string;\n radius?: number;\n strokeWidth?: number;\n children?: React.ReactNode;\n}\n\nconst size2config: Record<Size, { strokeWidth: number; radius: number }> = {\n xs: {\n radius: 15,\n strokeWidth: 3\n },\n sm: {\n radius: 19,\n strokeWidth: 4\n },\n md: {\n radius: 32,\n strokeWidth: 6\n },\n lg: {\n radius: 52,\n strokeWidth: 8\n },\n xl: {\n radius: 80,\n strokeWidth: 10\n }\n};\n\nfunction getLimitedValue(input: number | undefined) {\n if (input === undefined) {\n return 0;\n } else if (input > 100) {\n return 100;\n } else {\n return input;\n }\n}\nexport const ProgressCircle = React.forwardRef<\n HTMLDivElement,\n ProgressCircleProps\n>((props, ref) => {\n const {\n value: inputValue,\n size = \"md\",\n className,\n showAnimation = true,\n color,\n tooltip,\n radius: inputRadius,\n strokeWidth: inputStrokeWidth,\n children,\n ...other\n } = props;\n\n const value = getLimitedValue(inputValue);\n const radius = inputRadius ?? size2config[size].radius;\n const strokeWidth = inputStrokeWidth ?? size2config[size].strokeWidth;\n const normalizedRadius = radius - strokeWidth / 2;\n const circumference = normalizedRadius * 2 * Math.PI;\n const strokeDashoffset = (value / 100) * circumference;\n const offset = circumference - strokeDashoffset;\n\n return (\n <>\n <div\n ref={ref}\n className={cn(\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n className\n )}\n >\n <svg\n width={radius * 2}\n height={radius * 2}\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\n className=\"hawa-rotate-180 hawa-transform\"\n >\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \" hawa-stroke-primary/20\"\n )}\n />\n {value > 0 ? (\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n strokeDasharray={circumference + \" \" + circumference}\n strokeDashoffset={offset}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \"hawa-stroke-primary\",\n showAnimation\n ? \"hawa-transition-all hawa-duration-300 hawa-ease-in-out\"\n : \"\"\n )}\n />\n ) : null}\n </svg>\n <div className={cn(\"hawa-absolute hawa-flex\")}>{children}</div>\n </div>\n </>\n );\n});\n\nProgressCircle.displayName = \"ProgressCircle\";\n\n// export const Gauge: React.FC<GaugeType> = ({\n// value = 0,\n// maxValue = 100,\n// children,\n// design = \"full-circle\",\n// }) => {\n// // const radius = 16;\n// // const fullCircumference = 2 * Math.PI * radius; // Full circle circumference\n// // const halfCircumference = Math.PI * radius; // Half circle circumference, updated\n// // const percentage = value / maxValue;\n// // const fullOffset = fullCircumference - percentage * fullCircumference;\n// // const halfOffset = halfCircumference - percentage * halfCircumference; // Updated offset for half-circle\n// // const strokeDasharray = percentage * halfCircumference;\n// // const strokeDashoffset = halfCircumference * (1 - percentage);\n\n// // const FullCircle = () => (\n// // <svg className={\"hawa-h-36 hawa-w-36\"} viewBox=\"0 0 36 36\">\n// // <circle\n// // cx=\"18\"\n// // cy=\"18\"\n// // r={radius}\n// // strokeWidth=\"2\"\n// // stroke=\"lightgray\"\n// // fill=\"none\"\n// // />\n// // <circle\n// // cx=\"18\"\n// // cy=\"18\"\n// // r={radius}\n// // strokeWidth=\"2\"\n// // stroke=\"#009\"\n// // fill=\"none\"\n// // strokeLinecap=\"round\"\n// // strokeDasharray={fullCircumference}\n// // strokeDashoffset={fullOffset}\n// // style={{\n// // transition: \"stroke-dashoffset 0.35s\",\n// // transform: \"rotate(180deg)\",\n// // transformOrigin: \"50% 50%\",\n// // }}\n// // />\n// // <text\n// // x=\"50%\"\n// // y=\"50%\"\n// // alignmentBaseline=\"middle\"\n// // textAnchor=\"middle\"\n// // fontSize=\"10\"\n// // fill=\"#000\"\n// // >\n// // {value}\n// // </text>\n// // </svg>\n// // );\n// // const HalfCircle = () => (\n// // <svg className={\"hawa-h-36 hawa-w-36\"} viewBox=\"0 0 36 36\">\n// // <path\n// // d=\"M 4,18 A 14,14 0 0,1 32,18\"\n// // strokeWidth=\"4\"\n// // stroke=\"lightgray\"\n// // fill=\"none\"\n// // />\n// // <path\n// // d=\"M 4,18 A 14,14 0 0,1 32,18\"\n// // strokeWidth=\"4\"\n// // stroke=\"#00f\"\n// // fill=\"none\"\n// // // strokeDasharray={`${strokeDasharray}`}\n// // // strokeDashoffset={`${strokeDashoffset}`}\n// // strokeDasharray={50}\n// // strokeDashoffset={50}\n// // style={{\n// // transition: \"stroke-dashoffset 0.35s\",\n// // transformOrigin: \"50% 50%\",\n// // }}\n// // />\n// // <text\n// // x=\"50%\"\n// // y=\"45%\"\n// // alignmentBaseline=\"middle\"\n// // textAnchor=\"middle\"\n// // fontSize=\"8\"\n// // fill=\"#000\"\n// // >\n// // {value}\n// // </text>\n// // </svg>\n// // );\n// return (\n// <div className=\"hawa-flex hawa-flex-row hawa-gap-x-3\">\n// <div aria-label=\"Gauge\" role=\"status\">\n// {/* {design === \"full-circle\" ? <FullCircle /> : <HalfCircle />} */}\n// <AlmostFullCircle value={value} size=\"lg\">\n// {children}\n// </AlmostFullCircle>\n// </div>\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"],"mappings":";;;AAAA,OAAO,WAAW;;;ACAlB,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADkBA,IAAM,cAAqE;AAAA,EACzE,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AACF;AAEA,SAAS,gBAAgB,OAA2B;AAClD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT,WAAW,QAAQ,KAAK;AACtB,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA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I,2DACA;AAAA,UACN;AAAA;AAAA,MACF,IACE;AAAA,IACN;AAAA,IACA,oCAAC,SAAI,WAAW,GAAG,yBAAyB,KAAI,QAAS;AAAA,EAC3D,CACF;AAEJ,CAAC;AAED,eAAe,cAAc;","names":[]}
|
1
|
+
{"version":3,"sources":["../../elements/progressCircle/ProgressCircle.tsx","../../util/index.ts"],"sourcesContent":["import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ntype Size = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\ninterface ProgressCircleProps extends React.HTMLAttributes<HTMLDivElement> {\n value: number;\n size?: Size;\n color?: any;\n showAnimation?: boolean;\n tooltip?: string;\n radius?: number;\n strokeWidth?: number;\n children?: React.ReactNode;\n}\n\nconst size2config: Record<Size, { strokeWidth: number; radius: number }> = {\n xs: { radius: 15, strokeWidth: 3 },\n sm: { radius: 19, strokeWidth: 4 },\n md: { radius: 32, strokeWidth: 6 },\n lg: { radius: 52, strokeWidth: 8 },\n xl: { radius: 80, strokeWidth: 10 }\n};\n\nfunction getLimitedValue(input: number | undefined) {\n if (input === undefined) {\n return 0;\n } else if (input > 100) {\n return 100;\n } else {\n return input;\n }\n}\nexport const ProgressCircle = React.forwardRef<\n HTMLDivElement,\n ProgressCircleProps\n>((props, ref) => {\n const {\n value: inputValue,\n size = \"md\",\n className,\n showAnimation = true,\n color,\n tooltip,\n radius: inputRadius,\n strokeWidth: inputStrokeWidth,\n children,\n ...other\n } = props;\n\n const value = getLimitedValue(inputValue);\n const radius = inputRadius ?? size2config[size].radius;\n const strokeWidth = inputStrokeWidth ?? size2config[size].strokeWidth;\n const normalizedRadius = radius - strokeWidth / 2;\n const circumference = normalizedRadius * 2 * Math.PI;\n const strokeDashoffset = (value / 100) * circumference;\n const offset = circumference - strokeDashoffset;\n\n return (\n <>\n <div\n ref={ref}\n className={cn(\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n className\n )}\n >\n <svg\n width={radius * 2}\n height={radius * 2}\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\n className=\"hawa-rotate-180 hawa-transform\"\n >\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \" hawa-stroke-primary/20\"\n )}\n />\n {value > 0 ? (\n <circle\n r={normalizedRadius}\n cx={radius}\n cy={radius}\n strokeWidth={strokeWidth}\n strokeDasharray={circumference + \" \" + circumference}\n strokeDashoffset={offset}\n fill=\"transparent\"\n stroke=\"\"\n strokeLinecap=\"round\"\n className={cn(\n \"hawa-transition-colors hawa-ease-linear\",\n \"hawa-stroke-primary\",\n showAnimation\n ? \"hawa-transition-all hawa-duration-300 hawa-ease-in-out\"\n : \"\"\n )}\n />\n ) : null}\n </svg>\n <div className={cn(\"hawa-absolute hawa-flex\")}>{children}</div>\n </div>\n </>\n );\n});\n\nProgressCircle.displayName = \"ProgressCircle\";\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,OAAO,WAAW;;;ACAlB,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADYA,IAAM,cAAqE;AAAA,EACzE,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE;AAAA,EACjC,IAAI,EAAE,QAAQ,IAAI,aAAa,GAAG;AACpC;AAEA,SAAS,gBAAgB,OAA2B;AAClD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT,WAAW,QAAQ,KAAK;AACtB,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF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AAA,UACN;AAAA;AAAA,MACF,IACE;AAAA,IACN;AAAA,IACA,oCAAC,SAAI,WAAW,GAAG,yBAAyB,KAAI,QAAS;AAAA,EAC3D,CACF;AAEJ,CAAC;AAED,eAAe,cAAc;","names":[]}
|
package/dist/radio/index.d.mts
CHANGED
@@ -1,16 +1,5 @@
|
|
1
|
-
import * as React from 'react';
|
2
1
|
import { FC } from 'react';
|
3
|
-
|
4
|
-
type DirectionType = "rtl" | "ltr";
|
5
|
-
type PositionType = "top" | "bottom" | "right" | "left";
|
6
|
-
type OrientationType = "vertical" | "horizontal";
|
7
|
-
|
8
|
-
type LabelProps = {
|
9
|
-
hint?: React.ReactNode;
|
10
|
-
hintSide?: PositionType;
|
11
|
-
htmlFor?: string;
|
12
|
-
required?: boolean;
|
13
|
-
};
|
2
|
+
import { O as OrientationType, D as DirectionType, L as LabelProps } from '../Label-9FHRF7Ex.mjs';
|
14
3
|
|
15
4
|
type RadioOptionsTypes = {
|
16
5
|
value: any;
|