@sikka/hawa 0.36.2-next → 0.37.0-next
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appLayout/index.js +1 -1
- package/dist/appLayout/index.js.map +1 -1
- package/dist/appLayout/index.mjs +1 -1
- package/dist/appLayout/index.mjs.map +1 -1
- package/dist/blocks/auth/index.js +11 -14
- package/dist/blocks/auth/index.mjs +1 -1
- package/dist/blocks/feedback/index.js +11 -14
- package/dist/blocks/feedback/index.mjs +1 -1
- package/dist/blocks/index.js +295 -181
- package/dist/blocks/index.mjs +2 -2
- package/dist/blocks/misc/index.js +257 -143
- package/dist/blocks/misc/index.mjs +50 -16
- package/dist/blocks/pricing/index.js +94 -11
- package/dist/blocks/pricing/index.mjs +1 -1
- package/dist/{chunk-CJ57JBYA.mjs → chunk-I5YX7N76.mjs} +94 -11
- package/dist/{chunk-T33FXOHA.mjs → chunk-PO5OW6SQ.mjs} +151 -40
- package/dist/{chunk-HLYAX77R.mjs → chunk-SE5A4R76.mjs} +11 -14
- package/dist/{chunk-OPYDG34F.mjs → chunk-ZBUBNKF6.mjs} +93 -1
- package/dist/combobox/index.d.mts +1 -4
- package/dist/combobox/index.d.ts +1 -4
- package/dist/combobox/index.js +2 -1
- package/dist/combobox/index.js.map +1 -1
- package/dist/combobox/index.mjs +2 -1
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/command/index.d.mts +4 -36
- package/dist/command/index.d.ts +4 -36
- package/dist/command/index.js +43 -5
- package/dist/command/index.js.map +1 -1
- package/dist/command/index.mjs +39 -3
- package/dist/command/index.mjs.map +1 -1
- package/dist/elements/index.d.mts +28 -2
- package/dist/elements/index.d.ts +28 -2
- package/dist/elements/index.js +437 -284
- package/dist/elements/index.mjs +41 -4
- package/dist/hooks/index.d.mts +25 -1
- package/dist/hooks/index.d.ts +25 -1
- package/dist/hooks/index.js +96 -0
- package/dist/hooks/index.mjs +9 -1
- package/dist/index-CoPyqTu8.d.mts +63 -0
- package/dist/index-CoPyqTu8.d.ts +63 -0
- package/dist/index.css +20 -3
- package/dist/index.d.mts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +953 -707
- package/dist/index.mjs +481 -241
- package/dist/layout/index.js +1 -1
- package/dist/layout/index.mjs +1 -1
- package/dist/phoneInput/index.js +11 -14
- package/dist/phoneInput/index.js.map +1 -1
- package/dist/phoneInput/index.mjs +11 -14
- package/dist/phoneInput/index.mjs.map +1 -1
- package/dist/scrollArea/index.js +94 -11
- package/dist/scrollArea/index.js.map +1 -1
- package/dist/scrollArea/index.mjs +94 -11
- package/dist/scrollArea/index.mjs.map +1 -1
- package/dist/select/index.js +11 -14
- package/dist/select/index.js.map +1 -1
- package/dist/select/index.mjs +11 -14
- package/dist/select/index.mjs.map +1 -1
- package/dist/tabs/index.d.mts +3 -1
- package/dist/tabs/index.d.ts +3 -1
- package/dist/tabs/index.js +189 -32
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +184 -27
- package/dist/tabs/index.mjs.map +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../elements/select/Select.tsx","../../util/index.ts","../../elements/label/Label.tsx","../../elements/tooltip/Tooltip.tsx","../../elements/skeleton/Skeleton.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport ReactSelect, { MenuProps } from \"react-select\";\nimport CreatableSelect from \"react-select/creatable\";\n\nimport { cn } from \"@util/index\";\nimport clsx from \"clsx\";\n\nimport { Label, LabelProps } from \"../label\";\nimport { Skeleton } from \"../skeleton\";\n\ntype ControlTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\n// The options container\ntype MenuTypes = MenuProps & {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n};\n\n// The single options\ntype OptionTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\nexport type SelectOptionProps = {\n value: any;\n label: any;\n};\n\ntype SelectTypes = {\n label?: string;\n hideHelperText?: boolean;\n options: SelectOptionProps[];\n labelKey?: string;\n isCreatable?: boolean;\n isClearable?: boolean;\n isMulti?: boolean;\n isSearchable?: boolean;\n controlClassNames?: string;\n containerClassNames?: string;\n onChange: any;\n helperText?: string;\n onInputChange?: any;\n native?: any;\n width?: \"full\" | \"small\" | \"fit\";\n value?: any;\n children?: any;\n getOptionLabel?: any;\n disabled?: boolean;\n defaultValue?: any;\n handleCreateOption?: () => void;\n placeholder?: string;\n hideIndicator?: boolean;\n phoneCode?: boolean;\n isLoading?: any;\n labelProps?: LabelProps;\n texts?: {\n noOptions?: string;\n createLabel?: string;\n };\n};\n\nexport const Select: FC<SelectTypes> = ({\n labelProps,\n labelKey = \"label\",\n ...props\n}) => {\n const NoOption = () => {\n return <div>{props.texts?.noOptions ?? \"No Items Found\"}</div>;\n };\n const Control: FC<ControlTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={clsx(\n \"hawa-flex hawa-w-full hawa-rounded hawa-border hawa-bg-background hawa-p-2 hawa-text-sm hawa-text-gray-900 focus:hawa-border-blue-500 focus:hawa-ring-blue-500 dark:focus:hawa-ring-blue-500\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Option: FC<OptionTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={cn(\n \"hawa-flex hawa-cursor-pointer hawa-select-none hawa-flex-row hawa-items-center hawa-justify-between hawa-rounded-inner hawa-p-1 hawa-px-2 hawa-transition-all hover:hawa-bg-primary hover:hawa-text-primary-foreground\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Menu: FC<MenuTypes> = ({\n cx,\n children,\n getStyles,\n innerProps,\n innerRef,\n ...menuProps\n }) => {\n const menuOpen = menuProps.selectProps.menuIsOpen;\n return (\n <div\n className={cn(\n \"dark:dark-shadow hawa-absolute hawa-z-10 -hawa-mx-1 hawa-mt-1 hawa-flex hawa-flex-col hawa-justify-start hawa-rounded hawa-border hawa-bg-background hawa-shadow-md\",\n props.phoneCode ? \"hawa-p-1.5\" : \"hawa-w-full hawa-p-1.5\",\n menuOpen && \"hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 \",\n )}\n ref={innerRef}\n {...innerProps}\n // {...props}\n >\n {children}\n </div>\n );\n };\n\n return (\n <div\n className={cn(\n \"hawa-flex hawa-flex-col hawa-gap-2\",\n props.width === \"fit\" ? \"hawa-w-fit\" : \"hawa-w-full\",\n )}\n >\n {props.label && <Label {...labelProps}>{props.label}</Label>}\n {props.isLoading ? (\n <Skeleton className=\"hawa-h-[40px] hawa-w-full\" />\n ) : !props.isCreatable ? (\n // TODO: enable keyboard to go to the next item in the list\n <ReactSelect\n noOptionsMessage={NoOption}\n classNames={{\n control: () =>\n cn(\n props.phoneCode && \"hawa-rounded-r-none\",\n props.controlClassNames,\n ),\n container: () =>\n cn(\n \"hawa-rounded \",\n props.phoneCode &&\n \"hawa-min-w-[65px] hawa-text-right hawa-w-[100px] hawa-p-0 hawa-rounded-r-none hawa-h-[40px] \",\n\n \"hawa-block hawa-w-full hawa-rounded hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm\",\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n\n props.isMulti && \"hawa-ps-0 \",\n ),\n\n placeholder: () =>\n \"hawa-text-muted-foreground hawa-cursor-pointer hawa-px-1\",\n valueContainer: () => \"hawa-text-foreground hawa-px-1 \",\n singleValue: () => \"hawa-text-foreground\",\n indicatorsContainer: () =>\n cn(\n \"hawa-cursor-pointer hawa-text-muted-foreground hawa-absolute hawa-end-0 hawa-top-[50%] hawa-bottom-[50%] \",\n props.hideIndicator ? \"hawa-invisible\" : \"hawa-px-1\",\n ),\n }}\n unstyled\n // autoFocus\n components={\n props.hideIndicator\n ? {\n Option,\n Menu,\n IndicatorsContainer: () => null,\n }\n : {\n Option,\n Menu,\n // Control: (e) => (\n // <div\n // className={cn(e.className, \"hawa-flex hawa-flex-row\")}\n // {...e}\n // />\n // ),\n\n ValueContainer: (e) => (\n <div\n className={cn(\n e.className,\n \"hawa-gap-1 hawa-flex hawa-flex-row hawa-flex-wrap hawa-p-1\",\n )}\n {...e}\n />\n ),\n MultiValueContainer: (e) => (\n <div\n className={cn(\n // e.className,\n \"hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row\",\n )}\n {...e}\n />\n ),\n }\n }\n onChange={(newValue: any, action) => props.onChange(newValue, action)}\n options={props.options}\n getOptionLabel={props.getOptionLabel}\n defaultValue={props.defaultValue}\n placeholder={props.placeholder}\n isDisabled={props.disabled}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n />\n ) : (\n <CreatableSelect\n formatCreateLabel={(inputValue) =>\n `${props.texts?.createLabel ?? \"Create\"} \"${inputValue}\"`\n }\n classNames={{\n container: () =>\n cn(\n \"hawa-rounded\",\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n ),\n placeholder: () => \"hawa-px-2 hawa-text-muted-foreground\",\n input: () => \"hawa-text-primary hawa-px-2\",\n valueContainer: () =>\n \"hawa-text-white dark:hawa-text-muted-foreground\",\n singleValue: () => \"hawa-text-black dark:hawa-text-white hawa-px-2\",\n indicatorsContainer: () =>\n \" hawa-px-2 hawa-cursor-pointer hawa-text-muted-foreground\",\n }}\n unstyled\n options={props.options}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n placeholder={props.placeholder}\n onCreateOption={props.handleCreateOption}\n onChange={(newValue, action) => props.onChange(newValue, action)}\n components={{ Control, Option, Menu }}\n onInputChange={(newValue, action) =>\n props.onInputChange(newValue, action)\n }\n />\n )}\n {!props.hideHelperText && (\n <p\n className={cn(\n \"hawa-my-0 hawa-text-start hawa-text-xs hawa-text-helper-color hawa-transition-all\",\n props.helperText\n ? \"hawa-h-4 hawa-opacity-100\"\n : \"hawa-h-0 hawa-opacity-0\",\n )}\n >\n {props.helperText}\n </p>\n )}\n </div>\n );\n};\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\ntype Palette = {\n name: string;\n colors: {\n [key: number]: string;\n };\n};\ntype Rgb = {\n r: number;\n g: number;\n b: number;\n};\nfunction hexToRgb(hex: string): Rgb | null {\n const sanitizedHex = hex.replaceAll(\"##\", \"#\");\n const colorParts = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(\n sanitizedHex\n );\n\n if (!colorParts) {\n return null;\n }\n\n const [, r, g, b] = colorParts;\n\n return {\n r: parseInt(r, 16),\n g: parseInt(g, 16),\n b: parseInt(b, 16)\n } as Rgb;\n}\n\nfunction rgbToHex(r: number, g: number, b: number): string {\n const toHex = (c: number) => `0${c.toString(16)}`.slice(-2);\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\nexport function getTextColor(color: string): \"#FFF\" | \"#333\" {\n const rgbColor = hexToRgb(color);\n\n if (!rgbColor) {\n return \"#333\";\n }\n\n const { r, g, b } = rgbColor;\n const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n return luma < 120 ? \"#FFF\" : \"#333\";\n}\n\nfunction lighten(hex: string, intensity: number): string {\n const color = hexToRgb(`#${hex}`);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r + (255 - color.r) * intensity);\n const g = Math.round(color.g + (255 - color.g) * intensity);\n const b = Math.round(color.b + (255 - color.b) * intensity);\n\n return rgbToHex(r, g, b);\n}\n\nfunction darken(hex: string, intensity: number): string {\n const color = hexToRgb(hex);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r * intensity);\n const g = Math.round(color.g * intensity);\n const b = Math.round(color.b * intensity);\n\n return rgbToHex(r, g, b);\n}\nconst parseColor = (color: any) => {\n if (color.startsWith(\"#\")) {\n // Convert hex to RGB\n let r = parseInt(color.slice(1, 3), 16);\n let g = parseInt(color.slice(3, 5), 16);\n let b = parseInt(color.slice(5, 7), 16);\n return [r, g, b];\n } else if (color.startsWith(\"rgb\")) {\n // Extract RGB values from rgb() format\n return color.match(/\\d+/g).map(Number);\n }\n // Default to white if format is unrecognized\n return [255, 255, 255];\n};\nexport const calculateLuminance = (color: any) => {\n const [r, g, b] = parseColor(color)?.map((c: any) => {\n c /= 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nfunction getPallette(baseColor: string): Palette {\n const name = baseColor;\n\n const response: Palette = {\n name,\n colors: {\n 500: `#${baseColor}`.replace(\"##\", \"#\")\n }\n };\n\n const intensityMap: {\n [key: number]: number;\n } = {\n 50: 0.95,\n 100: 0.9,\n 200: 0.75,\n 300: 0.6,\n 400: 0.3,\n 600: 0.9,\n 700: 0.75,\n 800: 0.6,\n 900: 0.49\n };\n\n [50, 100, 200, 300, 400].forEach((level) => {\n response.colors[level] = lighten(baseColor, intensityMap[level]);\n });\n [600, 700, 800, 900].forEach((level) => {\n response.colors[level] = darken(baseColor, intensityMap[level]);\n });\n\n return response as Palette;\n}\n\nexport { getPallette };\n\n// const hexToRgb = (hex) => {\n// let d = hex?.split(\"#\")[1];\n// var aRgbHex = d?.match(/.{1,2}/g);\n// var aRgb = [\n// parseInt(aRgbHex[0], 16),\n// parseInt(aRgbHex[1], 16),\n// parseInt(aRgbHex[2], 16)\n// ];\n// return aRgb;\n// };\n// const getTextColor = (backColor) => {\n// let rgbArray = hexToRgb(backColor);\n// if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {\n// return \"#000000\";\n// } else {\n// return \"#ffffff\";\n// }\n// };\n// const replaceAt = function (string, index, replacement) {\n// // if (replacement == \"\" || replacement == \" \") {\n// // return (\n// // string.substring(0, index) +\n// // string.substring(index + replacement.length )\n// // );\n// // }\n// const replaced = string.substring(0, index) + replacement + string.substring(index + 1)\n// return replaced\n// };\n\n// export { hexToRgb, getTextColor, replaceAt };\n","import * as React from \"react\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nimport { cn } from \"@util/index\";\nimport { Tooltip } from \"../tooltip\";\n\nexport type LabelProps = {\n hint?: React.ReactNode;\n hintSide?: PositionType;\n htmlFor?: string;\n required?: boolean;\n};\n\nconst Label = React.forwardRef<\n HTMLLabelElement,\n React.LabelHTMLAttributes<HTMLLabelElement> & LabelProps\n>(({ className, hint, hintSide, required, children, ...props }, ref) => (\n <div className=\"hawa-flex hawa-flex-row hawa-items-center hawa-gap-1 hawa-transition-all\">\n <label\n ref={ref}\n className={cn(\n \"hawa-text-sm hawa-font-medium hawa-leading-none peer-disabled:hawa-cursor-not-allowed peer-disabled:hawa-opacity-70\",\n className\n )}\n {...props}\n >\n {children}\n {required && <span className=\"hawa-mx-0.5 hawa-text-red-500\">*</span>}\n </label>\n {hint && (\n <Tooltip\n content={hint}\n side={hintSide}\n triggerProps={{\n tabIndex: -1,\n onClick: (event) => event.preventDefault()\n }}\n >\n <div>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"hawa-h-[14px] hawa-w-[14px] hawa-cursor-help\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3\" />\n <path d=\"M12 17h.01\" />\n </svg>\n </div>\n </Tooltip>\n )}\n </div>\n));\n\nLabel.displayName = \"Label\";\n\nexport { Label };\n","import React from \"react\";\n\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport { cn } from \"@util/index\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {\n size?: \"default\" | \"small\" | \"large\";\n }\n>(({ className, sideOffset = 4, size = \"default\", ...props }, ref) => (\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"hawa-z-50 hawa-overflow-hidden hawa-rounded-md hawa-border hawa-bg-popover hawa-px-3 hawa-py-1.5 hawa-text-sm hawa-text-popover-foreground hawa-shadow-md hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=closed]:hawa-zoom-out-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2\",\n {\n \"hawa-text-xs\": size === \"small\",\n \"hawa-text-xl\": size === \"large\"\n },\n className\n )}\n {...props}\n />\n));\nTooltipContent.displayName = TooltipPrimitive.Content.displayName;\n\nconst TooltipArrow = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Arrow>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Arrow>\n>(({ className, ...props }, ref) => (\n <TooltipPrimitive.Arrow ref={ref} className={cn(className)} {...props} />\n));\nTooltipArrow.displayName = TooltipPrimitive.Arrow.displayName;\n\ntype TooltipTypes = {\n /** Controls the open state of the tooltip. */\n open?: any;\n /** Specifies the side where the tooltip will appear. */\n side?: PositionType;\n /** Content to be displayed within the tooltip. */\n content?: any;\n /** Elements to which the tooltip is anchored. */\n children?: any;\n /** Sets the default open state of the tooltip. */\n defaultOpen?: any;\n /** Event handler for open state changes. */\n onOpenChange?: any;\n /** Duration of the delay before the tooltip appears. */\n delayDuration?: any;\n /** Size of the tooltip. */\n size?: \"default\" | \"small\" | \"large\";\n /** Disables the tooltip. */\n disabled?: boolean;\n triggerProps?: TooltipPrimitive.TooltipTriggerProps;\n contentProps?: TooltipPrimitive.TooltipContentProps;\n providerProps?: TooltipPrimitive.TooltipProviderProps;\n};\n\nconst Tooltip: React.FunctionComponent<TooltipTypes> = ({\n side,\n size,\n open,\n content,\n children,\n disabled,\n defaultOpen,\n onOpenChange,\n triggerProps,\n contentProps,\n providerProps,\n delayDuration = 300,\n ...props\n}) => {\n return (\n <TooltipPrimitive.TooltipProvider\n delayDuration={delayDuration}\n {...providerProps}\n >\n <TooltipPrimitive.Root\n open={!disabled && open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n {...props}\n >\n <TooltipPrimitive.Trigger {...triggerProps}>\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipContent\n size={size}\n side={side}\n align=\"center\"\n {...contentProps}\n style={{\n ...contentProps?.style,\n maxWidth: \"var(--radix-tooltip-content-available-width)\",\n maxHeight: \"var(--radix-tooltip-content-available-height)\"\n }}\n >\n {content}\n </TooltipContent>\n </TooltipPrimitive.Root>\n </TooltipPrimitive.TooltipProvider>\n );\n};\n\nexport { Tooltip };\n","import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ninterface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n animation?: \"none\" | \"pulse\" | \"shimmer\";\n content?: any;\n fade?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}\n\nfunction Skeleton({\n className,\n content,\n animation = \"pulse\",\n fade,\n ...props\n}: SkeletonProps) {\n const animationStyles = {\n none: \"hawa-rounded hawa-bg-muted\",\n pulse: \"hawa-animate-pulse hawa-rounded hawa-bg-muted\",\n shimmer:\n \"hawa-space-y-5 hawa-rounded hawa-bg-muted hawa-p-4 hawa-relative before:hawa-absolute before:hawa-inset-0 before:hawa--translate-x-full before:hawa-animate-[shimmer_2s_infinite] before:hawa-bg-gradient-to-r before:hawa-from-transparent before:hawa-via-gray-300/40 dark:before:hawa-via-white/10 before:hawa-to-transparent hawa-isolate hawa-overflow-hidden before:hawa-border-t before:hawa-border-rose-100/10\",\n };\n const fadeStyle = {\n bottom: \"hawa-mask-fade-bottom\",\n top: \"hawa-mask-fade-top\",\n right: \"hawa-mask-fade-right\",\n left: \"hawa-mask-fade-left \",\n };\n\n return (\n <div\n className={cn(\n animationStyles[animation],\n content &&\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n fade && fadeStyle[fade],\n className,\n )}\n {...props}\n >\n {content && content}\n </div>\n );\n}\n\nexport { Skeleton };\n"],"mappings":";;;AAAA,OAAOA,YAAmB;AAC1B,OAAO,iBAAgC;AACvC,OAAO,qBAAqB;;;ACF5B,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADAA,OAAOC,WAAU;;;AELjB,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,OAAO,CACxE;AACD,aAAa,cAA+B,uBAAM;AA0BlD,IAAM,UAAiD,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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AgB,MAAM;AAAA,QACtB,UAAU,CAAC,UAAU,WAAW,MAAM,SAAS,UAAU,MAAM;AAAA,QAC/D,YAAY,EAAE,SAAS,QAAQ,KAAK;AAAA,QACpC,eAAe,CAAC,UAAU,WACxB,MAAM,cAAc,UAAU,MAAM;AAAA;AAAA,IAExC;AAAA,IAED,CAAC,MAAM,kBACN,gBAAAA,OAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,MAAM,aACF,8BACA;AAAA,QACN;AAAA;AAAA,MAEC,MAAM;AAAA,IACT;AAAA,EAEJ;AAEJ;","names":["React","clsx","React","React","React","React","clsx"]}
|
1
|
+
{"version":3,"sources":["../../elements/select/Select.tsx","../../util/index.ts","../../elements/label/Label.tsx","../../elements/tooltip/Tooltip.tsx","../../elements/skeleton/Skeleton.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport ReactSelect, { MenuProps } from \"react-select\";\nimport CreatableSelect from \"react-select/creatable\";\n\nimport { cn } from \"@util/index\";\nimport clsx from \"clsx\";\n\nimport { Label, LabelProps } from \"../label\";\nimport { Skeleton } from \"../skeleton\";\n\ntype ControlTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\n// The options container\ntype MenuTypes = MenuProps & {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n};\n\n// The single options\ntype OptionTypes = {\n cx: any;\n children: any;\n getStyles: any;\n innerProps: any;\n innerRef: any;\n size?: \"small\" | \"normal\" | \"large\";\n};\n\nexport type SelectOptionProps = {\n value: any;\n label: any;\n};\n\ntype SelectTypes = {\n label?: string;\n hideHelperText?: boolean;\n options: SelectOptionProps[];\n labelKey?: string;\n isCreatable?: boolean;\n isClearable?: boolean;\n isMulti?: boolean;\n isSearchable?: boolean;\n controlClassNames?: string;\n containerClassNames?: string;\n onChange: any;\n helperText?: string;\n onInputChange?: any;\n native?: any;\n width?: \"full\" | \"small\" | \"fit\";\n value?: any;\n children?: any;\n getOptionLabel?: any;\n disabled?: boolean;\n defaultValue?: any;\n handleCreateOption?: () => void;\n placeholder?: string;\n hideIndicator?: boolean;\n phoneCode?: boolean;\n isLoading?: any;\n labelProps?: LabelProps;\n texts?: {\n noOptions?: string;\n createLabel?: string;\n };\n};\n\nexport const Select: FC<SelectTypes> = ({\n labelProps,\n labelKey = \"label\",\n ...props\n}) => {\n const NoOption = () => {\n return <div>{props.texts?.noOptions ?? \"No Items Found\"}</div>;\n };\n const Control: FC<ControlTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={clsx(\n \"hawa-flex hawa-w-full hawa-rounded hawa-border hawa-bg-background hawa-p-2 hawa-text-sm hawa-text-gray-900 focus:hawa-border-blue-500 focus:hawa-ring-blue-500 dark:focus:hawa-ring-blue-500\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Option: FC<OptionTypes> = ({ children, innerProps, innerRef }) => {\n return (\n <div\n ref={innerRef}\n className={cn(\n \"hawa-flex hawa-cursor-pointer hawa-select-none hawa-flex-row hawa-items-center hawa-justify-between hawa-rounded-inner hawa-p-1 hawa-px-2 hawa-transition-all hover:hawa-bg-primary hover:hawa-text-primary-foreground\",\n )}\n {...innerProps}\n >\n {children}\n </div>\n );\n };\n const Menu: FC<MenuTypes> = ({\n cx,\n children,\n getStyles,\n innerProps,\n innerRef,\n ...menuProps\n }) => {\n const menuOpen = menuProps.selectProps.menuIsOpen;\n return (\n <div\n className={cn(\n \"dark:dark-shadow hawa-absolute hawa-z-10 -hawa-mx-1 hawa-mt-1 hawa-flex hawa-flex-col hawa-justify-start hawa-rounded hawa-border hawa-bg-background hawa-shadow-md\",\n props.phoneCode ? \"hawa-p-1.5\" : \"hawa-w-full hawa-p-1.5\",\n menuOpen && \"hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 \",\n )}\n ref={innerRef}\n {...innerProps}\n // {...props}\n >\n {children}\n </div>\n );\n };\n\n let phoneCodeStyles =\n \"hawa-min-w-[65px] hawa-text-right hawa-w-[100px] hawa-p-0 hawa-rounded-r-none hawa-h-[40px]\";\n let selectContainerStyles =\n \"hawa-rounded hawa-block hawa-w-full hawa-border hawa-transition-all hawa-bg-background hawa-p-0 hawa-px-1 hawa-text-sm\";\n let selectPlaceholderStyles =\n \"hawa-text-muted-foreground hawa-cursor-pointer hawa-px-1\";\n let selectIndicatorContainerStyles =\n \"hawa-cursor-pointer hawa-text-muted-foreground hawa-absolute hawa-end-0 hawa-top-[50%] hawa-bottom-[50%] \";\n return (\n <div\n className={cn(\n \"hawa-flex hawa-flex-col hawa-gap-2\",\n props.width === \"fit\" ? \"hawa-w-fit\" : \"hawa-w-full\",\n )}\n >\n {props.label && <Label {...labelProps}>{props.label}</Label>}\n {props.isLoading ? (\n <Skeleton className=\"hawa-h-[40px] hawa-w-full\" />\n ) : !props.isCreatable ? (\n // TODO: enable keyboard to go to the next item in the list\n <ReactSelect\n noOptionsMessage={NoOption}\n classNames={{\n control: () =>\n cn(\n props.phoneCode && \"hawa-rounded-r-none\",\n props.controlClassNames,\n ),\n container: () =>\n cn(\n selectContainerStyles,\n props.phoneCode && phoneCodeStyles,\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n props.isMulti && \"hawa-ps-0 \",\n ),\n placeholder: () => selectPlaceholderStyles,\n valueContainer: () => \"hawa-text-foreground hawa-px-1 \",\n singleValue: () => \"hawa-text-foreground\",\n indicatorsContainer: () =>\n cn(\n selectIndicatorContainerStyles,\n props.hideIndicator ? \"hawa-invisible\" : \"hawa-px-1\",\n ),\n }}\n unstyled\n autoFocus={false}\n components={\n props.hideIndicator\n ? { Option, Menu, IndicatorsContainer: () => null }\n : {\n Option,\n Menu,\n // Control: (e) => (\n // <div\n // className={cn(e.className, \"hawa-flex hawa-flex-row\")}\n // {...e}\n // />\n // ),\n\n ValueContainer: (e) => (\n <div\n className={cn(\n e.className,\n \"hawa-gap-1 hawa-flex hawa-flex-row hawa-flex-wrap hawa-p-1\",\n )}\n {...e}\n />\n ),\n MultiValueContainer: (e) => (\n <div\n className=\"hawa-rounded hawa-border hawa-p-1 hawa-px-2 hawa-flex hawa-flex-row\"\n {...e}\n />\n ),\n }\n }\n onChange={(newValue: any, action) => props.onChange(newValue, action)}\n options={props.options}\n getOptionLabel={props.getOptionLabel}\n defaultValue={props.defaultValue}\n placeholder={props.placeholder}\n isDisabled={props.disabled}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n />\n ) : (\n <CreatableSelect\n formatCreateLabel={(inputValue) =>\n `${props.texts?.createLabel ?? \"Create\"} \"${inputValue}\"`\n }\n classNames={{\n container: () =>\n cn(\n \"hawa-rounded\",\n props.disabled\n ? \"hawa-cursor-not-allowed\"\n : \"hawa-cursor-pointer\",\n ),\n placeholder: () => \"hawa-px-2 hawa-text-muted-foreground\",\n input: () => \"hawa-text-primary hawa-px-2\",\n valueContainer: () =>\n \"hawa-text-white dark:hawa-text-muted-foreground\",\n singleValue: () => \"hawa-text-black dark:hawa-text-white hawa-px-2\",\n indicatorsContainer: () =>\n \" hawa-px-2 hawa-cursor-pointer hawa-text-muted-foreground\",\n }}\n unstyled\n options={props.options}\n isClearable={props.isClearable}\n isMulti={props.isMulti}\n isSearchable={props.isSearchable}\n placeholder={props.placeholder}\n onCreateOption={props.handleCreateOption}\n onChange={(newValue, action) => props.onChange(newValue, action)}\n components={{ Control, Option, Menu }}\n onInputChange={(newValue, action) =>\n props.onInputChange(newValue, action)\n }\n />\n )}\n {!props.hideHelperText && (\n <p\n className={cn(\n \"hawa-my-0 hawa-text-start hawa-text-xs hawa-text-helper-color hawa-transition-all\",\n props.helperText\n ? \"hawa-h-4 hawa-opacity-100\"\n : \"hawa-h-0 hawa-opacity-0\",\n )}\n >\n {props.helperText}\n </p>\n )}\n </div>\n );\n};\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\ntype Palette = {\n name: string;\n colors: {\n [key: number]: string;\n };\n};\ntype Rgb = {\n r: number;\n g: number;\n b: number;\n};\nfunction hexToRgb(hex: string): Rgb | null {\n const sanitizedHex = hex.replaceAll(\"##\", \"#\");\n const colorParts = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(\n sanitizedHex\n );\n\n if (!colorParts) {\n return null;\n }\n\n const [, r, g, b] = colorParts;\n\n return {\n r: parseInt(r, 16),\n g: parseInt(g, 16),\n b: parseInt(b, 16)\n } as Rgb;\n}\n\nfunction rgbToHex(r: number, g: number, b: number): string {\n const toHex = (c: number) => `0${c.toString(16)}`.slice(-2);\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\nexport function getTextColor(color: string): \"#FFF\" | \"#333\" {\n const rgbColor = hexToRgb(color);\n\n if (!rgbColor) {\n return \"#333\";\n }\n\n const { r, g, b } = rgbColor;\n const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n return luma < 120 ? \"#FFF\" : \"#333\";\n}\n\nfunction lighten(hex: string, intensity: number): string {\n const color = hexToRgb(`#${hex}`);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r + (255 - color.r) * intensity);\n const g = Math.round(color.g + (255 - color.g) * intensity);\n const b = Math.round(color.b + (255 - color.b) * intensity);\n\n return rgbToHex(r, g, b);\n}\n\nfunction darken(hex: string, intensity: number): string {\n const color = hexToRgb(hex);\n\n if (!color) {\n return \"\";\n }\n\n const r = Math.round(color.r * intensity);\n const g = Math.round(color.g * intensity);\n const b = Math.round(color.b * intensity);\n\n return rgbToHex(r, g, b);\n}\nconst parseColor = (color: any) => {\n if (color.startsWith(\"#\")) {\n // Convert hex to RGB\n let r = parseInt(color.slice(1, 3), 16);\n let g = parseInt(color.slice(3, 5), 16);\n let b = parseInt(color.slice(5, 7), 16);\n return [r, g, b];\n } else if (color.startsWith(\"rgb\")) {\n // Extract RGB values from rgb() format\n return color.match(/\\d+/g).map(Number);\n }\n // Default to white if format is unrecognized\n return [255, 255, 255];\n};\nexport const calculateLuminance = (color: any) => {\n const [r, g, b] = parseColor(color)?.map((c: any) => {\n c /= 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nfunction getPallette(baseColor: string): Palette {\n const name = baseColor;\n\n const response: Palette = {\n name,\n colors: {\n 500: `#${baseColor}`.replace(\"##\", \"#\")\n }\n };\n\n const intensityMap: {\n [key: number]: number;\n } = {\n 50: 0.95,\n 100: 0.9,\n 200: 0.75,\n 300: 0.6,\n 400: 0.3,\n 600: 0.9,\n 700: 0.75,\n 800: 0.6,\n 900: 0.49\n };\n\n [50, 100, 200, 300, 400].forEach((level) => {\n response.colors[level] = lighten(baseColor, intensityMap[level]);\n });\n [600, 700, 800, 900].forEach((level) => {\n response.colors[level] = darken(baseColor, intensityMap[level]);\n });\n\n return response as Palette;\n}\n\nexport { getPallette };\n\n// const hexToRgb = (hex) => {\n// let d = hex?.split(\"#\")[1];\n// var aRgbHex = d?.match(/.{1,2}/g);\n// var aRgb = [\n// parseInt(aRgbHex[0], 16),\n// parseInt(aRgbHex[1], 16),\n// parseInt(aRgbHex[2], 16)\n// ];\n// return aRgb;\n// };\n// const getTextColor = (backColor) => {\n// let rgbArray = hexToRgb(backColor);\n// if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {\n// return \"#000000\";\n// } else {\n// return \"#ffffff\";\n// }\n// };\n// const replaceAt = function (string, index, replacement) {\n// // if (replacement == \"\" || replacement == \" \") {\n// // return (\n// // string.substring(0, index) +\n// // string.substring(index + replacement.length )\n// // );\n// // }\n// const replaced = string.substring(0, index) + replacement + string.substring(index + 1)\n// return replaced\n// };\n\n// export { hexToRgb, getTextColor, replaceAt };\n","import * as React from \"react\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nimport { cn } from \"@util/index\";\nimport { Tooltip } from \"../tooltip\";\n\nexport type LabelProps = {\n hint?: React.ReactNode;\n hintSide?: PositionType;\n htmlFor?: string;\n required?: boolean;\n};\n\nconst Label = React.forwardRef<\n HTMLLabelElement,\n React.LabelHTMLAttributes<HTMLLabelElement> & LabelProps\n>(({ className, hint, hintSide, required, children, ...props }, ref) => (\n <div className=\"hawa-flex hawa-flex-row hawa-items-center hawa-gap-1 hawa-transition-all\">\n <label\n ref={ref}\n className={cn(\n \"hawa-text-sm hawa-font-medium hawa-leading-none peer-disabled:hawa-cursor-not-allowed peer-disabled:hawa-opacity-70\",\n className\n )}\n {...props}\n >\n {children}\n {required && <span className=\"hawa-mx-0.5 hawa-text-red-500\">*</span>}\n </label>\n {hint && (\n <Tooltip\n content={hint}\n side={hintSide}\n triggerProps={{\n tabIndex: -1,\n onClick: (event) => event.preventDefault()\n }}\n >\n <div>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"hawa-h-[14px] hawa-w-[14px] hawa-cursor-help\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3\" />\n <path d=\"M12 17h.01\" />\n </svg>\n </div>\n </Tooltip>\n )}\n </div>\n));\n\nLabel.displayName = \"Label\";\n\nexport { Label };\n","import React from \"react\";\n\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport { cn } from \"@util/index\";\n\nimport { PositionType } from \"@_types/commonTypes\";\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {\n size?: \"default\" | \"small\" | \"large\";\n }\n>(({ className, sideOffset = 4, size = \"default\", ...props }, ref) => (\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"hawa-z-50 hawa-overflow-hidden hawa-rounded-md hawa-border hawa-bg-popover hawa-px-3 hawa-py-1.5 hawa-text-sm hawa-text-popover-foreground hawa-shadow-md hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=closed]:hawa-zoom-out-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2\",\n {\n \"hawa-text-xs\": size === \"small\",\n \"hawa-text-xl\": size === \"large\"\n },\n className\n )}\n {...props}\n />\n));\nTooltipContent.displayName = TooltipPrimitive.Content.displayName;\n\nconst TooltipArrow = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Arrow>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Arrow>\n>(({ className, ...props }, ref) => (\n <TooltipPrimitive.Arrow ref={ref} className={cn(className)} {...props} />\n));\nTooltipArrow.displayName = TooltipPrimitive.Arrow.displayName;\n\ntype TooltipTypes = {\n /** Controls the open state of the tooltip. */\n open?: any;\n /** Specifies the side where the tooltip will appear. */\n side?: PositionType;\n /** Content to be displayed within the tooltip. */\n content?: any;\n /** Elements to which the tooltip is anchored. */\n children?: any;\n /** Sets the default open state of the tooltip. */\n defaultOpen?: any;\n /** Event handler for open state changes. */\n onOpenChange?: any;\n /** Duration of the delay before the tooltip appears. */\n delayDuration?: any;\n /** Size of the tooltip. */\n size?: \"default\" | \"small\" | \"large\";\n /** Disables the tooltip. */\n disabled?: boolean;\n triggerProps?: TooltipPrimitive.TooltipTriggerProps;\n contentProps?: TooltipPrimitive.TooltipContentProps;\n providerProps?: TooltipPrimitive.TooltipProviderProps;\n};\n\nconst Tooltip: React.FunctionComponent<TooltipTypes> = ({\n side,\n size,\n open,\n content,\n children,\n disabled,\n defaultOpen,\n onOpenChange,\n triggerProps,\n contentProps,\n providerProps,\n delayDuration = 300,\n ...props\n}) => {\n return (\n <TooltipPrimitive.TooltipProvider\n delayDuration={delayDuration}\n {...providerProps}\n >\n <TooltipPrimitive.Root\n open={!disabled && open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n {...props}\n >\n <TooltipPrimitive.Trigger {...triggerProps}>\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipContent\n size={size}\n side={side}\n align=\"center\"\n {...contentProps}\n style={{\n ...contentProps?.style,\n maxWidth: \"var(--radix-tooltip-content-available-width)\",\n maxHeight: \"var(--radix-tooltip-content-available-height)\"\n }}\n >\n {content}\n </TooltipContent>\n </TooltipPrimitive.Root>\n </TooltipPrimitive.TooltipProvider>\n );\n};\n\nexport { Tooltip };\n","import React from \"react\";\n\nimport { cn } from \"@util/index\";\n\ninterface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n animation?: \"none\" | \"pulse\" | \"shimmer\";\n content?: any;\n fade?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}\n\nfunction Skeleton({\n className,\n content,\n animation = \"pulse\",\n fade,\n ...props\n}: SkeletonProps) {\n const animationStyles = {\n none: \"hawa-rounded hawa-bg-muted\",\n pulse: \"hawa-animate-pulse hawa-rounded hawa-bg-muted\",\n shimmer:\n \"hawa-space-y-5 hawa-rounded hawa-bg-muted hawa-p-4 hawa-relative before:hawa-absolute before:hawa-inset-0 before:hawa--translate-x-full before:hawa-animate-[shimmer_2s_infinite] before:hawa-bg-gradient-to-r before:hawa-from-transparent before:hawa-via-gray-300/40 dark:before:hawa-via-white/10 before:hawa-to-transparent hawa-isolate hawa-overflow-hidden before:hawa-border-t before:hawa-border-rose-100/10\",\n };\n const fadeStyle = {\n bottom: \"hawa-mask-fade-bottom\",\n top: \"hawa-mask-fade-top\",\n right: \"hawa-mask-fade-right\",\n left: \"hawa-mask-fade-left \",\n };\n\n return (\n <div\n className={cn(\n animationStyles[animation],\n content &&\n \"hawa-flex hawa-flex-col hawa-items-center hawa-justify-center\",\n fade && fadeStyle[fade],\n className,\n )}\n {...props}\n >\n {content && content}\n </div>\n );\n}\n\nexport { Skeleton };\n"],"mappings":";;;AAAA,OAAOA,YAAmB;AAC1B,OAAO,iBAAgC;AACvC,OAAO,qBAAqB;;;ACF5B,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADAA,OAAOC,WAAU;;;AELjB,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,OAAO,CACxE;AACD,aAAa,cAA+B,uBAAM;AA0BlD,IAAM,UAAiD,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,GAAG;AACL,MAAM;AACJ,SACE;AAAA,IAAkB;AAAA,IAAjB;AAAA,MACC;AAAA,MACC,GAAG;AAAA;AAAA,IAEJ;AAAA,MAAkB;AAAA,MAAjB;AAA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A;AAAA,IAExC;AAAA,IAED,CAAC,MAAM,kBACN,gBAAAA,OAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,MAAM,aACF,8BACA;AAAA,QACN;AAAA;AAAA,MAEC,MAAM;AAAA,IACT;AAAA,EAEJ;AAEJ;","names":["React","clsx","React","React","React","React","clsx"]}
|
package/dist/tabs/index.d.mts
CHANGED
@@ -24,7 +24,9 @@ type TabsVariants = "default" | "underlined" | "underlined_tabs";
|
|
24
24
|
declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
25
25
|
variant?: TabsVariants | undefined;
|
26
26
|
} & React.RefAttributes<HTMLDivElement>>;
|
27
|
-
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> &
|
27
|
+
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
28
|
+
scrollable?: boolean | undefined;
|
29
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
28
30
|
declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & {
|
29
31
|
chipProps?: ChipTypes | undefined;
|
30
32
|
className?: string | undefined;
|
package/dist/tabs/index.d.ts
CHANGED
@@ -24,7 +24,9 @@ type TabsVariants = "default" | "underlined" | "underlined_tabs";
|
|
24
24
|
declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
25
25
|
variant?: TabsVariants | undefined;
|
26
26
|
} & React.RefAttributes<HTMLDivElement>>;
|
27
|
-
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> &
|
27
|
+
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
28
|
+
scrollable?: boolean | undefined;
|
29
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
28
30
|
declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & {
|
29
31
|
chipProps?: ChipTypes | undefined;
|
30
32
|
className?: string | undefined;
|
package/dist/tabs/index.js
CHANGED
@@ -39,7 +39,7 @@ __export(tabs_exports, {
|
|
39
39
|
module.exports = __toCommonJS(tabs_exports);
|
40
40
|
|
41
41
|
// elements/tabs/Tabs.tsx
|
42
|
-
var
|
42
|
+
var React12 = __toESM(require("react"));
|
43
43
|
|
44
44
|
// hooks/useIsomorphicEffect.ts
|
45
45
|
var import_react = require("react");
|
@@ -125,6 +125,9 @@ var useMeasureDirty = (ref) => {
|
|
125
125
|
// hooks/useClickOutside.ts
|
126
126
|
var import_react16 = require("react");
|
127
127
|
|
128
|
+
// hooks/useShortcuts.ts
|
129
|
+
var import_react17 = require("react");
|
130
|
+
|
128
131
|
// elements/tabs/Tabs.tsx
|
129
132
|
var TabsPrimitive = __toESM(require("@radix-ui/react-tabs"));
|
130
133
|
|
@@ -139,8 +142,8 @@ function cn(...inputs) {
|
|
139
142
|
var import_tailwind_variants = require("tailwind-variants");
|
140
143
|
|
141
144
|
// elements/chip/Chip.tsx
|
142
|
-
var
|
143
|
-
var Chip =
|
145
|
+
var import_react18 = __toESM(require("react"));
|
146
|
+
var Chip = import_react18.default.forwardRef(
|
144
147
|
({
|
145
148
|
label,
|
146
149
|
size = "normal",
|
@@ -184,7 +187,7 @@ var Chip = import_react17.default.forwardRef(
|
|
184
187
|
oceanic: "hawa-text-white dark:hawa-text-black hawa-bg-gradient-to-bl hawa-from-green-300 hawa-via-blue-500 hawa-to-purple-600"
|
185
188
|
};
|
186
189
|
if (label) {
|
187
|
-
return /* @__PURE__ */
|
190
|
+
return /* @__PURE__ */ import_react18.default.createElement(
|
188
191
|
"span",
|
189
192
|
{
|
190
193
|
...rest,
|
@@ -196,7 +199,7 @@ var Chip = import_react17.default.forwardRef(
|
|
196
199
|
color ? colorStyles[color] : "hawa-border hawa-bg-none"
|
197
200
|
)
|
198
201
|
},
|
199
|
-
dot && /* @__PURE__ */
|
202
|
+
dot && /* @__PURE__ */ import_react18.default.createElement(
|
200
203
|
"span",
|
201
204
|
{
|
202
205
|
className: cn(dotStyles[size], dotStatusStyles[dotStatus])
|
@@ -206,7 +209,7 @@ var Chip = import_react17.default.forwardRef(
|
|
206
209
|
label
|
207
210
|
);
|
208
211
|
} else {
|
209
|
-
return /* @__PURE__ */
|
212
|
+
return /* @__PURE__ */ import_react18.default.createElement(
|
210
213
|
"span",
|
211
214
|
{
|
212
215
|
...rest,
|
@@ -276,14 +279,137 @@ var FloatBox = ({
|
|
276
279
|
);
|
277
280
|
};
|
278
281
|
|
282
|
+
// elements/scrollArea/ScrollArea.tsx
|
283
|
+
var React11 = __toESM(require("react"));
|
284
|
+
var ScrollAreaPrimitive = __toESM(require("@radix-ui/react-scroll-area"));
|
285
|
+
var ScrollArea = React11.forwardRef(({ className, children, orientation = "vertical", ...props }, ref) => {
|
286
|
+
const scrollAreaRef = React11.useRef(null);
|
287
|
+
const isDragging = React11.useRef(false);
|
288
|
+
const startPos = React11.useRef({ x: 0, y: 0 });
|
289
|
+
const scrollPos = React11.useRef({ top: 0, left: 0 });
|
290
|
+
const [showLeftFade, setShowLeftFade] = React11.useState(false);
|
291
|
+
const [showRightFade, setShowRightFade] = React11.useState(false);
|
292
|
+
const checkOverflow = () => {
|
293
|
+
if (scrollAreaRef.current) {
|
294
|
+
const { scrollLeft, scrollWidth, clientWidth } = scrollAreaRef.current;
|
295
|
+
setShowLeftFade(scrollLeft > 0);
|
296
|
+
setShowRightFade(scrollLeft + clientWidth < scrollWidth);
|
297
|
+
}
|
298
|
+
};
|
299
|
+
const onMouseDown = (e) => {
|
300
|
+
isDragging.current = true;
|
301
|
+
startPos.current = { x: e.clientX, y: e.clientY };
|
302
|
+
if (scrollAreaRef.current) {
|
303
|
+
scrollPos.current = {
|
304
|
+
top: scrollAreaRef.current.scrollTop,
|
305
|
+
left: scrollAreaRef.current.scrollLeft
|
306
|
+
};
|
307
|
+
}
|
308
|
+
document.addEventListener("mousemove", onMouseMove);
|
309
|
+
document.addEventListener("mouseup", onMouseUp);
|
310
|
+
};
|
311
|
+
const onMouseMove = (e) => {
|
312
|
+
if (!isDragging.current || !scrollAreaRef.current)
|
313
|
+
return;
|
314
|
+
const dx = e.clientX - startPos.current.x;
|
315
|
+
const dy = e.clientY - startPos.current.y;
|
316
|
+
if (orientation === "vertical") {
|
317
|
+
scrollAreaRef.current.scrollTop = scrollPos.current.top - dy;
|
318
|
+
} else {
|
319
|
+
scrollAreaRef.current.scrollLeft = scrollPos.current.left - dx;
|
320
|
+
checkOverflow();
|
321
|
+
}
|
322
|
+
};
|
323
|
+
const onMouseUp = () => {
|
324
|
+
isDragging.current = false;
|
325
|
+
document.removeEventListener("mousemove", onMouseMove);
|
326
|
+
document.removeEventListener("mouseup", onMouseUp);
|
327
|
+
};
|
328
|
+
React11.useEffect(() => {
|
329
|
+
checkOverflow();
|
330
|
+
if (scrollAreaRef.current) {
|
331
|
+
scrollAreaRef.current.addEventListener("scroll", checkOverflow);
|
332
|
+
window.addEventListener("resize", checkOverflow);
|
333
|
+
}
|
334
|
+
return () => {
|
335
|
+
if (scrollAreaRef.current) {
|
336
|
+
scrollAreaRef.current.removeEventListener("scroll", checkOverflow);
|
337
|
+
}
|
338
|
+
window.removeEventListener("resize", checkOverflow);
|
339
|
+
};
|
340
|
+
}, []);
|
341
|
+
return /* @__PURE__ */ React11.createElement(
|
342
|
+
ScrollAreaPrimitive.Root,
|
343
|
+
{
|
344
|
+
ref,
|
345
|
+
className: cn("hawa-relative hawa-overflow-hidden", className),
|
346
|
+
...props
|
347
|
+
},
|
348
|
+
/* @__PURE__ */ React11.createElement(
|
349
|
+
"div",
|
350
|
+
{
|
351
|
+
className: cn(
|
352
|
+
"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-h-full hawa-w-[50px] hawa-z-10 hawa-start-0 hawa-mask-fade-right",
|
353
|
+
showLeftFade ? "hawa-block" : "hawa-hidden"
|
354
|
+
)
|
355
|
+
}
|
356
|
+
),
|
357
|
+
/* @__PURE__ */ React11.createElement(
|
358
|
+
"div",
|
359
|
+
{
|
360
|
+
className: cn(
|
361
|
+
"hawa-pointer-events-none hawa-absolute hawa-bg-background/ hawa-mask-fade-left hawa-end-0 hawa-h-full hawa-w-[50px] hawa-z-10 ",
|
362
|
+
showRightFade ? "hawa-block" : "hawa-hidden"
|
363
|
+
)
|
364
|
+
}
|
365
|
+
),
|
366
|
+
/* @__PURE__ */ React11.createElement(
|
367
|
+
ScrollAreaPrimitive.Viewport,
|
368
|
+
{
|
369
|
+
ref: scrollAreaRef,
|
370
|
+
className: "hawa-h-full hawa-w-full hawa-rounded-[inherit]",
|
371
|
+
onMouseDown
|
372
|
+
},
|
373
|
+
children
|
374
|
+
),
|
375
|
+
/* @__PURE__ */ React11.createElement(ScrollBar, { orientation }),
|
376
|
+
/* @__PURE__ */ React11.createElement(ScrollAreaPrimitive.Corner, null)
|
377
|
+
);
|
378
|
+
});
|
379
|
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
380
|
+
var ScrollBar = React11.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React11.createElement(
|
381
|
+
ScrollAreaPrimitive.ScrollAreaScrollbar,
|
382
|
+
{
|
383
|
+
ref,
|
384
|
+
orientation,
|
385
|
+
className: cn(
|
386
|
+
"hawa-flex hawa-touch-none hawa-select-none hawa-transition-colors",
|
387
|
+
orientation === "vertical" && "hawa-h-full hawa-w-2.5 hawa-border-l hawa-border-l-transparent hawa-p-[1px]",
|
388
|
+
orientation === "horizontal" && "hawa-h-2.5 hawa-border-t hawa-border-t-transparent hawa-p-[1px]",
|
389
|
+
className
|
390
|
+
),
|
391
|
+
...props
|
392
|
+
},
|
393
|
+
/* @__PURE__ */ React11.createElement(
|
394
|
+
ScrollAreaPrimitive.ScrollAreaThumb,
|
395
|
+
{
|
396
|
+
className: cn(
|
397
|
+
"hawa-relative hawa-rounded-full hawa-bg-border",
|
398
|
+
orientation === "vertical" && "hawa-flex-1"
|
399
|
+
)
|
400
|
+
}
|
401
|
+
)
|
402
|
+
));
|
403
|
+
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
404
|
+
|
279
405
|
// elements/tabs/Tabs.tsx
|
280
406
|
var tabsListVariant = (0, import_tailwind_variants.tv)({
|
281
407
|
base: "",
|
282
408
|
variants: {
|
283
409
|
variant: {
|
284
|
-
default: "hawa-flex hawa-w-fit hawa-
|
285
|
-
underlined: "hawa-flex hawa-w-fit hawa-
|
286
|
-
underlined_tabs: "hawa-flex hawa-w-fit hawa-
|
410
|
+
default: "hawa-flex hawa-w-fit hawa-items-center hawa-justify-start hawa-gap-1 hawa-rounded hawa-border hawa-bg-muted hawa-p-1 hawa-text-muted-foreground dark:hawa-border-primary/10",
|
411
|
+
underlined: "hawa-flex hawa-w-fit hawa-items-center hawa-justify-start hawa-gap-1 hawa-rounded hawa-p-1 hawa-text-muted-foreground dark:hawa-border-primary/10",
|
412
|
+
underlined_tabs: "hawa-flex hawa-w-fit hawa-items-center hawa-justify-start hawa-gap-1 hawa-text-muted-foreground"
|
287
413
|
},
|
288
414
|
orientation: { horizontal: "", vertical: "" }
|
289
415
|
},
|
@@ -335,8 +461,8 @@ var tabsTriggerVariant = (0, import_tailwind_variants.tv)({
|
|
335
461
|
],
|
336
462
|
defaultVariants: { variant: "default", orientation: "horizontal" }
|
337
463
|
});
|
338
|
-
var TabsContext =
|
339
|
-
var Tabs =
|
464
|
+
var TabsContext = React12.createContext({ orientation: "horizontal", variant: "default" });
|
465
|
+
var Tabs = React12.forwardRef(({ className, orientation, variant = "default", ...props }, ref) => /* @__PURE__ */ React12.createElement(
|
340
466
|
TabsPrimitive.Root,
|
341
467
|
{
|
342
468
|
ref,
|
@@ -347,28 +473,59 @@ var Tabs = React11.forwardRef(({ className, orientation, variant = "default", ..
|
|
347
473
|
),
|
348
474
|
...props
|
349
475
|
},
|
350
|
-
/* @__PURE__ */
|
476
|
+
/* @__PURE__ */ React12.createElement(TabsContext.Provider, { value: { orientation, variant } }, props.children)
|
351
477
|
));
|
352
|
-
var TabsList =
|
353
|
-
const { orientation, variant } =
|
354
|
-
|
355
|
-
|
356
|
-
{
|
357
|
-
ref,
|
358
|
-
className: cn(
|
359
|
-
tabsListVariant({ variant, orientation }),
|
360
|
-
orientation === "vertical" ? "hawa-flex-col" : "hawa-flex-row",
|
361
|
-
className
|
362
|
-
),
|
363
|
-
...props
|
364
|
-
}
|
478
|
+
var TabsList = React12.forwardRef(({ className, ...props }, ref) => {
|
479
|
+
const { orientation, variant } = React12.useContext(TabsContext);
|
480
|
+
const [size, setSize] = React12.useState(
|
481
|
+
typeof window !== "undefined" && window.innerWidth || 1200
|
365
482
|
);
|
483
|
+
React12.useEffect(() => {
|
484
|
+
if (typeof window !== "undefined") {
|
485
|
+
const resize = () => {
|
486
|
+
setSize(window.innerWidth);
|
487
|
+
};
|
488
|
+
resize();
|
489
|
+
window.addEventListener("resize", resize);
|
490
|
+
return () => {
|
491
|
+
window.removeEventListener("resize", resize);
|
492
|
+
};
|
493
|
+
}
|
494
|
+
}, []);
|
495
|
+
if ((props.scrollable || size < 768) && orientation === "horizontal") {
|
496
|
+
return /* @__PURE__ */ React12.createElement(ScrollArea, { orientation: "horizontal" }, /* @__PURE__ */ React12.createElement(
|
497
|
+
TabsPrimitive.List,
|
498
|
+
{
|
499
|
+
ref,
|
500
|
+
className: cn(
|
501
|
+
tabsListVariant({ variant, orientation }),
|
502
|
+
"hawa-flex-row hawa-flex-nowrap",
|
503
|
+
className
|
504
|
+
),
|
505
|
+
...props
|
506
|
+
}
|
507
|
+
));
|
508
|
+
} else {
|
509
|
+
return /* @__PURE__ */ React12.createElement(
|
510
|
+
TabsPrimitive.List,
|
511
|
+
{
|
512
|
+
ref,
|
513
|
+
className: cn(
|
514
|
+
tabsListVariant({ variant, orientation }),
|
515
|
+
orientation === "vertical" ? "hawa-flex-col" : "hawa-flex-row",
|
516
|
+
"hawa-flex-wrap",
|
517
|
+
className
|
518
|
+
),
|
519
|
+
...props
|
520
|
+
}
|
521
|
+
);
|
522
|
+
}
|
366
523
|
});
|
367
|
-
var TabsTrigger =
|
368
|
-
const { orientation, variant } =
|
369
|
-
const tabTriggerRef =
|
524
|
+
var TabsTrigger = React12.forwardRef(({ className, chipProps, ...props }, ref) => {
|
525
|
+
const { orientation, variant } = React12.useContext(TabsContext);
|
526
|
+
const tabTriggerRef = React12.useRef(null);
|
370
527
|
const { width } = useMeasureDirty(tabTriggerRef);
|
371
|
-
return /* @__PURE__ */
|
528
|
+
return /* @__PURE__ */ React12.createElement(
|
372
529
|
TabsPrimitive.Trigger,
|
373
530
|
{
|
374
531
|
ref: tabTriggerRef,
|
@@ -380,8 +537,8 @@ var TabsTrigger = React11.forwardRef(({ className, chipProps, ...props }, ref) =
|
|
380
537
|
...props
|
381
538
|
},
|
382
539
|
props.children,
|
383
|
-
chipProps && /* @__PURE__ */
|
384
|
-
/* @__PURE__ */
|
540
|
+
chipProps && /* @__PURE__ */ React12.createElement(Chip, { ...chipProps }),
|
541
|
+
/* @__PURE__ */ React12.createElement(
|
385
542
|
FloatBox,
|
386
543
|
{
|
387
544
|
withArrow: true,
|
@@ -394,7 +551,7 @@ var TabsTrigger = React11.forwardRef(({ className, chipProps, ...props }, ref) =
|
|
394
551
|
)
|
395
552
|
);
|
396
553
|
});
|
397
|
-
var TabsContent =
|
554
|
+
var TabsContent = React12.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React12.createElement(
|
398
555
|
TabsPrimitive.Content,
|
399
556
|
{
|
400
557
|
ref,
|