@sikka/hawa 0.30.23-next → 0.30.25-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/{DropdownMenu-sSnQc6fT.d.ts → DropdownMenu-o_-MnT5h.d.mts} +6 -6
- package/dist/{DropdownMenu-arqV1gRt.d.mts → DropdownMenu-p-Ha-y2R.d.ts} +6 -6
- package/dist/appLayout/index.d.mts +8 -1
- package/dist/appLayout/index.d.ts +8 -1
- package/dist/appLayout/index.js +31 -0
- package/dist/appLayout/index.js.map +1 -1
- package/dist/appLayout/index.mjs +35 -4
- package/dist/appLayout/index.mjs.map +1 -1
- package/dist/appTopbar/index.d.mts +5 -2
- package/dist/appTopbar/index.d.ts +5 -2
- package/dist/appTopbar/index.js +31 -0
- package/dist/appTopbar/index.js.map +1 -1
- package/dist/appTopbar/index.mjs +31 -0
- package/dist/appTopbar/index.mjs.map +1 -1
- package/dist/blocks/index.d.mts +1 -1
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.js +31 -0
- package/dist/blocks/index.mjs +2 -2
- package/dist/blocks/pricing/index.mjs +3 -3
- package/dist/breadcrumb/index.d.mts +7 -5
- package/dist/breadcrumb/index.d.ts +7 -5
- package/dist/breadcrumb/index.js +36 -12
- package/dist/breadcrumb/index.js.map +1 -1
- package/dist/breadcrumb/index.mjs +36 -12
- package/dist/breadcrumb/index.mjs.map +1 -1
- package/dist/{chunk-CXBN42TF.mjs → chunk-7LAUVLVZ.mjs} +1 -1
- package/dist/{chunk-HOE4FCIF.mjs → chunk-DGOT2FVH.mjs} +30 -0
- package/dist/{chunk-MH5K6NEO.mjs → chunk-TKSAYWDH.mjs} +1 -1
- package/dist/combobox/index.js +44 -35
- package/dist/combobox/index.js.map +1 -1
- package/dist/combobox/index.mjs +44 -35
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/commonTypes-52DloiYq.d.mts +7 -0
- package/dist/commonTypes-52DloiYq.d.ts +7 -0
- package/dist/dataTable/index.js +31 -0
- package/dist/dataTable/index.js.map +1 -1
- package/dist/dataTable/index.mjs +31 -0
- package/dist/dataTable/index.mjs.map +1 -1
- package/dist/docsLayout/index.d.mts +1 -1
- package/dist/docsLayout/index.d.ts +1 -1
- package/dist/dropdownMenu/index.d.mts +9 -5
- package/dist/dropdownMenu/index.d.ts +9 -5
- package/dist/dropdownMenu/index.js +30 -0
- package/dist/dropdownMenu/index.js.map +1 -1
- package/dist/dropdownMenu/index.mjs +30 -0
- package/dist/dropdownMenu/index.mjs.map +1 -1
- package/dist/elements/index.d.mts +8 -6
- package/dist/elements/index.d.ts +8 -6
- package/dist/elements/index.js +101 -47
- package/dist/elements/index.mjs +74 -50
- package/dist/index.d.mts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.js +101 -47
- package/dist/index.mjs +206 -152
- package/dist/layout/index.d.mts +1 -1
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +31 -0
- package/dist/layout/index.mjs +2 -2
- package/dist/splitButton/index.d.mts +8 -1
- package/dist/splitButton/index.d.ts +8 -1
- package/dist/splitButton/index.js +31 -0
- package/dist/splitButton/index.js.map +1 -1
- package/dist/splitButton/index.mjs +31 -0
- package/dist/splitButton/index.mjs.map +1 -1
- package/package.json +1 -1
@@ -1,14 +1,16 @@
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
2
2
|
|
3
|
+
type BreadcrumbItemProps = {
|
4
|
+
label: string;
|
5
|
+
href: string;
|
6
|
+
};
|
3
7
|
interface BCTypes {
|
4
8
|
/** The array of crumbs, each one with a label and a href link */
|
5
|
-
breadcrumbLinks:
|
6
|
-
label: string;
|
7
|
-
href: string;
|
8
|
-
}[];
|
9
|
+
breadcrumbLinks: BreadcrumbItemProps[];
|
9
10
|
/** The separator between each crumb, can be character or React Node. The default is ">" */
|
10
11
|
separator?: string | ReactNode;
|
12
|
+
size?: "normal" | "small" | "xs";
|
11
13
|
}
|
12
14
|
declare const Breadcrumb: FC<BCTypes>;
|
13
15
|
|
14
|
-
export { Breadcrumb };
|
16
|
+
export { Breadcrumb, type BreadcrumbItemProps };
|
package/dist/breadcrumb/index.js
CHANGED
@@ -37,26 +37,50 @@ module.exports = __toCommonJS(breadcrumb_exports);
|
|
37
37
|
|
38
38
|
// elements/breadcrumb/Breadcrumb.tsx
|
39
39
|
var import_react = __toESM(require("react"));
|
40
|
+
|
41
|
+
// util/index.ts
|
42
|
+
var import_clsx = require("clsx");
|
43
|
+
var import_tailwind_merge = require("tailwind-merge");
|
44
|
+
function cn(...inputs) {
|
45
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
46
|
+
}
|
47
|
+
|
48
|
+
// elements/breadcrumb/Breadcrumb.tsx
|
40
49
|
var Breadcrumb = ({
|
41
50
|
breadcrumbLinks,
|
42
|
-
separator = ">"
|
51
|
+
separator = ">",
|
52
|
+
size = "normal"
|
43
53
|
}) => {
|
44
|
-
|
54
|
+
const textStyles = {
|
55
|
+
normal: "",
|
56
|
+
small: "hawa-text-sm",
|
57
|
+
xs: "hawa-text-xs"
|
58
|
+
};
|
59
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
45
60
|
"div",
|
46
61
|
{
|
47
|
-
|
48
|
-
|
62
|
+
className: cn(
|
63
|
+
"hawa-flex hawa-flex-row hawa-items-center hawa-gap-2 hawa-text-sm",
|
64
|
+
textStyles[size]
|
65
|
+
)
|
49
66
|
},
|
50
|
-
/* @__PURE__ */ import_react.default.createElement(
|
51
|
-
"
|
67
|
+
breadcrumbLinks.map((singleBreadcrumbLink, index) => /* @__PURE__ */ import_react.default.createElement(
|
68
|
+
"div",
|
52
69
|
{
|
53
|
-
|
54
|
-
className:
|
70
|
+
key: index,
|
71
|
+
className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-2"
|
55
72
|
},
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
73
|
+
/* @__PURE__ */ import_react.default.createElement(
|
74
|
+
"a",
|
75
|
+
{
|
76
|
+
href: singleBreadcrumbLink.href,
|
77
|
+
className: index + 1 === breadcrumbLinks.length ? "hawa-pointer-events-none" : "hawa-underline-offset-4 hawa-transition-all hover:hawa-text-primary hover:hawa-underline hover:hawa-decoration-2"
|
78
|
+
},
|
79
|
+
singleBreadcrumbLink.label
|
80
|
+
),
|
81
|
+
index != breadcrumbLinks.length - 1 ? typeof separator == "string" ? /* @__PURE__ */ import_react.default.createElement("div", null, separator) : /* @__PURE__ */ import_react.default.createElement("div", null, separator) : null
|
82
|
+
))
|
83
|
+
);
|
60
84
|
};
|
61
85
|
// Annotate the CommonJS export names for ESM import in node:
|
62
86
|
0 && (module.exports = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/breadcrumb/index.ts","../../elements/breadcrumb/Breadcrumb.tsx"],"sourcesContent":["export * from \"./Breadcrumb\";\n","import React, { FC, ReactNode } from \"react\";\n\ninterface BCTypes {\n /** The array of crumbs, each one with a label and a href link */\n breadcrumbLinks:
|
1
|
+
{"version":3,"sources":["../../elements/breadcrumb/index.ts","../../elements/breadcrumb/Breadcrumb.tsx","../../util/index.ts"],"sourcesContent":["export * from \"./Breadcrumb\";\n","import React, { FC, ReactNode } from \"react\";\n\nimport { cn } from \"@util/index\";\n\nexport type BreadcrumbItemProps = {\n label: string;\n href: string;\n};\ninterface BCTypes {\n /** The array of crumbs, each one with a label and a href link */\n breadcrumbLinks: BreadcrumbItemProps[];\n /** The separator between each crumb, can be character or React Node. The default is \">\" */\n separator?: string | ReactNode;\n size?: \"normal\" | \"small\" | \"xs\";\n}\n\nexport const Breadcrumb: FC<BCTypes> = ({\n breadcrumbLinks,\n separator = \">\",\n size = \"normal\",\n}) => {\n const textStyles = {\n normal: \"\",\n small: \"hawa-text-sm\",\n xs: \"hawa-text-xs\",\n };\n return (\n <div\n className={cn(\n \"hawa-flex hawa-flex-row hawa-items-center hawa-gap-2 hawa-text-sm\",\n textStyles[size],\n )}\n >\n {breadcrumbLinks.map((singleBreadcrumbLink, index) => (\n <div\n key={index}\n className=\"hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-2\"\n >\n <a\n href={singleBreadcrumbLink.href}\n className={\n index + 1 === breadcrumbLinks.length\n ? \"hawa-pointer-events-none\"\n : \"hawa-underline-offset-4 hawa-transition-all hover:hawa-text-primary hover:hawa-underline hover:hawa-decoration-2\"\n }\n >\n {singleBreadcrumbLink.label}\n </a>\n {index != breadcrumbLinks.length - 1 ? (\n typeof separator == \"string\" ? (\n <div>{separator}</div>\n ) : (\n <div>{separator}</div>\n )\n ) : null}\n </div>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAqC;;;ACArC,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADWO,IAAM,aAA0B,CAAC;AAAA,EACtC;AAAA,EACA,YAAY;AAAA,EACZ,OAAO;AACT,MAAM;AACJ,QAAM,aAAa;AAAA,IACjB,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,IAAI;AAAA,EACN;AACA,SACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,WAAW,IAAI;AAAA,MACjB;AAAA;AAAA,IAEC,gBAAgB,IAAI,CAAC,sBAAsB,UAC1C,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,WAAU;AAAA;AAAA,MAEV,6BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,qBAAqB;AAAA,UAC3B,WACE,QAAQ,MAAM,gBAAgB,SAC1B,6BACA;AAAA;AAAA,QAGL,qBAAqB;AAAA,MACxB;AAAA,MACC,SAAS,gBAAgB,SAAS,IACjC,OAAO,aAAa,WAClB,6BAAAA,QAAA,cAAC,aAAK,SAAU,IAEhB,6BAAAA,QAAA,cAAC,aAAK,SAAU,IAEhB;AAAA,IACN,CACD;AAAA,EACH;AAEJ;","names":["React"]}
|
@@ -2,26 +2,50 @@
|
|
2
2
|
|
3
3
|
// elements/breadcrumb/Breadcrumb.tsx
|
4
4
|
import React from "react";
|
5
|
+
|
6
|
+
// util/index.ts
|
7
|
+
import { clsx } from "clsx";
|
8
|
+
import { twMerge } from "tailwind-merge";
|
9
|
+
function cn(...inputs) {
|
10
|
+
return twMerge(clsx(inputs));
|
11
|
+
}
|
12
|
+
|
13
|
+
// elements/breadcrumb/Breadcrumb.tsx
|
5
14
|
var Breadcrumb = ({
|
6
15
|
breadcrumbLinks,
|
7
|
-
separator = ">"
|
16
|
+
separator = ">",
|
17
|
+
size = "normal"
|
8
18
|
}) => {
|
9
|
-
|
19
|
+
const textStyles = {
|
20
|
+
normal: "",
|
21
|
+
small: "hawa-text-sm",
|
22
|
+
xs: "hawa-text-xs"
|
23
|
+
};
|
24
|
+
return /* @__PURE__ */ React.createElement(
|
10
25
|
"div",
|
11
26
|
{
|
12
|
-
|
13
|
-
|
27
|
+
className: cn(
|
28
|
+
"hawa-flex hawa-flex-row hawa-items-center hawa-gap-2 hawa-text-sm",
|
29
|
+
textStyles[size]
|
30
|
+
)
|
14
31
|
},
|
15
|
-
/* @__PURE__ */ React.createElement(
|
16
|
-
"
|
32
|
+
breadcrumbLinks.map((singleBreadcrumbLink, index) => /* @__PURE__ */ React.createElement(
|
33
|
+
"div",
|
17
34
|
{
|
18
|
-
|
19
|
-
className:
|
35
|
+
key: index,
|
36
|
+
className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-2"
|
20
37
|
},
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
38
|
+
/* @__PURE__ */ React.createElement(
|
39
|
+
"a",
|
40
|
+
{
|
41
|
+
href: singleBreadcrumbLink.href,
|
42
|
+
className: index + 1 === breadcrumbLinks.length ? "hawa-pointer-events-none" : "hawa-underline-offset-4 hawa-transition-all hover:hawa-text-primary hover:hawa-underline hover:hawa-decoration-2"
|
43
|
+
},
|
44
|
+
singleBreadcrumbLink.label
|
45
|
+
),
|
46
|
+
index != breadcrumbLinks.length - 1 ? typeof separator == "string" ? /* @__PURE__ */ React.createElement("div", null, separator) : /* @__PURE__ */ React.createElement("div", null, separator) : null
|
47
|
+
))
|
48
|
+
);
|
25
49
|
};
|
26
50
|
export {
|
27
51
|
Breadcrumb
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import React, { FC, ReactNode } from \"react\";\n\ninterface BCTypes {\n /** The array of crumbs, each one with a label and a href link */\n breadcrumbLinks:
|
1
|
+
{"version":3,"sources":["../../elements/breadcrumb/Breadcrumb.tsx","../../util/index.ts"],"sourcesContent":["import React, { FC, ReactNode } from \"react\";\n\nimport { cn } from \"@util/index\";\n\nexport type BreadcrumbItemProps = {\n label: string;\n href: string;\n};\ninterface BCTypes {\n /** The array of crumbs, each one with a label and a href link */\n breadcrumbLinks: BreadcrumbItemProps[];\n /** The separator between each crumb, can be character or React Node. The default is \">\" */\n separator?: string | ReactNode;\n size?: \"normal\" | \"small\" | \"xs\";\n}\n\nexport const Breadcrumb: FC<BCTypes> = ({\n breadcrumbLinks,\n separator = \">\",\n size = \"normal\",\n}) => {\n const textStyles = {\n normal: \"\",\n small: \"hawa-text-sm\",\n xs: \"hawa-text-xs\",\n };\n return (\n <div\n className={cn(\n \"hawa-flex hawa-flex-row hawa-items-center hawa-gap-2 hawa-text-sm\",\n textStyles[size],\n )}\n >\n {breadcrumbLinks.map((singleBreadcrumbLink, index) => (\n <div\n key={index}\n className=\"hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-2\"\n >\n <a\n href={singleBreadcrumbLink.href}\n className={\n index + 1 === breadcrumbLinks.length\n ? \"hawa-pointer-events-none\"\n : \"hawa-underline-offset-4 hawa-transition-all hover:hawa-text-primary hover:hawa-underline hover:hawa-decoration-2\"\n }\n >\n {singleBreadcrumbLink.label}\n </a>\n {index != breadcrumbLinks.length - 1 ? (\n typeof separator == \"string\" ? (\n <div>{separator}</div>\n ) : (\n <div>{separator}</div>\n )\n ) : null}\n </div>\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"],"mappings":";;;AAAA,OAAO,WAA8B;;;ACArC,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADWO,IAAM,aAA0B,CAAC;AAAA,EACtC;AAAA,EACA,YAAY;AAAA,EACZ,OAAO;AACT,MAAM;AACJ,QAAM,aAAa;AAAA,IACjB,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,IAAI;AAAA,EACN;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,WAAW,IAAI;AAAA,MACjB;AAAA;AAAA,IAEC,gBAAgB,IAAI,CAAC,sBAAsB,UAC1C;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,WAAU;AAAA;AAAA,MAEV;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,qBAAqB;AAAA,UAC3B,WACE,QAAQ,MAAM,gBAAgB,SAC1B,6BACA;AAAA;AAAA,QAGL,qBAAqB;AAAA,MACxB;AAAA,MACC,SAAS,gBAAgB,SAAS,IACjC,OAAO,aAAa,WAClB,oCAAC,aAAK,SAAU,IAEhB,oCAAC,aAAK,SAAU,IAEhB;AAAA,IACN,CACD;AAAA,EACH;AAEJ;","names":[]}
|
@@ -1158,6 +1158,9 @@ var DropdownMenu = ({
|
|
1158
1158
|
default: "hawa-px-2 hawa-py-3 ",
|
1159
1159
|
sm: "hawa-text-xs hawa-px-1.5 hawa-py-1.5 "
|
1160
1160
|
};
|
1161
|
+
let [values, setValues] = React8.useState(
|
1162
|
+
items.map((item) => item.currentOption)
|
1163
|
+
);
|
1161
1164
|
return /* @__PURE__ */ React8.createElement(
|
1162
1165
|
DropdownMenuRoot,
|
1163
1166
|
{
|
@@ -1185,11 +1188,38 @@ var DropdownMenu = ({
|
|
1185
1188
|
},
|
1186
1189
|
header && header,
|
1187
1190
|
items && items.map((item, index) => {
|
1191
|
+
var _a;
|
1188
1192
|
const ItemLinkComponent = item.slug ? LinkComponent : "a";
|
1189
1193
|
if (item.itemType === "separator") {
|
1190
1194
|
return /* @__PURE__ */ React8.createElement(DropdownMenuSeparator, { key: index });
|
1191
1195
|
} else if (item.itemType === "label") {
|
1192
1196
|
return /* @__PURE__ */ React8.createElement(DropdownMenuLabel, { key: index }, item.label);
|
1197
|
+
} else if (item.itemType === "radio") {
|
1198
|
+
let dd = item.currentOption;
|
1199
|
+
return /* @__PURE__ */ React8.createElement(DropdownMenuSub, { key: index }, /* @__PURE__ */ React8.createElement(
|
1200
|
+
DropdownMenuSubTrigger,
|
1201
|
+
{
|
1202
|
+
dir: direction,
|
1203
|
+
className: cn(sizeStyles[size])
|
1204
|
+
},
|
1205
|
+
item.icon && item.icon,
|
1206
|
+
item.label && item.label
|
1207
|
+
), /* @__PURE__ */ React8.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React8.createElement(
|
1208
|
+
DropdownMenuRadioGroup,
|
1209
|
+
{
|
1210
|
+
value: values[index],
|
1211
|
+
onValueChange: (e) => {
|
1212
|
+
let newValues = [...values];
|
1213
|
+
newValues[index] = e;
|
1214
|
+
setValues(newValues);
|
1215
|
+
console.log("changing to ", e);
|
1216
|
+
if (item.onOptionChange) {
|
1217
|
+
item.onOptionChange(e);
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
},
|
1221
|
+
(_a = item.options) == null ? void 0 : _a.map((opt, i) => /* @__PURE__ */ React8.createElement(DropdownMenuRadioItem, { key: i, value: opt.value }, opt.label))
|
1222
|
+
)));
|
1193
1223
|
} else if (item.itemType === "custom") {
|
1194
1224
|
return /* @__PURE__ */ React8.createElement("div", { key: index }, item.content);
|
1195
1225
|
} else {
|
package/dist/combobox/index.js
CHANGED
@@ -749,46 +749,55 @@ var Combobox = React7.forwardRef(
|
|
749
749
|
}
|
750
750
|
),
|
751
751
|
/* @__PURE__ */ React7.createElement(CommandEmpty, null, ((_c = props.texts) == null ? void 0 : _c.noItems) || "No items found."),
|
752
|
-
/* @__PURE__ */ React7.createElement(CommandList, null, /* @__PURE__ */ React7.createElement(
|
753
|
-
|
752
|
+
/* @__PURE__ */ React7.createElement(CommandList, null, /* @__PURE__ */ React7.createElement(
|
753
|
+
CommandGroup,
|
754
754
|
{
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
755
|
+
className: cn(
|
756
|
+
"hawa-max-h-[200px]",
|
757
|
+
data.length > 0 && "hawa-overflow-y-scroll"
|
758
|
+
)
|
759
|
+
},
|
760
|
+
data.map((item, i) => /* @__PURE__ */ React7.createElement(
|
761
|
+
CommandItem,
|
762
|
+
{
|
763
|
+
key: i,
|
764
|
+
onSelect: () => {
|
765
|
+
const newValue = getProperty(item, valueKey);
|
766
|
+
setValue(
|
763
767
|
newValue === value ? "" : newValue
|
764
768
|
);
|
769
|
+
if (props.onChange) {
|
770
|
+
props.onChange(
|
771
|
+
newValue === value ? "" : newValue
|
772
|
+
);
|
773
|
+
}
|
774
|
+
setOpen(false);
|
765
775
|
}
|
766
|
-
setOpen(false);
|
767
|
-
}
|
768
|
-
},
|
769
|
-
/* @__PURE__ */ React7.createElement(
|
770
|
-
"svg",
|
771
|
-
{
|
772
|
-
"aria-label": "Check Icon",
|
773
|
-
xmlns: "http://www.w3.org/2000/svg",
|
774
|
-
width: "24",
|
775
|
-
height: "24",
|
776
|
-
viewBox: "0 0 24 24",
|
777
|
-
fill: "none",
|
778
|
-
stroke: "currentColor",
|
779
|
-
strokeWidth: "2",
|
780
|
-
strokeLinecap: "round",
|
781
|
-
strokeLinejoin: "round",
|
782
|
-
className: cn(
|
783
|
-
"hawa-icon",
|
784
|
-
value === getProperty(item, valueKey) ? "hawa-opacity-100" : "hawa-opacity-0"
|
785
|
-
),
|
786
|
-
style: { marginInlineEnd: "0.5rem" }
|
787
776
|
},
|
788
|
-
/* @__PURE__ */ React7.createElement(
|
789
|
-
|
790
|
-
|
791
|
-
|
777
|
+
/* @__PURE__ */ React7.createElement(
|
778
|
+
"svg",
|
779
|
+
{
|
780
|
+
"aria-label": "Check Icon",
|
781
|
+
xmlns: "http://www.w3.org/2000/svg",
|
782
|
+
width: "24",
|
783
|
+
height: "24",
|
784
|
+
viewBox: "0 0 24 24",
|
785
|
+
fill: "none",
|
786
|
+
stroke: "currentColor",
|
787
|
+
strokeWidth: "2",
|
788
|
+
strokeLinecap: "round",
|
789
|
+
strokeLinejoin: "round",
|
790
|
+
className: cn(
|
791
|
+
"hawa-icon",
|
792
|
+
value === getProperty(item, valueKey) ? "hawa-opacity-100" : "hawa-opacity-0"
|
793
|
+
),
|
794
|
+
style: { marginInlineEnd: "0.5rem" }
|
795
|
+
},
|
796
|
+
/* @__PURE__ */ React7.createElement("polyline", { points: "20 6 9 17 4 12" })
|
797
|
+
),
|
798
|
+
renderOption ? renderOption(item) : getProperty(item, labelKey)
|
799
|
+
))
|
800
|
+
))
|
792
801
|
)
|
793
802
|
))
|
794
803
|
);
|