@deckai/deck-ui 0.0.10 → 0.0.13
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/README.md +127 -1
- package/dist/components/AboutCard.cjs +3 -7
- package/dist/components/AboutCard.cjs.map +1 -1
- package/dist/components/AboutCard.d.cts +3 -2
- package/dist/components/AboutCard.d.ts +3 -2
- package/dist/components/AboutCard.js +3 -7
- package/dist/components/AboutCard.js.map +1 -1
- package/dist/components/Avatar.cjs +1 -1
- package/dist/components/Avatar.cjs.map +1 -1
- package/dist/components/Avatar.d.cts +3 -1
- package/dist/components/Avatar.d.ts +3 -1
- package/dist/components/Avatar.js +1 -1
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Badge.cjs +1 -1
- package/dist/components/Badge.cjs.map +1 -1
- package/dist/components/Badge.d.cts +2 -2
- package/dist/components/Badge.d.ts +2 -2
- package/dist/components/Badge.js +1 -1
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs.cjs.map +1 -1
- package/dist/components/Breadcrumbs.js +1 -1
- package/dist/components/Breadcrumbs.js.map +1 -1
- package/dist/components/Button.cjs +3 -7
- package/dist/components/Button.cjs.map +1 -1
- package/dist/components/Button.d.cts +11 -1
- package/dist/components/Button.d.ts +11 -1
- package/dist/components/Button.js +3 -7
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Collapsible.cjs +2 -0
- package/dist/components/Collapsible.cjs.map +1 -0
- package/dist/components/Collapsible.d.cts +12 -0
- package/dist/components/Collapsible.d.ts +12 -0
- package/dist/components/Collapsible.js +2 -0
- package/dist/components/Collapsible.js.map +1 -0
- package/dist/components/Combobox.cjs +1 -1
- package/dist/components/Combobox.cjs.map +1 -1
- package/dist/components/Combobox.d.cts +7 -1
- package/dist/components/Combobox.d.ts +7 -1
- package/dist/components/Combobox.js +1 -1
- package/dist/components/Combobox.js.map +1 -1
- package/dist/components/ContactItem.cjs +1 -1
- package/dist/components/ContactItem.cjs.map +1 -1
- package/dist/components/ContactItem.d.cts +2 -3
- package/dist/components/ContactItem.d.ts +2 -3
- package/dist/components/ContactItem.js +1 -1
- package/dist/components/ContactItem.js.map +1 -1
- package/dist/components/EditButton.cjs +10 -0
- package/dist/components/EditButton.cjs.map +1 -0
- package/dist/components/EditButton.d.cts +12 -0
- package/dist/components/EditButton.d.ts +12 -0
- package/dist/components/EditButton.js +10 -0
- package/dist/components/EditButton.js.map +1 -0
- package/dist/components/Icon.cjs +1 -1
- package/dist/components/Icon.cjs.map +1 -1
- package/dist/components/Icon.d.cts +4 -3
- package/dist/components/Icon.d.ts +4 -3
- package/dist/components/Icon.js +1 -1
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconRenderer.cjs +2 -0
- package/dist/components/IconRenderer.cjs.map +1 -0
- package/dist/components/IconRenderer.d.cts +13 -0
- package/dist/components/IconRenderer.d.ts +13 -0
- package/dist/components/IconRenderer.js +2 -0
- package/dist/components/IconRenderer.js.map +1 -0
- package/dist/components/Illustration.cjs +50 -0
- package/dist/components/Illustration.cjs.map +1 -0
- package/dist/components/Illustration.d.cts +10 -0
- package/dist/components/Illustration.d.ts +10 -0
- package/dist/components/Illustration.js +50 -0
- package/dist/components/Illustration.js.map +1 -0
- package/dist/components/Input.cjs +1 -1
- package/dist/components/Input.cjs.map +1 -1
- package/dist/components/Input.d.cts +6 -2
- package/dist/components/Input.d.ts +6 -2
- package/dist/components/Input.js +1 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Link.cjs +1 -1
- package/dist/components/Link.cjs.map +1 -1
- package/dist/components/Link.d.cts +1 -1
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/Link.js.map +1 -1
- package/dist/components/Logo.cjs +1 -1
- package/dist/components/Logo.cjs.map +1 -1
- package/dist/components/Logo.d.cts +2 -5
- package/dist/components/Logo.d.ts +2 -5
- package/dist/components/Logo.js +1 -1
- package/dist/components/Logo.js.map +1 -1
- package/dist/components/MultiSelectCombobox.cjs +2 -0
- package/dist/components/MultiSelectCombobox.cjs.map +1 -0
- package/dist/components/MultiSelectCombobox.d.cts +21 -0
- package/dist/components/MultiSelectCombobox.d.ts +21 -0
- package/dist/components/MultiSelectCombobox.js +2 -0
- package/dist/components/MultiSelectCombobox.js.map +1 -0
- package/dist/components/Navbar.cjs +2 -2
- package/dist/components/Navbar.cjs.map +1 -1
- package/dist/components/Navbar.d.cts +1 -1
- package/dist/components/Navbar.d.ts +1 -1
- package/dist/components/Navbar.js +2 -2
- package/dist/components/Navbar.js.map +1 -1
- package/dist/components/NavbarItem.cjs +1 -1
- package/dist/components/NavbarItem.cjs.map +1 -1
- package/dist/components/NavbarItem.d.cts +1 -1
- package/dist/components/NavbarItem.d.ts +1 -1
- package/dist/components/NavbarItem.js +1 -1
- package/dist/components/NavbarItem.js.map +1 -1
- package/dist/components/Pressable.cjs +1 -1
- package/dist/components/Pressable.cjs.map +1 -1
- package/dist/components/Pressable.js +1 -1
- package/dist/components/Pressable.js.map +1 -1
- package/dist/components/ProfileCard.cjs +3 -7
- package/dist/components/ProfileCard.cjs.map +1 -1
- package/dist/components/ProfileCard.d.cts +3 -1
- package/dist/components/ProfileCard.d.ts +3 -1
- package/dist/components/ProfileCard.js +3 -7
- package/dist/components/ProfileCard.js.map +1 -1
- package/dist/components/Sidebar.cjs +2 -0
- package/dist/components/Sidebar.cjs.map +1 -0
- package/dist/components/Sidebar.d.cts +37 -0
- package/dist/components/Sidebar.d.ts +37 -0
- package/dist/components/Sidebar.js +2 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/SocialCard.cjs +1 -1
- package/dist/components/SocialCard.cjs.map +1 -1
- package/dist/components/SocialCard.js +1 -1
- package/dist/components/SocialCard.js.map +1 -1
- package/dist/components/Spinner.cjs +2 -0
- package/dist/components/Spinner.cjs.map +1 -0
- package/dist/components/Spinner.d.cts +19 -0
- package/dist/components/Spinner.d.ts +19 -0
- package/dist/components/Spinner.js +2 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Tabs.cjs +1 -1
- package/dist/components/Tabs.cjs.map +1 -1
- package/dist/components/Tabs.js +1 -1
- package/dist/components/Tabs.js.map +1 -1
- package/dist/components/Tag.cjs +1 -1
- package/dist/components/Tag.cjs.map +1 -1
- package/dist/components/Tag.d.cts +4 -2
- package/dist/components/Tag.d.ts +4 -2
- package/dist/components/Tag.js +1 -1
- package/dist/components/Tag.js.map +1 -1
- package/dist/components/Text.cjs +1 -1
- package/dist/components/Text.cjs.map +1 -1
- package/dist/components/Text.d.cts +2 -2
- package/dist/components/Text.d.ts +2 -2
- package/dist/components/Text.js +1 -1
- package/dist/components/Text.js.map +1 -1
- package/dist/components/TextArea.cjs +2 -0
- package/dist/components/TextArea.cjs.map +1 -0
- package/dist/components/TextArea.d.cts +19 -0
- package/dist/components/TextArea.d.ts +19 -0
- package/dist/components/TextArea.js +2 -0
- package/dist/components/TextArea.js.map +1 -0
- package/dist/components/WorkCard.cjs +1 -1
- package/dist/components/WorkCard.cjs.map +1 -1
- package/dist/components/WorkCard.js +1 -1
- package/dist/components/WorkCard.js.map +1 -1
- package/dist/index.cjs +51 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -23
- package/dist/index.d.ts +99 -23
- package/dist/index.js +51 -7
- package/dist/index.js.map +1 -1
- package/dist/styles/styles.css +1 -1
- package/dist/{tailwind-DJFscIlV.d.cts → tailwind-CIZ10fKA.d.cts} +4 -3
- package/dist/{tailwind-DJFscIlV.d.ts → tailwind-CIZ10fKA.d.ts} +4 -3
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts","../../src/components/Icon.tsx","../../src/components/Text.tsx","../../src/utils/tailwind.ts","../../src/components/Link.tsx","../../src/components/Breadcrumbs.tsx"],"names":["cn","inputs","twMerge","clsx","COLOR_MAP","BREAKPOINT_MAP","processSizes","sizes","sizeArray","baseSize","style","mediaQueries","size","acc","breakpoint","value","Icon","React","name","color","title","className","props","ref","IconComponent","IconMap","sizeStyles","HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","fontWeight","processVariants","variants","typographyClass","Text","as","children","weight","typographyClasses","colorClasses","suggestedElement","baseVariant","focusRingStyles","Link","href","DefaultSeparator","Breadcrumbs","items","SeparatorComponent","onHomeClick","renderSeparator","item","index","isLastItem"],"mappings":"sHAGO,SAASA,CAAMC,CAAAA,GAAAA,CAAAA,CAAsB,CAC1C,OAAOC,QAAQC,IAAKF,CAAAA,CAAM,CAAC,CAC7B,CCWA,IAAMG,CAAAA,CAAwC,CAC5C,OAAS,CAAA,SAAA,CACT,UAAW,SACX,CAAA,KAAA,CAAO,UACP,WAAa,CAAA,SACf,CAKMC,CAAAA,CAAAA,CAA6C,CACjD,EAAI,CAAA,2BAAA,CACJ,EAAI,CAAA,2BAAA,CACJ,GAAI,4BACJ,CAAA,EAAA,CAAI,4BACJ,CAAA,KAAA,CAAO,4BACT,CAEMC,CAAAA,CAAAA,CACJC,CACwB,EAAA,CACxB,GAAI,CAACA,CAAAA,CAAO,OAAO,CAAE,MAAO,MAAQ,CAAA,MAAA,CAAQ,MAAO,CAAA,CAEnD,IAAMC,CAAY,CAAA,KAAA,CAAM,OAAQD,CAAAA,CAAK,EAAIA,CAAQ,CAAA,CAACA,CAAK,CACjDE,CAAAA,CAAAA,CAAW,OAAOD,CAAU,CAAA,CAAC,CAAM,EAAA,QAAA,CAAWA,EAAU,CAAC,CAAA,CAAI,EAE7DE,CAAAA,CAAAA,CAA6B,CACjC,KAAO,CAAA,CAAA,EAAGD,CAAQ,CAAA,EAAA,CAAA,CAClB,OAAQ,CAAGA,EAAAA,CAAQ,CACrB,EAAA,CAAA,CAAA,CAGME,EAAeH,CAClB,CAAA,MAAA,CACEI,CACC,EAAA,OAAOA,GAAS,QAAYA,EAAAA,CAAAA,CAAK,QAAS,CAAA,GAAG,CACjD,CACC,CAAA,MAAA,CACC,CAACC,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CAAAA,CAAaD,IAAUL,CAAM,CAAA,MAAA,CAAS,CAE5C,CAAA,OAAOM,GAAc,CAACF,CAAAA,CAAK,IACzBnC,CAAAA,CAAAA,CAAA,cAACkB,CAAA,CAAA,CACC,QAASmB,CAAa,CAAA,uBAAA,CAA0B,eAChD,KAAOA,CAAAA,CAAAA,CAAa,cAAiB,CAAA,gBAAA,CACrC,eAAcA,CAAa,CAAA,MAAA,CAAS,KACpC,CAAA,CAAA,GAAA,CAAKF,EAAK,KAETA,CAAAA,CAAAA,CAAAA,CAAK,KACR,CAAA,CAEAnC,EAAA,aAAAA,CAAAA,CAAAA,CAAA,QACEA,CAAAA,IAAAA,CAAAA,CAAAA,CAAA,cAAC2B,CAAA,CAAA,CAAK,IAAMQ,CAAAA,CAAAA,CAAK,KAAM,GAAKA,CAAAA,CAAAA,CAAK,KAC9BA,CAAAA,CAAAA,CAAAA,CAAK,KACR,CACCD,CAAAA,CAAAA,EACH,CAEJ,CAAC,CACH,CACF,CAEJ,CACF,EAEAJ,EAAY,WAAc,CAAA,aAAA","file":"Breadcrumbs.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const noopFn = () => {};\n","import React, { SVGProps } from \"react\";\nimport { IconName, IconMap } from \"@deckai/icons\";\nimport { IconColors } from \"../types/tailwind\";\nimport { cn } from \"../utils\";\n\nexport type IconProps = {\n name: IconName;\n /** @default 24 */\n size?: number | `${Breakpoint}:${number}`;\n /** @default primary */\n color?: IconColors;\n title?: string;\n className?: string;\n style?: React.CSSProperties;\n} & Omit<SVGProps<SVGSVGElement>, \"aria-hidden\" | \"aria-label\">;\n\nconst COLOR_MAP: Record<IconColors, string> = {\n primary: \"#080808\",\n secondary: \"#666666\",\n white: \"#ffffff\",\n primaryBlue: \"#089CCB\"\n};\n\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveSize = number | `${Breakpoint}:${number}`;\n\nconst BREAKPOINT_MAP: Record<Breakpoint, string> = {\n sm: \"@media (min-width: 640px)\",\n md: \"@media (min-width: 768px)\",\n lg: \"@media (min-width: 1024px)\",\n xl: \"@media (min-width: 1280px)\",\n \"2xl\": \"@media (min-width: 1536px)\"\n};\n\nconst processSizes = (\n sizes: ResponsiveSize | ResponsiveSize[] | undefined\n): React.CSSProperties => {\n if (!sizes) return { width: \"24px\", height: \"24px\" };\n\n const sizeArray = Array.isArray(sizes) ? sizes : [sizes];\n const baseSize = typeof sizeArray[0] === \"number\" ? sizeArray[0] : 24;\n\n const style: React.CSSProperties = {\n width: `${baseSize}px`,\n height: `${baseSize}px`\n };\n\n // Add media queries for responsive sizes\n const mediaQueries = sizeArray\n .filter(\n (size): size is `${Breakpoint}:${number}` =>\n typeof size === \"string\" && size.includes(\":\")\n )\n .reduce(\n (acc, size) => {\n const [breakpoint, value] = size.split(\":\") as [Breakpoint, string];\n acc[BREAKPOINT_MAP[breakpoint]] = {\n width: `${value}px`,\n height: `${value}px`\n };\n return acc;\n },\n {} as Record<string, React.CSSProperties>\n );\n\n if (Object.keys(mediaQueries).length > 0) {\n (style as any)[\"@media\"] = mediaQueries;\n }\n\n return style;\n};\n\nexport const Icon = React.forwardRef<SVGSVGElement, IconProps>(\n (\n {\n name,\n size = 24,\n color = \"primary\",\n title,\n className,\n style = {},\n ...props\n },\n ref\n ) => {\n const IconComponent = IconMap[name];\n const sizeStyles = processSizes(size);\n\n return (\n <div\n className={cn(\"flex justify-center items-center\", className)}\n style={{\n ...sizeStyles,\n [\"--icon-stroke\" as string]: COLOR_MAP[color],\n ...style\n }}\n >\n <IconComponent\n ref={ref}\n aria-hidden={!title}\n aria-label={title}\n stroke={name.includes(\"filled\") ? undefined : COLOR_MAP[color]}\n {...props}\n />\n </div>\n );\n }\n);\n\nIcon.displayName = \"Icon\";\n","import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return Array.isArray(variants) ? `lg:text-${variant}` : `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\n","import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\n","import React from \"react\";\nimport { Text, TextProps } from \"./Text\";\nimport { cn } from \"../utils\";\nimport { focusRingStyles } from \"../utils/tailwind\";\n\nexport type LinkProps = {\n href: string;\n children: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n} & Pick<TextProps, \"variant\" | \"color\"> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>;\n\nexport const Link = ({\n children,\n color = \"text-primary\",\n variant = \"body-default-semibold\",\n href,\n className,\n ...props\n}: LinkProps) => (\n <Text variant={variant} color={color}>\n <a\n href={href}\n className={cn(\n \"hover:opacity-80 transition-all active:scale-95\",\n focusRingStyles,\n className\n )}\n {...props}\n >\n {children}\n </a>\n </Text>\n);\n","import React from \"react\";\nimport { cn } from \"../utils\";\nimport { Icon } from \"./Icon\";\nimport { Text } from \"./Text\";\nimport { Link } from \"./Link\";\n\ntype BreadcrumbItem = {\n label: string;\n href?: string;\n};\n\nexport type BreadcrumbsProps = {\n items: BreadcrumbItem[];\n className?: string;\n SeparatorComponent?: React.ReactElement;\n onHomeClick: () => void;\n};\n\nconst DefaultSeparator = () => (\n <Text variant=\"body-lg\" color=\"text-primary\">\n /\n </Text>\n);\n\nexport const Breadcrumbs = React.forwardRef<HTMLElement, BreadcrumbsProps>(\n (\n { items, className, SeparatorComponent = DefaultSeparator, onHomeClick },\n ref\n ) => {\n const renderSeparator = () =>\n typeof SeparatorComponent === \"function\" ? (\n <SeparatorComponent />\n ) : (\n React.cloneElement(SeparatorComponent)\n );\n\n return (\n <nav\n ref={ref}\n aria-label=\"Breadcrumb\"\n className={cn(\"relative\", className)}\n >\n <ol className=\"flex flex-wrap items-center gap-2\">\n <Icon\n onClick={onHomeClick}\n name=\"home\"\n size={20}\n color=\"secondary\"\n className=\"pb-0.5\"\n />\n {renderSeparator()}\n {items.map((item, index) => {\n const isLastItem = index === items.length - 1;\n\n return isLastItem || !item.href ? (\n <Text\n variant={isLastItem ? \"body-default-semibold\" : \"body-default\"}\n color={isLastItem ? \"text-primary\" : \"text-secondary\"}\n aria-current={isLastItem ? \"page\" : undefined}\n key={item.label}\n >\n {item.label}\n </Text>\n ) : (\n <>\n <Link href={item.href} key={item.label}>\n {item.label}\n </Link>\n {renderSeparator()}\n </>\n );\n })}\n </ol>\n </nav>\n );\n }\n);\n\nBreadcrumbs.displayName = \"Breadcrumbs\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts","../../src/components/Icon.tsx","../../src/components/Text.tsx","../../src/components/Link.tsx","../../src/utils/tailwind.ts","../../src/components/Breadcrumbs.tsx"],"names":["cn","inputs","twMerge","clsx","COLOR_MAP","BREAKPOINT_MAP","processSizes","sizes","sizeArray","mediaQueries","baseSize","size","breakpoint","valueStr","value","acc","query","Icon","React","name","color","title","className","style","props","ref","IconComponent","IconMap","sizeStyles","HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","fontWeight","processVariants","variants","typographyClass","Text","as","children","weight","typographyClasses","colorClasses","suggestedElement","baseVariant","focusRingStyles","Link","href","DefaultSeparator","Breadcrumbs","items","SeparatorComponent","onHomeClick","renderSeparator","item","index","isLastItem"],"mappings":"sHAGO,SAASA,CAAMC,CAAAA,GAAAA,CAAAA,CAAsB,CAC1C,OAAOC,QAAQC,IAAKF,CAAAA,CAAM,CAAC,CAC7B,CCcA,IAAMG,CAAAA,CAAwC,CAC5C,OAAS,CAAA,SAAA,CACT,UAAW,SACX,CAAA,KAAA,CAAO,UACP,WAAa,CAAA,SACf,CAEMC,CAAAA,CAAAA,CAA6C,CACjD,EAAI,CAAA,OAAA,CACJ,EAAI,CAAA,OAAA,CACJ,GAAI,QACJ,CAAA,EAAA,CAAI,QACJ,CAAA,KAAA,CAAO,QACT,CAEMC,CAAAA,CAAAA,CACJC,CACwB,EAAA,CACxB,GAAI,CAACA,CAAAA,CAAO,OAAO,CAAE,MAAO,MAAQ,CAAA,MAAA,CAAQ,MAAO,CAAA,CAEnD,IAAMC,CAAY,CAAA,KAAA,CAAM,OAAQD,CAAAA,CAAK,EAAIA,CAAQ,CAAA,CAACA,CAAK,CACjDE,CAAAA,CAAAA,CAAuC,EACzCC,CAAAA,CAAAA,CAGJ,OAAAF,CAAAA,CAAU,QAASG,CAAS,EAAA,CAC1B,GAAI,OAAOA,GAAS,QAClBD,CAAAA,CAAAA,CAAW,CAAGC,EAAAA,CAAI,UACb,CACL,GAAM,CAACC,CAAAA,CAAYC,CAAQ,CAAIF,CAAAA,CAAAA,CAAK,KAAM,CAAA,GAAG,EACvCG,CAAQ,CAAA,QAAA,CAASD,CAAU,CAAA,EAAE,EACnCJ,CAAa,CAAA,CAAA,mBAAA,EAAsBJ,CAAeO,CAAAA,CAAU,CAAC,CAAG,CAAA,CAAA,CAAA,CAC9D,GAAGE,CAAK,CAAA,EAAA,EACZ,CACF,CAAC,CAAA,CAGM,CACL,KAAA,CAAOJ,GAAY,MACnB,CAAA,MAAA,CAAQA,C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,cAAA,CAAiB,iBACrC,cAAcA,CAAAA,CAAAA,CAAa,MAAS,CAAA,KAAA,CAAA,CACpC,IAAKF,CAAK,CAAA,KAAA,CAAA,CAETA,CAAK,CAAA,KACR,EAEApC,CAAA,CAAA,aAAA,CAAAA,EAAA,QACEA,CAAAA,IAAAA,CAAAA,CAAAA,CAAA,cAAC4B,CAAA,CAAA,CAAK,IAAMQ,CAAAA,CAAAA,CAAK,KAAM,GAAKA,CAAAA,CAAAA,CAAK,KAC9BA,CAAAA,CAAAA,CAAAA,CAAK,KACR,CACCD,CAAAA,CAAAA,EACH,CAEJ,CAAC,CACH,CACF,CAEJ,CACF,EAEAJ,EAAY,WAAc,CAAA,aAAA","file":"Breadcrumbs.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const noopFn = () => {};\n","import React, { SVGProps } from \"react\";\nimport { IconName, IconMap } from \"@deckai/icons\";\nimport { IconColors } from \"../types/tailwind\";\nimport { cn } from \"../utils\";\n\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveSize = number | `${Breakpoint}:${number}`;\n\nexport type IconProps = {\n name: IconName;\n /** @default 24 */\n size?: ResponsiveSize | ResponsiveSize[];\n /** @default primary */\n color?: IconColors;\n title?: string;\n className?: string;\n style?: React.CSSProperties;\n} & Omit<SVGProps<SVGSVGElement>, \"aria-hidden\" | \"aria-label\">;\n\nconst COLOR_MAP: Record<IconColors, string> = {\n primary: \"#080808\",\n secondary: \"#666666\",\n white: \"#ffffff\",\n primaryBlue: \"#089CCB\"\n};\n\nconst BREAKPOINT_MAP: Record<Breakpoint, string> = {\n sm: \"640px\",\n md: \"768px\",\n lg: \"1024px\",\n xl: \"1280px\",\n \"2xl\": \"1536px\"\n};\n\nconst processSizes = (\n sizes: ResponsiveSize | ResponsiveSize[] | undefined\n): React.CSSProperties => {\n if (!sizes) return { width: \"24px\", height: \"24px\" };\n\n const sizeArray = Array.isArray(sizes) ? sizes : [sizes];\n const mediaQueries: Record<string, string> = {};\n let baseSize: string | undefined;\n\n // Process each size\n sizeArray.forEach((size) => {\n if (typeof size === \"number\") {\n baseSize = `${size}px`;\n } else {\n const [breakpoint, valueStr] = size.split(\":\") as [Breakpoint, string];\n const value = parseInt(valueStr, 10);\n mediaQueries[`@media (min-width: ${BREAKPOINT_MAP[breakpoint]})`] =\n `${value}px`;\n }\n });\n\n // Create the style object with the correct structure\n return {\n width: baseSize || \"24px\",\n height: baseSize || \"24px\",\n ...Object.entries(mediaQueries).reduce(\n (acc, [query, size]) => ({\n ...acc,\n [query]: {\n width: size,\n height: size\n }\n }),\n {}\n )\n };\n};\n\nexport const Icon = React.forwardRef<SVGSVGElement, IconProps>(\n (\n {\n name,\n size = 24,\n color = \"primary\",\n title,\n className,\n style = {},\n ...props\n },\n ref\n ) => {\n const IconComponent = IconMap[name];\n const sizeStyles = processSizes(size);\n\n return (\n <div\n className={cn(\"flex justify-center items-center\", className)}\n style={{\n ...sizeStyles,\n [\"--icon-stroke\" as string]: COLOR_MAP[color],\n ...style\n }}\n >\n <IconComponent\n ref={ref}\n aria-hidden={!title}\n aria-label={title}\n stroke={name.includes(\"filled\") ? undefined : COLOR_MAP[color]}\n {...props}\n />\n </div>\n );\n }\n);\n\nIcon.displayName = \"Icon\";\n","import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\n","import React from \"react\";\nimport { Text, TextProps } from \"./Text\";\nimport { cn } from \"../utils\";\nimport { focusRingStyles } from \"../utils/tailwind\";\n\nexport type LinkProps = {\n href: string;\n children: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n} & Pick<TextProps, \"variant\" | \"color\"> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>;\n\nexport const Link = ({\n children,\n color = \"text-primary\",\n variant = \"body-default-semibold\",\n href,\n className,\n ...props\n}: LinkProps) => (\n <Text variant={variant} color={color}>\n <a\n href={href}\n className={cn(\n \"hover:opacity-80 transition-all active:scale-95 hover:underline\",\n focusRingStyles,\n className\n )}\n {...props}\n >\n {children}\n </a>\n </Text>\n);\n","import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\n","import React from \"react\";\nimport { cn } from \"../utils\";\nimport { Icon } from \"./Icon\";\nimport { Text } from \"./Text\";\nimport { Link } from \"./Link\";\n\ntype BreadcrumbItem = {\n label: string;\n href?: string;\n};\n\nexport type BreadcrumbsProps = {\n items: BreadcrumbItem[];\n className?: string;\n SeparatorComponent?: React.ReactElement;\n onHomeClick: () => void;\n};\n\nconst DefaultSeparator = () => (\n <Text variant={[\"sm:body-lg\", \"body-xs\"]} color=\"text-primary\">\n /\n </Text>\n);\n\nexport const Breadcrumbs = React.forwardRef<HTMLElement, BreadcrumbsProps>(\n (\n { items, className, SeparatorComponent = DefaultSeparator, onHomeClick },\n ref\n ) => {\n const renderSeparator = () =>\n typeof SeparatorComponent === \"function\" ? (\n <SeparatorComponent />\n ) : (\n React.cloneElement(SeparatorComponent)\n );\n\n return (\n <nav\n ref={ref}\n aria-label=\"Breadcrumb\"\n className={cn(\n \"sm:relative sticky top-0 sm:border-none border-secondary-50 border-b-[1px] pb-2\",\n className\n )}\n >\n <ol className=\"flex flex-wrap items-center gap-2\">\n <Icon\n onClick={onHomeClick}\n name=\"home\"\n size={[\"sm:20\", 16]}\n color=\"secondary\"\n className=\"pb-0.5\"\n />\n {renderSeparator()}\n {items.map((item, index) => {\n const isLastItem = index === items.length - 1;\n\n return isLastItem || !item.href ? (\n <Text\n variant={\n isLastItem\n ? [\"body-xs-medium\", \"md:body-default-semibold\"]\n : [\"body-xs\", \"md:body-default\"]\n }\n color={isLastItem ? \"text-primary\" : \"text-secondary\"}\n aria-current={isLastItem ? \"page\" : undefined}\n key={item.label}\n >\n {item.label}\n </Text>\n ) : (\n <>\n <Link href={item.href} key={item.label}>\n {item.label}\n </Link>\n {renderSeparator()}\n </>\n );\n })}\n </ol>\n </nav>\n );\n }\n);\n\nBreadcrumbs.displayName = \"Breadcrumbs\";\n"]}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
'use strict';var p=require('react');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var p__namespace=/*#__PURE__*/_interopNamespace(p);var
|
|
2
|
-
px-7
|
|
1
|
+
'use strict';var p=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var p__namespace=/*#__PURE__*/_interopNamespace(p);var b={xl:"h1",lg:"h1",md:"h2",sm:"h3",xs:"h4"},h=e=>{let[t,r]=e.split("-");return t==="heading"?b[r]||"p":t==="label"?"label":"p"},f={light:"font-light",regular:"font-regular",semibold:"font-semibold",bold:"font-bold"},H=e=>e?(Array.isArray(e)?e:[e]).map(r=>{if(r.includes(":")){let[n,o]=r.split(":");return `${n}:text-${o}`}return `text-${r}`}).join(" "):"text-body-default",c=p__namespace.default.forwardRef(({variant:e="body-default",color:t="text-primary",as:r,className:n,children:o,weight:s,...i},l)=>{let T=H(e),m=t&&t==="inherit"?"inherit":t?`text-${t}`:"",g=p__namespace.default.useMemo(()=>{let u=typeof e=="string"?e.split(":").pop():Array.isArray(e)?e[0].split(":").pop():"body-default";return h(u)},[e]);return p__namespace.default.createElement(r||g,{ref:l,className:`font-sans antialiased ${T} ${m} ${s?`!${f[s]}`:""} ${n??""}`,...i},o)});c.displayName="Text";var y="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";function d(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var L={black:"bg-text-primary text-white",accent:"bg-primary-100 text-white",secondary:"bg-secondary-100 text-secondary"},E={black:"border border-text-primary text-text-primary",accent:"border border-primary-100 text-primary-100",secondary:"border border-text-secondary text-secondary"},R=p__namespace.forwardRef(({className:e,variant:t="filled",color:r="black",isLoading:n=!1,children:o,disabled:s,...i},l)=>p__namespace.createElement("button",{ref:l,className:d(`
|
|
2
|
+
sm:px-7 px-4
|
|
3
3
|
py-2
|
|
4
4
|
inline-flex items-center justify-center
|
|
5
5
|
rounded-lg
|
|
6
6
|
transition-colors duration-200
|
|
7
|
-
${c}
|
|
8
7
|
disabled:opacity-50 disabled:pointer-events-none
|
|
9
8
|
hover:opacity-80 active:scale-95
|
|
10
|
-
truncate
|
|
11
|
-
${r==="filled"?H[t]:M[t]}
|
|
12
|
-
${e}
|
|
13
|
-
`,disabled:s||a,type:"button",...i},typeof o=="string"?p__namespace.createElement(y,{variant:"body-default-bold",color:"inherit"},o):o));L.displayName="Button";if (exports.default) module.exports = exports.default;exports.Button=L;//# sourceMappingURL=Button.cjs.map
|
|
9
|
+
truncate`,y,t==="filled"?L[r]:E[r],e),disabled:s||n,type:"button",...i},typeof o=="string"?p__namespace.createElement(c,{variant:["sm:body-default-bold","body-xxs-semibold"],color:"inherit"},o):o));R.displayName="Button";if (exports.default) module.exports = exports.default;exports.Button=R;exports.filled=L;exports.outlined=E;//# sourceMappingURL=Button.cjs.map
|
|
14
10
|
//# sourceMappingURL=Button.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Text.tsx","../../src/utils/tailwind.ts","../../src/components/Button.tsx"],"names":["HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","size","fontWeight","processVariants","variants","breakpoint","typographyClass","Text","React","color","as","className","children","weight","props","ref","typographyClasses","colorClasses","suggestedElement","baseVariant","focusRingStyles","filled","outlined","Button","n","isLoading","disabled"],"mappings":"0YA4FA,IAAMA,CAAmD,CAAA,CACvD,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IACN,CAEMC,CAAAA,CAAAA,CAAyBC,CAAwC,EAAA,CACrE,GAAM,CAACC,CAAUC,CAAAA,CAAI,CAAIF,CAAAA,CAAAA,CAAQ,MAAM,GAAG,CAAA,CAE1C,OAAIC,CAAAA,GAAa,SACRH,CAAAA,CAAAA,CAAoBI,CAAI,CAAA,EAAK,GAGlCD,CAAAA,CAAAA,GAAa,OACR,CAAA,OAAA,CAGF,GACT,CAAA,CAIME,CAAqC,CAAA,CACzC,MAAO,YACP,CAAA,OAAA,CAAS,cACT,CAAA,QAAA,CAAU,eACV,CAAA,IAAA,CAAM,WACR,CAAA,CAiBMC,CACJC,CAAAA,CAAAA,EAEKA,CAEgB,CAAA,CAAA,KAAA,CAAM,OAAQA,CAAAA,CA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A,CAAOZ,CAAK,CAAIa,CAAAA,CAAAA,CAASb,CAAK,CAAC;AAAA,UAAA,EACtDE,CAAS;AAAA,QAEf,CAAA,CAAA,QAAA,CAAUe,GAAYD,CACtB,CAAA,IAAA,CAAK,SACJ,GAAGX,CAAAA,CAAAA,CAEH,OAAOF,CAAAA,EAAa,QACnB,CAAAY,YAAA,CAAA,aAAA,CAACjB,EAAA,CAAK,OAAA,CAAQ,mBAAoB,CAAA,KAAA,CAAM,SACrCK,CAAAA,CAAAA,CACH,EAEAA,CAEJ,CAEJ,EAEAW,CAAAA,CAAO,WAAc,CAAA,QAAA","file":"Button.cjs","sourcesContent":["import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return Array.isArray(variants) ? `lg:text-${variant}` : `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\n","import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\n","import * as React from \"react\";\nimport { Text } from \"./Text\";\nimport { focusRingStyles } from \"../utils/tailwind\";\n\nexport type ButtonProps = {\n /** @default filled */\n variant?: \"filled\" | \"outlined\";\n /** @default primary */\n color?: \"black\" | \"accent\" | \"secondary\";\n isLoading?: boolean;\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n start?: React.ReactNode;\n end?: React.ReactNode;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nconst filled = {\n black: \"bg-text-primary text-white\",\n // fade it slightly\n accent: \"bg-primary-100 text-white\",\n secondary: \"bg-secondary-100 text-secondary\"\n};\n\nconst outlined = {\n black: \"border border-text-primary text-text-primary\",\n accent: \"border border-primary-100 text-primary-100\",\n secondary: \"border border-text-secondary text-secondary\"\n};\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n className,\n variant = \"filled\",\n color = \"black\",\n isLoading = false,\n children,\n disabled,\n ...props\n },\n ref\n ) => (\n <button\n ref={ref}\n className={`\n px-7\n py-2\n inline-flex items-center justify-center\n rounded-lg \n transition-colors duration-200\n ${focusRingStyles}\n disabled:opacity-50 disabled:pointer-events-none\n hover:opacity-80 active:scale-95 \n truncate\n ${variant === \"filled\" ? filled[color] : outlined[color]}\n ${className}\n `}\n disabled={disabled || isLoading}\n type=\"button\"\n {...props}\n >\n {typeof children === \"string\" ? (\n <Text variant=\"body-default-bold\" color=\"inherit\">\n {children}\n </Text>\n ) : (\n children\n )}\n </button>\n )\n);\n\nButton.displayName = \"Button\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Text.tsx","../../src/utils/tailwind.ts","../../src/utils/index.ts","../../src/components/Button.tsx"],"names":["HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","size","fontWeight","processVariants","variants","breakpoint","typographyClass","Text","React","color","as","className","children","weight","props","ref","typographyClasses","colorClasses","suggestedElement","baseVariant","focusRingStyles","cn","inputs","twMerge","clsx","filled","outlined","Button","a","isLoading","disabled"],"mappings":"ucA4FA,IAAMA,CAAmD,CAAA,CACvD,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,GAAI,IACJ,CAAA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C1B,CAAA,UAAA,CAAA,CACE,CACE,SAAA,CAAAjB,CACA,CAAA,OAAA,CAAAZ,CAAU,CAAA,QAAA,CACV,MAAAU,CAAQ,CAAA,OAAA,CACR,SAAAoB,CAAAA,CAAAA,CAAY,CACZ,CAAA,CAAA,QAAA,CAAAjB,CACA,CAAA,QAAA,CAAAkB,EACA,GAAGhB,CACL,CACAC,CAAAA,CAAAA,GAEAa,YAAC,CAAA,aAAA,CAAA,QAAA,CAAA,CACC,GAAKb,CAAAA,CAAAA,CACL,UAAWM,CACT,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAA,CAAA,CASAD,EACArB,CAAY,GAAA,QAAA,CAAW0B,CAAOhB,CAAAA,CAAK,EAAIiB,CAASjB,CAAAA,CAAK,CACrDE,CAAAA,CACF,EACA,QAAUmB,CAAAA,CAAAA,EAAYD,CACtB,CAAA,IAAA,CAAK,SACJ,GAAGf,CAAAA,CAAAA,CAEH,OAAOF,CAAAA,EAAa,SACnBgB,YAACrB,CAAAA,aAAAA,CAAAA,CAAAA,CAAA,CACC,OAAA,CAAS,CAAC,sBAAwB,CAAA,mBAAmB,CACrD,CAAA,KAAA,CAAM,WAELK,CACH,CAAA,CAEAA,CAEJ,CAEJ,EAEAe,EAAO,WAAc,CAAA,QAAA","file":"Button.cjs","sourcesContent":["import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\n","import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\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\nexport const noopFn = () => {};\n","import * as React from \"react\";\nimport { Text } from \"./Text\";\nimport { focusRingStyles } from \"../utils/tailwind\";\nimport { cn } from \"../utils\";\n\nexport type ButtonProps = {\n /** @default filled */\n variant?: \"filled\" | \"outlined\";\n /** @default primary */\n color?: \"black\" | \"accent\" | \"secondary\";\n isLoading?: boolean;\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n start?: React.ReactNode;\n end?: React.ReactNode;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const filled = {\n black: \"bg-text-primary text-white\",\n // fade it slightly\n accent: \"bg-primary-100 text-white\",\n secondary: \"bg-secondary-100 text-secondary\"\n};\n\nexport const outlined = {\n black: \"border border-text-primary text-text-primary\",\n accent: \"border border-primary-100 text-primary-100\",\n secondary: \"border border-text-secondary text-secondary\"\n};\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n className,\n variant = \"filled\",\n color = \"black\",\n isLoading = false,\n children,\n disabled,\n ...props\n },\n ref\n ) => (\n <button\n ref={ref}\n className={cn(\n `\n sm:px-7 px-4\n py-2\n inline-flex items-center justify-center\n rounded-lg \n transition-colors duration-200\n disabled:opacity-50 disabled:pointer-events-none\n hover:opacity-80 active:scale-95 \n truncate`,\n focusRingStyles,\n variant === \"filled\" ? filled[color] : outlined[color],\n className\n )}\n disabled={disabled || isLoading}\n type=\"button\"\n {...props}\n >\n {typeof children === \"string\" ? (\n <Text\n variant={[\"sm:body-default-bold\", \"body-xxs-semibold\"]}\n color=\"inherit\"\n >\n {children}\n </Text>\n ) : (\n children\n )}\n </button>\n )\n);\n\nButton.displayName = \"Button\";\n"]}
|
|
@@ -12,6 +12,16 @@ type ButtonProps = {
|
|
|
12
12
|
start?: React.ReactNode;
|
|
13
13
|
end?: React.ReactNode;
|
|
14
14
|
} & React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
15
|
+
declare const filled: {
|
|
16
|
+
black: string;
|
|
17
|
+
accent: string;
|
|
18
|
+
secondary: string;
|
|
19
|
+
};
|
|
20
|
+
declare const outlined: {
|
|
21
|
+
black: string;
|
|
22
|
+
accent: string;
|
|
23
|
+
secondary: string;
|
|
24
|
+
};
|
|
15
25
|
declare const Button: React.ForwardRefExoticComponent<{
|
|
16
26
|
/** @default filled */
|
|
17
27
|
variant?: "filled" | "outlined";
|
|
@@ -25,4 +35,4 @@ declare const Button: React.ForwardRefExoticComponent<{
|
|
|
25
35
|
end?: React.ReactNode;
|
|
26
36
|
} & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
|
27
37
|
|
|
28
|
-
export { Button, type ButtonProps };
|
|
38
|
+
export { Button, type ButtonProps, filled, outlined };
|
|
@@ -12,6 +12,16 @@ type ButtonProps = {
|
|
|
12
12
|
start?: React.ReactNode;
|
|
13
13
|
end?: React.ReactNode;
|
|
14
14
|
} & React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
15
|
+
declare const filled: {
|
|
16
|
+
black: string;
|
|
17
|
+
accent: string;
|
|
18
|
+
secondary: string;
|
|
19
|
+
};
|
|
20
|
+
declare const outlined: {
|
|
21
|
+
black: string;
|
|
22
|
+
accent: string;
|
|
23
|
+
secondary: string;
|
|
24
|
+
};
|
|
15
25
|
declare const Button: React.ForwardRefExoticComponent<{
|
|
16
26
|
/** @default filled */
|
|
17
27
|
variant?: "filled" | "outlined";
|
|
@@ -25,4 +35,4 @@ declare const Button: React.ForwardRefExoticComponent<{
|
|
|
25
35
|
end?: React.ReactNode;
|
|
26
36
|
} & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
|
27
37
|
|
|
28
|
-
export { Button, type ButtonProps };
|
|
38
|
+
export { Button, type ButtonProps, filled, outlined };
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import*as p from'react';import p__default from'react';var
|
|
2
|
-
px-7
|
|
1
|
+
import*as p from'react';import p__default from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';var b={xl:"h1",lg:"h1",md:"h2",sm:"h3",xs:"h4"},h=e=>{let[t,r]=e.split("-");return t==="heading"?b[r]||"p":t==="label"?"label":"p"},f={light:"font-light",regular:"font-regular",semibold:"font-semibold",bold:"font-bold"},H=e=>e?(Array.isArray(e)?e:[e]).map(r=>{if(r.includes(":")){let[n,o]=r.split(":");return `${n}:text-${o}`}return `text-${r}`}).join(" "):"text-body-default",c=p__default.forwardRef(({variant:e="body-default",color:t="text-primary",as:r,className:n,children:o,weight:s,...i},l)=>{let T=H(e),m=t&&t==="inherit"?"inherit":t?`text-${t}`:"",g=p__default.useMemo(()=>{let u=typeof e=="string"?e.split(":").pop():Array.isArray(e)?e[0].split(":").pop():"body-default";return h(u)},[e]);return p__default.createElement(r||g,{ref:l,className:`font-sans antialiased ${T} ${m} ${s?`!${f[s]}`:""} ${n??""}`,...i},o)});c.displayName="Text";var y="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";function d(...e){return twMerge(clsx(e))}var L={black:"bg-text-primary text-white",accent:"bg-primary-100 text-white",secondary:"bg-secondary-100 text-secondary"},E={black:"border border-text-primary text-text-primary",accent:"border border-primary-100 text-primary-100",secondary:"border border-text-secondary text-secondary"},R=p.forwardRef(({className:e,variant:t="filled",color:r="black",isLoading:n=!1,children:o,disabled:s,...i},l)=>p.createElement("button",{ref:l,className:d(`
|
|
2
|
+
sm:px-7 px-4
|
|
3
3
|
py-2
|
|
4
4
|
inline-flex items-center justify-center
|
|
5
5
|
rounded-lg
|
|
6
6
|
transition-colors duration-200
|
|
7
|
-
${c}
|
|
8
7
|
disabled:opacity-50 disabled:pointer-events-none
|
|
9
8
|
hover:opacity-80 active:scale-95
|
|
10
|
-
truncate
|
|
11
|
-
${r==="filled"?H[t]:M[t]}
|
|
12
|
-
${e}
|
|
13
|
-
`,disabled:s||a,type:"button",...i},typeof o=="string"?p.createElement(y,{variant:"body-default-bold",color:"inherit"},o):o));L.displayName="Button";if (exports.default) module.exports = exports.default;export{L as Button};//# sourceMappingURL=Button.js.map
|
|
9
|
+
truncate`,y,t==="filled"?L[r]:E[r],e),disabled:s||n,type:"button",...i},typeof o=="string"?p.createElement(c,{variant:["sm:body-default-bold","body-xxs-semibold"],color:"inherit"},o):o));R.displayName="Button";if (exports.default) module.exports = exports.default;export{R as Button,L as filled,E as outlined};//# sourceMappingURL=Button.js.map
|
|
14
10
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Text.tsx","../../src/utils/tailwind.ts","../../src/components/Button.tsx"],"names":["HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","size","fontWeight","processVariants","variants","breakpoint","typographyClass","Text","React","color","as","className","children","weight","props","ref","typographyClasses","colorClasses","suggestedElement","baseVariant","focusRingStyles","filled","outlined","Button","n","isLoading","disabled"],"mappings":"sDA4FA,IAAMA,CAAmD,CAAA,CACvD,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IACN,CAEMC,CAAAA,CAAAA,CAAyBC,CAAwC,EAAA,CACrE,GAAM,CAACC,CAAUC,CAAAA,CAAI,CAAIF,CAAAA,CAAAA,CAAQ,MAAM,GA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A,OAAA,CACR,SAAAgB,CAAAA,CAAAA,CAAY,CACZ,CAAA,CAAA,QAAA,CAAAb,CACA,CAAA,QAAA,CAAAc,CACA,CAAA,GAAGZ,CACL,CAAA,CACAC,CAEA,GAAAS,CAAA,CAAA,aAAA,CAAC,QACC,CAAA,CAAA,GAAA,CAAKT,EACL,SAAW,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAA,EAMLK,CAAe;AAAA;AAAA;AAAA;AAAA,UAAA,EAIfrB,IAAY,QAAWsB,CAAAA,CAAAA,CAAOZ,CAAK,CAAIa,CAAAA,CAAAA,CAASb,CAAK,CAAC;AAAA,UAAA,EACtDE,CAAS;AAAA,QAEf,CAAA,CAAA,QAAA,CAAUe,GAAYD,CACtB,CAAA,IAAA,CAAK,SACJ,GAAGX,CAAAA,CAAAA,CAEH,OAAOF,CAAAA,EAAa,QACnB,CAAAY,CAAA,CAAA,aAAA,CAACjB,EAAA,CAAK,OAAA,CAAQ,mBAAoB,CAAA,KAAA,CAAM,SACrCK,CAAAA,CAAAA,CACH,EAEAA,CAEJ,CAEJ,EAEAW,CAAAA,CAAO,WAAc,CAAA,QAAA","file":"Button.js","sourcesContent":["import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return Array.isArray(variants) ? `lg:text-${variant}` : `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\n","import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\n","import * as React from \"react\";\nimport { Text } from \"./Text\";\nimport { focusRingStyles } from \"../utils/tailwind\";\n\nexport type ButtonProps = {\n /** @default filled */\n variant?: \"filled\" | \"outlined\";\n /** @default primary */\n color?: \"black\" | \"accent\" | \"secondary\";\n isLoading?: boolean;\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n start?: React.ReactNode;\n end?: React.ReactNode;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nconst filled = {\n black: \"bg-text-primary text-white\",\n // fade it slightly\n accent: \"bg-primary-100 text-white\",\n secondary: \"bg-secondary-100 text-secondary\"\n};\n\nconst outlined = {\n black: \"border border-text-primary text-text-primary\",\n accent: \"border border-primary-100 text-primary-100\",\n secondary: \"border border-text-secondary text-secondary\"\n};\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n className,\n variant = \"filled\",\n color = \"black\",\n isLoading = false,\n children,\n disabled,\n ...props\n },\n ref\n ) => (\n <button\n ref={ref}\n className={`\n px-7\n py-2\n inline-flex items-center justify-center\n rounded-lg \n transition-colors duration-200\n ${focusRingStyles}\n disabled:opacity-50 disabled:pointer-events-none\n hover:opacity-80 active:scale-95 \n truncate\n ${variant === \"filled\" ? filled[color] : outlined[color]}\n ${className}\n `}\n disabled={disabled || isLoading}\n type=\"button\"\n {...props}\n >\n {typeof children === \"string\" ? (\n <Text variant=\"body-default-bold\" color=\"inherit\">\n {children}\n </Text>\n ) : (\n children\n )}\n </button>\n )\n);\n\nButton.displayName = \"Button\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Text.tsx","../../src/utils/tailwind.ts","../../src/utils/index.ts","../../src/components/Button.tsx"],"names":["HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","size","fontWeight","processVariants","variants","breakpoint","typographyClass","Text","React","color","as","className","children","weight","props","ref","typographyClasses","colorClasses","suggestedElement","baseVariant","focusRingStyles","cn","inputs","twMerge","clsx","filled","outlined","Button","a","isLoading","disabled"],"mappings":"mHA4FA,IAAMA,CAAmD,CAAA,CACvD,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IAAA,CACJ,GAAI,IACJ,CAAA,EAAA,CAAI,IACJ,CAAA,EAAA,CAAI,IACN,CAAA,CAEMC,CAAyBC,CAAAA,CAAAA,EAAwC,CACrE,GAAM,CAACC,CAAUC,CAAAA,CAAI,CAAIF,CAAAA,CAAAA,CAAQ,KAAM,CAAA,GAAG,EAE1C,OAAIC,CAAAA,GAAa,SACRH,CAAAA,CAAAA,CAAoBI,CAAI,CAAA,EAAK,GAGlCD,CAAAA,CAAAA,GAAa,QACR,OAGF,CAAA,GACT,CAIME,CAAAA,CAAAA,CAAqC,CACzC,KAAA,CAAO,YACP,CAAA,OAAA,CAAS,eACT,QAAU,CAAA,eAAA,CACV,IAAM,CAAA,WACR,CAiBMC,CAAAA,CAAAA,CACJC,CAEKA,EAAAA,CAAAA,CAAAA,CAEgB,MAAM,OAAQA,CAAAA,CAAQ,CAAIA,CAAAA,CAAAA,CAAW,CAACA,CAAQ,CAGhE,EAAA,GAAA,CAAKL,GAAY,CAChB,GAAIA,CAAQ,CAAA,QAAA,CAAS,GAAG,CAAA,CAAG,CACzB,GAAM,CAACM,CAAAA,CAAYC,CAAe,CAAA,CAAIP,CAAQ,CAAA,KAAA,CAAM,GAAG,CAAA,CACvD,OAAO,CAAGM,EAAAA,CAAU,CAASC,MAAAA,EAAAA,CAAe,CAC9C,CAAA,CACA,OAAO,CAAA,KAAA,EAAQP,CAAO,CACxB,CAAA,CAAC,CACA,CAAA,IAAA,CAAK,GAAG,CAAA,CAZW,mBAeXQ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X,qGCpEF,CAGO,SAASC,CAAMC,CAAAA,GAAAA,CAAAA,CAAsB,CAC1C,OAAOC,OAAAA,CAAQC,IAAKF,CAAAA,CAAM,CAAC,CAC7B,CCaO,IAAMG,EAAS,CACpB,KAAA,CAAO,4BAEP,CAAA,MAAA,CAAQ,2BACR,CAAA,SAAA,CAAW,iCACb,CAAA,CAEaC,EAAW,CACtB,KAAA,CAAO,8CACP,CAAA,MAAA,CAAQ,4CACR,CAAA,SAAA,CAAW,6CACb,CAAA,CAEaC,EAAeC,CAC1B,CAAA,UAAA,CAAA,CACE,CACE,SAAA,CAAAjB,CACA,CAAA,OAAA,CAAAZ,CAAU,CAAA,QAAA,CACV,MAAAU,CAAQ,CAAA,OAAA,CACR,SAAAoB,CAAAA,CAAAA,CAAY,CACZ,CAAA,CAAA,QAAA,CAAAjB,CACA,CAAA,QAAA,CAAAkB,EACA,GAAGhB,CACL,CACAC,CAAAA,CAAAA,GAEAa,CAAC,CAAA,aAAA,CAAA,QAAA,CAAA,CACC,GAAKb,CAAAA,CAAAA,CACL,UAAWM,CACT,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAA,CAAA,CASAD,EACArB,CAAY,GAAA,QAAA,CAAW0B,CAAOhB,CAAAA,CAAK,EAAIiB,CAASjB,CAAAA,CAAK,CACrDE,CAAAA,CACF,EACA,QAAUmB,CAAAA,CAAAA,EAAYD,CACtB,CAAA,IAAA,CAAK,SACJ,GAAGf,CAAAA,CAAAA,CAEH,OAAOF,CAAAA,EAAa,SACnBgB,CAACrB,CAAAA,aAAAA,CAAAA,CAAAA,CAAA,CACC,OAAA,CAAS,CAAC,sBAAwB,CAAA,mBAAmB,CACrD,CAAA,KAAA,CAAM,WAELK,CACH,CAAA,CAEAA,CAEJ,CAEJ,EAEAe,EAAO,WAAc,CAAA,QAAA","file":"Button.js","sourcesContent":["import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\n","import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\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\nexport const noopFn = () => {};\n","import * as React from \"react\";\nimport { Text } from \"./Text\";\nimport { focusRingStyles } from \"../utils/tailwind\";\nimport { cn } from \"../utils\";\n\nexport type ButtonProps = {\n /** @default filled */\n variant?: \"filled\" | \"outlined\";\n /** @default primary */\n color?: \"black\" | \"accent\" | \"secondary\";\n isLoading?: boolean;\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n start?: React.ReactNode;\n end?: React.ReactNode;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const filled = {\n black: \"bg-text-primary text-white\",\n // fade it slightly\n accent: \"bg-primary-100 text-white\",\n secondary: \"bg-secondary-100 text-secondary\"\n};\n\nexport const outlined = {\n black: \"border border-text-primary text-text-primary\",\n accent: \"border border-primary-100 text-primary-100\",\n secondary: \"border border-text-secondary text-secondary\"\n};\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n className,\n variant = \"filled\",\n color = \"black\",\n isLoading = false,\n children,\n disabled,\n ...props\n },\n ref\n ) => (\n <button\n ref={ref}\n className={cn(\n `\n sm:px-7 px-4\n py-2\n inline-flex items-center justify-center\n rounded-lg \n transition-colors duration-200\n disabled:opacity-50 disabled:pointer-events-none\n hover:opacity-80 active:scale-95 \n truncate`,\n focusRingStyles,\n variant === \"filled\" ? filled[color] : outlined[color],\n className\n )}\n disabled={disabled || isLoading}\n type=\"button\"\n {...props}\n >\n {typeof children === \"string\" ? (\n <Text\n variant={[\"sm:body-default-bold\", \"body-xxs-semibold\"]}\n color=\"inherit\"\n >\n {children}\n </Text>\n ) : (\n children\n )}\n </button>\n )\n);\n\nButton.displayName = \"Button\";\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var n=require('react'),i=require('@radix-ui/react-collapsible'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var n__default=/*#__PURE__*/_interopDefault(n);var i__namespace=/*#__PURE__*/_interopNamespace(i);var h="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";var u=({children:e,type:t="button",className:o,disabled:s,...r})=>n__default.default.createElement("button",{type:t,disabled:s,className:`appearance-none hover:opacity-80 transition-all active:scale-95 ${h} ${o} ${s?"opacity-50 cursor-not-allowed":""}`,...r},e);var H={xl:"h1",lg:"h1",md:"h2",sm:"h3",xs:"h4"},M=e=>{let[t,o]=e.split("-");return t==="heading"?H[o]||"p":t==="label"?"label":"p"},L={light:"font-light",regular:"font-regular",semibold:"font-semibold",bold:"font-bold"},x=e=>e?(Array.isArray(e)?e:[e]).map(o=>{if(o.includes(":")){let[s,r]=o.split(":");return `${s}:text-${r}`}return `text-${o}`}).join(" "):"text-body-default",g=n__default.default.forwardRef(({variant:e="body-default",color:t="text-primary",as:o,className:s,children:r,weight:a,...p},c)=>{let l=x(e),y=t&&t==="inherit"?"inherit":t?`text-${t}`:"",T=n__default.default.useMemo(()=>{let b=typeof e=="string"?e.split(":").pop():Array.isArray(e)?e[0].split(":").pop():"body-default";return M(b)},[e]);return n__default.default.createElement(o||T,{ref:c,className:`font-sans antialiased ${l} ${y} ${a?`!${L[a]}`:""} ${s??""}`,...p},r)});g.displayName="Text";function d(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var v=({children:e,maxHeight:t=100})=>{let[o,s]=n__default.default.useState(!1),r=n.useRef(null),[a,p]=n.useState(t);n.useLayoutEffect(()=>{if(!r.current)return;let l=new ResizeObserver(y=>{for(let T of y)p(T.target.scrollHeight);});return l.observe(r.current),()=>l.disconnect()},[]);let c=a>t;return n__default.default.createElement(i__namespace.Root,{open:o,onOpenChange:s},n__default.default.createElement("div",{className:"relative"},n__default.default.createElement("div",{className:"overflow-hidden transition-[height] duration-300 ease-in-out",style:{height:o?`${a}px`:`${t}px`}},n__default.default.createElement("div",{ref:r,className:"w-full"},e)),c&&n__default.default.createElement(i__namespace.Trigger,{asChild:!0},n__default.default.createElement(u,{className:d("absolute -bottom-8 left-0 right-0","flex items-end justify-center","h-16 pt-8 pb-2",!o&&"bg-gradient-to-b from-transparent via-white to-white","hover:opacity-100 transition-opacity")},n__default.default.createElement(g,{variant:"label-default",color:"text-secondary"},o?"See less":"See more")))))};v.displayName="Collapsible";if (exports.default) module.exports = exports.default;exports.Collapsible=v;//# sourceMappingURL=Collapsible.cjs.map
|
|
2
|
+
//# sourceMappingURL=Collapsible.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/tailwind.ts","../../src/components/Pressable.tsx","../../src/components/Text.tsx","../../src/utils/index.ts","../../src/components/Collapsible.tsx"],"names":["focusRingStyles","Pressable","children","type","className","disabled","props","React","HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","size","fontWeight","processVariants","variants","breakpoint","typographyClass","Text","color","as","weight","ref","typographyClasses","colorClasses","suggestedElement","baseVariant","cn","inputs","twMerge","clsx","Collapsible","maxHeight","open","setOpen","contentRef","useRef","contentHeight","setContentHeight","useState","useLayoutEffect","resizeObserver","entries","entry","shouldShowTrigger","i"],"mappings":"gmBAmEO,IAAMA,CAAAA,CACX,qGC/DK,CAAA,IAAMC,EAAsC,CAAC,CAClD,QAAAC,CAAAA,CAAAA,CACA,IAAAC,CAAAA,CAAAA,CAAO,SACP,SAAAC,CAAAA,CAAAA,CACA,SAAAC,CACA,CAAA,GAAGC,CACL,CACEC,GAAAA,kBAAAA,CAAA,aAAC,CAAA,QAAA,CAAA,CAEC,IAAMJ,CAAAA,CAAAA,CACN,SAAUE,CACV,CAAA,SAAA,CAAW,CAAmEL,gEAAAA,EAAAA,CAAe,CAAII,CAAAA,EAAAA,CAAS,IAAIC,CAAW,CAAA,+BAAA,CAAkC,EAAE,CAAA,CAAA,CAC5J,GAAGC,CAAAA,CAAAA,CAEHJ,CACH,CCpBF,CA4FA,IAAMM,EAAmD,CACvD,EAAA,CAAI,IACJ,CAAA,EAAA,CAAI,IACJ,CAAA,EAAA,CAAI,KACJ,EAAI,CAAA,IAAA,CACJ,EAAI,CAAA,IACN,CAEMC,CAAAA,CAAAA,CAAyBC,GAAwC,CACrE,GAAM,CAACC,CAAAA,CAAUC,CAAI,CAAA,CAAIF,EAAQ,KAAM,CAAA,GAAG,CAE1C,CAAA,OAAIC,CAAa,GAAA,SAAA,CACRH,EAAoBI,CAAI,CAAA,EAAK,GAGlCD,CAAAA,CAAAA,GAAa,OACR,CAAA,OAAA,CAGF,GACT,CAIME,CAAAA,CAAAA,CAAqC,CACzC,KAAA,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CAAA,UAAA,EAC9B,CAAG,CAAA,EAAE,CAAA,CAEL,IAAMG,CAAAA,CAAoBP,EAAgBL,CAE1C,CAAA,OACEzB,kBAAA,CAAA,aAAA,CAAkBsC,YAAjB,CAAA,IAAA,CAAA,CAAsB,KAAMZ,CAAM,CAAA,YAAA,CAAcC,CAC/C3B,CAAAA,CAAAA,kBAAAA,CAAA,aAAC,CAAA,KAAA,CAAA,CAAI,UAAU,UACbA,CAAAA,CAAAA,kBAAAA,CAAA,aAAC,CAAA,KAAA,CAAA,CACC,SAAU,CAAA,8DAAA,CACV,MAAO,CACL,MAAA,CAAQ0B,CAAO,CAAA,CAAA,EAAGI,CAAa,CAAA,EAAA,CAAA,CAAO,GAAGL,CAAS,CAAA,EAAA,CACpD,GAEAzB,kBAAA,CAAA,aAAA,CAAC,OAAI,GAAK4B,CAAAA,CAAAA,CAAY,SAAU,CAAA,QAAA,CAAA,CAC7BjC,CACH,CACF,EAEC0C,CACCrC,EAAAA,kBAAAA,CAAA,aAAkB,CAAAsC,YAAA,CAAA,OAAA,CAAjB,CAAyB,OAAA,CAAO,IAC/BtC,kBAAA,CAAA,aAAA,CAACN,CAAA,CAAA,CACC,SAAW0B,CAAAA,CAAAA,CACT,oCACA,+BACA,CAAA,gBAAA,CACA,CAACM,CAAAA,EAAQ,sDACT,CAAA,sCACF,GAEA1B,kBAAA,CAAA,aAAA,CAACW,CAAA,CAAA,CAAK,OAAQ,CAAA,eAAA,CAAgB,MAAM,gBACjCe,CAAAA,CAAAA,CAAAA,CAAO,UAAa,CAAA,UACvB,CACF,CACF,CAEJ,CACF,CAEJ,EAEAF,CAAAA,CAAY,WAAc,CAAA,aAAA","file":"Collapsible.cjs","sourcesContent":["import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\n","import React, { ButtonHTMLAttributes } from \"react\";\nimport { focusRingStyles } from \"../utils/tailwind\";\n\nexport type PressableProps = ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const Pressable: React.FC<PressableProps> = ({\n children,\n type = \"button\",\n className,\n disabled,\n ...props\n}) => (\n <button\n // eslint-disable-next-line react/butt on-has-type\n type={type}\n disabled={disabled}\n className={`appearance-none hover:opacity-80 transition-all active:scale-95 ${focusRingStyles} ${className} ${disabled ? \"opacity-50 cursor-not-allowed\" : \"\"}`}\n {...props}\n >\n {children}\n </button>\n);\n","import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\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\nexport const noopFn = () => {};\n","import React, { useRef, useLayoutEffect, useState } from \"react\";\nimport * as RadixCollapsible from \"@radix-ui/react-collapsible\";\nimport { Pressable } from \"./Pressable\";\nimport { Text } from \"./Text\";\nimport { cn } from \"../utils\";\n\nexport type CollapsibleProps = {\n children: React.ReactNode;\n maxHeight?: number;\n};\n\nexport const Collapsible = ({\n children,\n maxHeight = 100\n}: CollapsibleProps) => {\n const [open, setOpen] = React.useState(false);\n const contentRef = useRef<HTMLDivElement>(null);\n const [contentHeight, setContentHeight] = useState<number>(maxHeight);\n\n // Measure content height on mount and resize\n useLayoutEffect(() => {\n if (!contentRef.current) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setContentHeight(entry.target.scrollHeight);\n }\n });\n\n resizeObserver.observe(contentRef.current);\n return () => resizeObserver.disconnect();\n }, []);\n\n const shouldShowTrigger = contentHeight > maxHeight;\n\n return (\n <RadixCollapsible.Root open={open} onOpenChange={setOpen}>\n <div className=\"relative\">\n <div\n className=\"overflow-hidden transition-[height] duration-300 ease-in-out\"\n style={{\n height: open ? `${contentHeight}px` : `${maxHeight}px`\n }}\n >\n <div ref={contentRef} className=\"w-full\">\n {children}\n </div>\n </div>\n\n {shouldShowTrigger && (\n <RadixCollapsible.Trigger asChild>\n <Pressable\n className={cn(\n \"absolute -bottom-8 left-0 right-0\",\n \"flex items-end justify-center\",\n \"h-16 pt-8 pb-2\",\n !open && \"bg-gradient-to-b from-transparent via-white to-white\",\n \"hover:opacity-100 transition-opacity\"\n )}\n >\n <Text variant=\"label-default\" color=\"text-secondary\">\n {open ? \"See less\" : \"See more\"}\n </Text>\n </Pressable>\n </RadixCollapsible.Trigger>\n )}\n </div>\n </RadixCollapsible.Root>\n );\n};\n\nCollapsible.displayName = \"Collapsible\";\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
type CollapsibleProps = {
|
|
4
|
+
children: React__default.ReactNode;
|
|
5
|
+
maxHeight?: number;
|
|
6
|
+
};
|
|
7
|
+
declare const Collapsible: {
|
|
8
|
+
({ children, maxHeight }: CollapsibleProps): React__default.JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { Collapsible, type CollapsibleProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
type CollapsibleProps = {
|
|
4
|
+
children: React__default.ReactNode;
|
|
5
|
+
maxHeight?: number;
|
|
6
|
+
};
|
|
7
|
+
declare const Collapsible: {
|
|
8
|
+
({ children, maxHeight }: CollapsibleProps): React__default.JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { Collapsible, type CollapsibleProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import n,{useRef,useState,useLayoutEffect}from'react';import*as i from'@radix-ui/react-collapsible';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';var h="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";var u=({children:e,type:t="button",className:o,disabled:s,...r})=>n.createElement("button",{type:t,disabled:s,className:`appearance-none hover:opacity-80 transition-all active:scale-95 ${h} ${o} ${s?"opacity-50 cursor-not-allowed":""}`,...r},e);var H={xl:"h1",lg:"h1",md:"h2",sm:"h3",xs:"h4"},M=e=>{let[t,o]=e.split("-");return t==="heading"?H[o]||"p":t==="label"?"label":"p"},L={light:"font-light",regular:"font-regular",semibold:"font-semibold",bold:"font-bold"},x=e=>e?(Array.isArray(e)?e:[e]).map(o=>{if(o.includes(":")){let[s,r]=o.split(":");return `${s}:text-${r}`}return `text-${o}`}).join(" "):"text-body-default",g=n.forwardRef(({variant:e="body-default",color:t="text-primary",as:o,className:s,children:r,weight:a,...p},c)=>{let l=x(e),y=t&&t==="inherit"?"inherit":t?`text-${t}`:"",T=n.useMemo(()=>{let b=typeof e=="string"?e.split(":").pop():Array.isArray(e)?e[0].split(":").pop():"body-default";return M(b)},[e]);return n.createElement(o||T,{ref:c,className:`font-sans antialiased ${l} ${y} ${a?`!${L[a]}`:""} ${s??""}`,...p},r)});g.displayName="Text";function d(...e){return twMerge(clsx(e))}var v=({children:e,maxHeight:t=100})=>{let[o,s]=n.useState(!1),r=useRef(null),[a,p]=useState(t);useLayoutEffect(()=>{if(!r.current)return;let l=new ResizeObserver(y=>{for(let T of y)p(T.target.scrollHeight);});return l.observe(r.current),()=>l.disconnect()},[]);let c=a>t;return n.createElement(i.Root,{open:o,onOpenChange:s},n.createElement("div",{className:"relative"},n.createElement("div",{className:"overflow-hidden transition-[height] duration-300 ease-in-out",style:{height:o?`${a}px`:`${t}px`}},n.createElement("div",{ref:r,className:"w-full"},e)),c&&n.createElement(i.Trigger,{asChild:!0},n.createElement(u,{className:d("absolute -bottom-8 left-0 right-0","flex items-end justify-center","h-16 pt-8 pb-2",!o&&"bg-gradient-to-b from-transparent via-white to-white","hover:opacity-100 transition-opacity")},n.createElement(g,{variant:"label-default",color:"text-secondary"},o?"See less":"See more")))))};v.displayName="Collapsible";if (exports.default) module.exports = exports.default;export{v as Collapsible};//# sourceMappingURL=Collapsible.js.map
|
|
2
|
+
//# sourceMappingURL=Collapsible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/tailwind.ts","../../src/components/Pressable.tsx","../../src/components/Text.tsx","../../src/utils/index.ts","../../src/components/Collapsible.tsx"],"names":["focusRingStyles","Pressable","children","type","className","disabled","props","React","HEADING_ELEMENT_MAP","getElementFromVariant","variant","category","size","fontWeight","processVariants","variants","breakpoint","typographyClass","Text","color","as","weight","ref","typographyClasses","colorClasses","suggestedElement","baseVariant","cn","inputs","twMerge","clsx","Collapsible","maxHeight","open","setOpen","contentRef","useRef","contentHeight","setContentHeight","useState","useLayoutEffect","resizeObserver","entries","entry","shouldShowTrigger"],"mappings":"iKAmEO,IAAMA,CAAAA,CACX,qGC/DK,CAAA,IAAMC,EAAsC,CAAC,CAClD,QAAAC,CAAAA,CAAAA,CACA,IAAAC,CAAAA,CAAAA,CAAO,SACP,SAAAC,CAAAA,CAAAA,CACA,SAAAC,CACA,CAAA,GAAGC,CACL,CACEC,GAAAA,CAAAA,CAAA,aAAC,CAAA,QAAA,CAAA,CAEC,IAAMJ,CAAAA,CAAAA,CACN,SAA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AAA,CAAjB,CAAyB,OAAA,CAAO,IAC/BA,CAAA,CAAA,aAAA,CAACN,CAAA,CAAA,CACC,SAAW0B,CAAAA,CAAAA,CACT,oCACA,+BACA,CAAA,gBAAA,CACA,CAACM,CAAAA,EAAQ,sDACT,CAAA,sCACF,GAEA1B,CAAA,CAAA,aAAA,CAACW,CAAA,CAAA,CAAK,OAAQ,CAAA,eAAA,CAAgB,MAAM,gBACjCe,CAAAA,CAAAA,CAAAA,CAAO,UAAa,CAAA,UACvB,CACF,CACF,CAEJ,CACF,CAEJ,EAEAF,CAAAA,CAAY,WAAc,CAAA,aAAA","file":"Collapsible.js","sourcesContent":["import { Colors, Typography } from \"../types/tailwind\";\n\n// Generate safelist patterns for all color utilities so you can use any theme color variable in your code\nexport const generateSafelist = (colors: Colors, typography: Typography) => {\n const colorNames = Object.keys(colors) as (keyof Colors)[];\n const utilities = [\"bg\", \"text\", \"border\", \"ring\", \"divide\", \"outline\"];\n const variants = [\"hover:\", \"focus:\", \"active:\", \"disabled:\"];\n\n const safelist: string[] = [];\n\n colorNames.forEach((colorName) => {\n if (typeof colors[colorName] === \"object\") {\n // Handle nested color objects (with number keys)\n Object.keys(colors[colorName]).forEach((shade) => {\n utilities.forEach((utility) => {\n // Base utility\n safelist.push(`${utility}-${colorName}-${shade}`);\n\n // Variant utilities\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}-${shade}`);\n });\n });\n });\n } else {\n // Handle direct color values\n utilities.forEach((utility) => {\n safelist.push(`${utility}-${colorName}`);\n\n variants.forEach((variant) => {\n safelist.push(`${variant}${utility}-${colorName}`);\n });\n });\n }\n });\n\n // Generate typography classes\n Object.entries(typography).forEach(([family, sizes]) => {\n Object.keys(sizes).forEach((size) => {\n // Base typography classes\n safelist.push(`text-${family}-${size}`);\n\n // Add variants\n variants.forEach((variant) => {\n safelist.push(`${variant}text-${family}-${size}`);\n });\n });\n });\n\n const breakpoints = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\"];\n const typographyClasses = Object.entries(typography).flatMap(\n ([category, sizes]) =>\n Object.keys(sizes).map((size) => `text-${category}-${size}`)\n );\n\n // Generate responsive variants\n const responsiveTypographyClasses = typographyClasses.flatMap((className) =>\n breakpoints.map((breakpoint) => `${breakpoint}:${className}`)\n );\n\n return [\n ...typographyClasses,\n ...responsiveTypographyClasses\n // ... rest of your safelist\n ];\n};\n\nexport const focusRingStyles =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\";\n\nexport const focusRingStylesCoerced = \"ring-2 ring-ring ring-offset-2\";\n","import React, { ButtonHTMLAttributes } from \"react\";\nimport { focusRingStyles } from \"../utils/tailwind\";\n\nexport type PressableProps = ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const Pressable: React.FC<PressableProps> = ({\n children,\n type = \"button\",\n className,\n disabled,\n ...props\n}) => (\n <button\n // eslint-disable-next-line react/butt on-has-type\n type={type}\n disabled={disabled}\n className={`appearance-none hover:opacity-80 transition-all active:scale-95 ${focusRingStyles} ${className} ${disabled ? \"opacity-50 cursor-not-allowed\" : \"\"}`}\n {...props}\n >\n {children}\n </button>\n);\n","import React from \"react\";\nimport {\n Colors,\n TextColorVariant,\n PrimaryShades,\n SecondaryShades,\n TertiaryShades,\n Typography\n} from \"../types/tailwind\";\n\ntype TextElement =\n | \"p\"\n | \"span\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"strong\"\n | \"em\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"small\"\n | \"label\"\n | \"a\";\n\n// HTML element mapping type\ntype HTMLElementByTag = {\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n strong: HTMLElement;\n em: HTMLElement;\n blockquote: HTMLQuoteElement;\n pre: HTMLPreElement;\n code: HTMLElement;\n small: HTMLElement;\n label: HTMLLabelElement;\n a: HTMLAnchorElement;\n};\n\n// HTML props mapping type\ntype HTMLPropsMap = {\n p: React.HTMLAttributes<HTMLParagraphElement>;\n span: React.HTMLAttributes<HTMLSpanElement>;\n h1: React.HTMLAttributes<HTMLHeadingElement>;\n h2: React.HTMLAttributes<HTMLHeadingElement>;\n h3: React.HTMLAttributes<HTMLHeadingElement>;\n h4: React.HTMLAttributes<HTMLHeadingElement>;\n h5: React.HTMLAttributes<HTMLHeadingElement>;\n h6: React.HTMLAttributes<HTMLHeadingElement>;\n strong: React.HTMLAttributes<HTMLElement>;\n em: React.HTMLAttributes<HTMLElement>;\n blockquote: React.HTMLAttributes<HTMLQuoteElement>;\n pre: React.HTMLAttributes<HTMLPreElement>;\n code: React.HTMLAttributes<HTMLElement>;\n small: React.HTMLAttributes<HTMLElement>;\n label: React.LabelHTMLAttributes<HTMLLabelElement>;\n a: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"color\">;\n};\n\ntype ColorCategory = keyof Omit<Colors, \"stroke\" | \"background\">;\ntype ColorValue<T extends ColorCategory> = T extends \"text\"\n ? TextColorVariant\n : T extends \"primary\"\n ? keyof PrimaryShades\n : T extends \"secondary\"\n ? keyof SecondaryShades\n : T extends \"tertiary\"\n ? keyof TertiaryShades\n : never;\n\ntype ColorKey = {\n [T in ColorCategory]: `${T}-${ColorValue<T>}`;\n}[ColorCategory];\n\ntype TypographyCategory = keyof Typography;\ntype TypographyValue<T extends TypographyCategory> = Extract<\n keyof Typography[T],\n string | number | bigint | boolean | null | undefined\n>;\ntype TypographyKey = {\n [T in TypographyCategory]: `${T}-${TypographyValue<T>}`;\n}[TypographyCategory];\n\nconst HEADING_ELEMENT_MAP: Record<string, TextElement> = {\n xl: \"h1\",\n lg: \"h1\",\n md: \"h2\",\n sm: \"h3\",\n xs: \"h4\"\n};\n\nconst getElementFromVariant = (variant: TypographyKey): TextElement => {\n const [category, size] = variant.split(\"-\");\n\n if (category === \"heading\") {\n return HEADING_ELEMENT_MAP[size] || \"p\";\n }\n\n if (category === \"label\") {\n return \"label\";\n }\n\n return \"p\";\n};\n\ntype Weight = \"light\" | \"regular\" | \"semibold\" | \"bold\";\n\nconst fontWeight: Record<Weight, string> = {\n light: \"font-light\",\n regular: \"font-regular\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n};\n\n// Add breakpoint types\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\ntype ResponsiveVariant = TypographyKey | `${Breakpoint}:${TypographyKey}`;\n\n// Update TextProps to use ResponsiveVariant\nexport type TextProps<T extends TextElement = \"p\"> = {\n variant?: ResponsiveVariant | ResponsiveVariant[];\n color?: ColorKey | \"inherit\";\n as?: T;\n className?: string;\n children: React.ReactNode;\n weight?: Weight;\n} & HTMLPropsMap[T];\n\n// Add helper function to process variants\nconst processVariants = (\n variants: ResponsiveVariant | ResponsiveVariant[] | undefined\n): string => {\n if (!variants) return \"text-body-default\";\n\n const variantArray = Array.isArray(variants) ? variants : [variants];\n\n return variantArray\n .map((variant) => {\n if (variant.includes(\":\")) {\n const [breakpoint, typographyClass] = variant.split(\":\");\n return `${breakpoint}:text-${typographyClass}`;\n }\n return `text-${variant}`;\n })\n .join(\" \");\n};\n\nexport const Text = React.forwardRef(\n <T extends TextElement = \"p\">(\n {\n variant = \"body-default\",\n color = \"text-primary\",\n as,\n className,\n children,\n weight,\n ...props\n }: TextProps<T>,\n ref: React.ForwardedRef<HTMLElementByTag[T]>\n ) => {\n // Process typography classes with breakpoints\n const typographyClasses = processVariants(variant);\n\n // Get color styles\n const colorClasses =\n color && color === \"inherit\" ? \"inherit\" : color ? `text-${color}` : \"\";\n\n const suggestedElement = React.useMemo(() => {\n const baseVariant =\n typeof variant === \"string\"\n ? variant.split(\":\").pop()!\n : Array.isArray(variant)\n ? variant[0].split(\":\").pop()!\n : \"body-default\";\n return getElementFromVariant(baseVariant as TypographyKey);\n }, [variant]);\n\n const Component = (as || suggestedElement) as T;\n\n return (\n // @ts-expect-error TODO: figure this out\n <Component\n ref={ref}\n className={`font-sans antialiased ${typographyClasses} ${colorClasses} ${\n weight ? `!${fontWeight[weight]}` : \"\"\n } ${className ?? \"\"}`}\n {...props}\n >\n {children}\n </Component>\n );\n }\n);\n\nText.displayName = \"Text\";\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\nexport const noopFn = () => {};\n","import React, { useRef, useLayoutEffect, useState } from \"react\";\nimport * as RadixCollapsible from \"@radix-ui/react-collapsible\";\nimport { Pressable } from \"./Pressable\";\nimport { Text } from \"./Text\";\nimport { cn } from \"../utils\";\n\nexport type CollapsibleProps = {\n children: React.ReactNode;\n maxHeight?: number;\n};\n\nexport const Collapsible = ({\n children,\n maxHeight = 100\n}: CollapsibleProps) => {\n const [open, setOpen] = React.useState(false);\n const contentRef = useRef<HTMLDivElement>(null);\n const [contentHeight, setContentHeight] = useState<number>(maxHeight);\n\n // Measure content height on mount and resize\n useLayoutEffect(() => {\n if (!contentRef.current) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setContentHeight(entry.target.scrollHeight);\n }\n });\n\n resizeObserver.observe(contentRef.current);\n return () => resizeObserver.disconnect();\n }, []);\n\n const shouldShowTrigger = contentHeight > maxHeight;\n\n return (\n <RadixCollapsible.Root open={open} onOpenChange={setOpen}>\n <div className=\"relative\">\n <div\n className=\"overflow-hidden transition-[height] duration-300 ease-in-out\"\n style={{\n height: open ? `${contentHeight}px` : `${maxHeight}px`\n }}\n >\n <div ref={contentRef} className=\"w-full\">\n {children}\n </div>\n </div>\n\n {shouldShowTrigger && (\n <RadixCollapsible.Trigger asChild>\n <Pressable\n className={cn(\n \"absolute -bottom-8 left-0 right-0\",\n \"flex items-end justify-center\",\n \"h-16 pt-8 pb-2\",\n !open && \"bg-gradient-to-b from-transparent via-white to-white\",\n \"hover:opacity-100 transition-opacity\"\n )}\n >\n <Text variant=\"label-default\" color=\"text-secondary\">\n {open ? \"See less\" : \"See more\"}\n </Text>\n </Pressable>\n </RadixCollapsible.Trigger>\n )}\n </div>\n </RadixCollapsible.Root>\n );\n};\n\nCollapsible.displayName = \"Collapsible\";\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var i=require('react'),p=require('@radix-ui/react-popover'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),icons=require('@deckai/icons');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var i__namespace=/*#__PURE__*/_interopNamespace(i);var p__namespace=/*#__PURE__*/_interopNamespace(p);function m(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var P="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",$="ring-2 ring-ring ring-offset-2";var I={primary:"#080808",secondary:"#666666",white:"#ffffff",primaryBlue:"#089CCB"},M={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},T=e=>{if(!e)return {width:"24px",height:"24px"};let r=Array.isArray(e)?e:[e],o={},t;return r.forEach(s=>{if(typeof s=="number")t=`${s}px`;else {let[a,n]=s.split(":"),c=parseInt(n,10);o[`@media (min-width: ${M[a]})`]=`${c}px`;}}),{width:t||"24px",height:t||"24px",...Object.entries(o).reduce((s,[a,n])=>({...s,[a]:{width:n,height:n}}),{})}},b=i__namespace.default.forwardRef(({name:e,size:r=24,color:o="primary",title:t,className:s,style:a={},...n},c)=>{let f=icons.IconMap[e],u=T(r);return i__namespace.default.createElement("div",{className:m("flex justify-center items-center",s),style:{...u,"--icon-stroke":I[o],...a}},i__namespace.default.createElement(f,{ref:c,"aria-hidden":!t,"aria-label":t,stroke:e.includes("filled")?void 0:I[o],...n}))});b.displayName="Icon";var S=({className:e,end:r,iconName:o,color:t,size:s,title:a,label:n,labelClassName:c,id:f,...u})=>i__namespace.createElement("div",{className:"space-y-2"},n&&i__namespace.createElement("label",{htmlFor:f,className:m("block text-sm font-medium text-text-primary",c)},n),i__namespace.createElement("div",{className:"relative"},i__namespace.createElement("input",{id:f,className:m(`font-sans lg:text-body-default text-xs flex w-full rounded-lg border border-secondary-50 bg-background-0 px-3 md:py-3 py-2 text-secondary ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-secondary text-text-primary ${P} disabled:cursor-not-allowed disabled:opacity-50 md:text-md`,r&&"pr-10",e),...u}),r&&i__namespace.createElement("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3"},o?i__namespace.createElement(b,{name:o,color:t,size:s,title:a}):r)));var N=({value:e,label:r,onChange:o,selected:t})=>i__namespace.default.createElement("button",{type:"button",className:m("relative w-full h-full text-left px-2 py-1.5 text-sm cursor-pointer hover:bg-gray-100 rounded",t&&"bg-gray-100"),onClick:()=>{o?.(e);}},r);var le=({options:e,placeholder:r="Select an item...",value:o,onChange:t,end:s,className:a,label:n,labelClassName:c,id:f})=>{let[u,v]=i.useState(!1),[g,y]=i.useState(o),h=i.useMemo(()=>e.find(l=>l.value===g),[g,e]),C=e.filter(l=>g?l.label.toLowerCase().includes(g.toLowerCase()):e),k=i.useCallback(l=>{t(l),v(!1),y(h?.label);},[t,h?.label]);return i__namespace.default.createElement(p__namespace.Root,{open:u,onOpenChange:v},i__namespace.default.createElement("div",{className:`relative w-full font-sans text-text-secondary ${a}`},i__namespace.default.createElement(p__namespace.Trigger,{asChild:!0},i__namespace.default.createElement("div",{className:"flex"},i__namespace.default.createElement("div",{className:"relative flex-1"},i__namespace.default.createElement(S,{id:f,label:n,labelClassName:c,placeholder:r,value:g,onChange:l=>y(l.target.value),end:s,className:`flex-1 ${u&&$}`})))),i__namespace.default.createElement(p__namespace.Portal,null,i__namespace.default.createElement(p__namespace.Content,{className:"w-[--radix-popover-trigger-width] p-1 bg-white rounded-md shadow-lg border mt-1 z-20",sideOffset:5},i__namespace.default.createElement("div",{className:"max-h-60 overflow-auto flex flex-col items-start"},C.length>0?C.map(({label:l,value:w},E)=>i__namespace.default.createElement(N,{onChange:k,value:w,key:E,label:l})):i__namespace.default.createElement("div",{className:"px-2 py-1.5 text-sm text-gray-500"},"No results found"))))))};if (exports.default) module.exports = exports.default;exports.Combobox=le;//# sourceMappingURL=Combobox.cjs.map
|
|
2
2
|
//# sourceMappingURL=Combobox.cjs.map
|