analytica-frontend-lib 1.0.40 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProgressBar/index.js +9 -12
- package/dist/ProgressBar/index.js.map +1 -1
- package/dist/ProgressBar/index.mjs +9 -12
- package/dist/ProgressBar/index.mjs.map +1 -1
- package/dist/Radio/index.js +8 -34
- package/dist/Radio/index.js.map +1 -1
- package/dist/Radio/index.mjs +8 -34
- package/dist/Radio/index.mjs.map +1 -1
- package/dist/index.css +37 -9
- package/dist/index.css.map +1 -1
- package/dist/index.js +17 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -46
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +37 -9
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
|
@@ -83,7 +83,6 @@ var SIZE_CLASSES = {
|
|
|
83
83
|
// 4px height (h-1 = 4px in Tailwind)
|
|
84
84
|
bar: "h-1",
|
|
85
85
|
// 4px height for the fill bar
|
|
86
|
-
labelSize: "xs",
|
|
87
86
|
spacing: "gap-2",
|
|
88
87
|
// 8px gap between label and progress bar
|
|
89
88
|
layout: "flex-col",
|
|
@@ -96,8 +95,6 @@ var SIZE_CLASSES = {
|
|
|
96
95
|
// 8px height (h-2 = 8px in Tailwind)
|
|
97
96
|
bar: "h-2",
|
|
98
97
|
// 8px height for the fill bar
|
|
99
|
-
labelSize: "xs",
|
|
100
|
-
// 12px font size (xs in Tailwind)
|
|
101
98
|
spacing: "gap-2",
|
|
102
99
|
// 8px gap between progress bar and label
|
|
103
100
|
layout: "flex-row items-center",
|
|
@@ -139,25 +136,25 @@ var ProgressBar = ({
|
|
|
139
136
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
140
137
|
"div",
|
|
141
138
|
{
|
|
142
|
-
className: `flex ${sizeClasses.layout} ${sizeClasses.spacing} ${className}`,
|
|
139
|
+
className: `flex ${sizeClasses.layout} ${size === "medium" ? "gap-2" : sizeClasses.spacing} ${className}`,
|
|
143
140
|
children: [
|
|
144
141
|
size === "small" && (label || showPercentage) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-row items-center justify-between w-full", children: [
|
|
145
142
|
label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
146
143
|
Text_default,
|
|
147
144
|
{
|
|
148
145
|
as: "div",
|
|
149
|
-
size:
|
|
146
|
+
size: "xs",
|
|
150
147
|
weight: "medium",
|
|
151
|
-
className: `text-text-950 ${labelClassName}`,
|
|
148
|
+
className: `text-text-950 leading-none tracking-normal text-center ${labelClassName}`,
|
|
152
149
|
children: label
|
|
153
150
|
}
|
|
154
151
|
),
|
|
155
152
|
showPercentage && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
156
153
|
Text_default,
|
|
157
154
|
{
|
|
158
|
-
size:
|
|
155
|
+
size: "xs",
|
|
159
156
|
weight: "medium",
|
|
160
|
-
className: `text-text-
|
|
157
|
+
className: `text-text-950 leading-none tracking-normal text-center ${percentageClassName}`,
|
|
161
158
|
children: [
|
|
162
159
|
Math.round(percentage),
|
|
163
160
|
"%"
|
|
@@ -192,9 +189,9 @@ var ProgressBar = ({
|
|
|
192
189
|
size === "medium" && showPercentage && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
193
190
|
Text_default,
|
|
194
191
|
{
|
|
195
|
-
size:
|
|
192
|
+
size: "xs",
|
|
196
193
|
weight: "medium",
|
|
197
|
-
className: `text-text-950 text-center flex-none
|
|
194
|
+
className: `text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`,
|
|
198
195
|
children: [
|
|
199
196
|
Math.round(percentage),
|
|
200
197
|
"%"
|
|
@@ -205,9 +202,9 @@ var ProgressBar = ({
|
|
|
205
202
|
Text_default,
|
|
206
203
|
{
|
|
207
204
|
as: "div",
|
|
208
|
-
size:
|
|
205
|
+
size: "xs",
|
|
209
206
|
weight: "medium",
|
|
210
|
-
className: `text-text-950 flex-none ${labelClassName}`,
|
|
207
|
+
className: `text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`,
|
|
211
208
|
children: label
|
|
212
209
|
}
|
|
213
210
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/ProgressBar/ProgressBar.tsx","../../src/components/Text/Text.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport Text from '../Text/Text';\n\n/**\n * Progress bar size variants\n */\ntype ProgressBarSize = 'small' | 'medium';\n\n/**\n * Progress bar color variants\n */\ntype ProgressBarVariant = 'blue' | 'green';\n\n/**\n * Size configurations using Tailwind classes\n */\nconst SIZE_CLASSES = {\n small: {\n container: 'h-1', // 4px height (h-1 = 4px in Tailwind)\n bar: 'h-1', // 4px height for the fill bar\n labelSize: 'xs' as const,\n spacing: 'gap-2', // 8px gap between label and progress bar\n layout: 'flex-col', // vertical layout for small\n borderRadius: 'rounded-full', // 9999px border radius\n },\n medium: {\n container: 'h-2', // 8px height (h-2 = 8px in Tailwind)\n bar: 'h-2', // 8px height for the fill bar\n labelSize: 'xs' as const, // 12px font size (xs in Tailwind)\n spacing: 'gap-2', // 8px gap between progress bar and label\n layout: 'flex-row items-center', // horizontal layout for medium\n borderRadius: 'rounded-lg', // 8px border radius\n },\n} as const;\n\n/**\n * Color configurations using design system colors\n */\nconst VARIANT_CLASSES = {\n blue: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-primary-700', // Blue for activity progress (#2271C4)\n },\n green: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-success-200', // Green for performance (#84D3A2)\n },\n} as const;\n\n/**\n * ProgressBar component props interface\n */\nexport type ProgressBarProps = {\n /** Progress value between 0 and 100 */\n value: number;\n /** Maximum value (defaults to 100) */\n max?: number;\n /** Size variant of the progress bar */\n size?: ProgressBarSize;\n /** Color variant of the progress bar */\n variant?: ProgressBarVariant;\n /** Optional label to display */\n label?: ReactNode;\n /** Show percentage text */\n showPercentage?: boolean;\n /** Additional CSS classes */\n className?: string;\n /** Label CSS classes */\n labelClassName?: string;\n /** Percentage text CSS classes */\n percentageClassName?: string;\n};\n\n/**\n * ProgressBar component for Analytica Ensino platforms\n *\n * A progress bar component with size and color variants designed for tracking\n * activity progress (blue) and performance metrics (green).\n * Uses the Analytica Ensino Design System colors from styles.css with automatic\n * light/dark mode support. Includes Text component integration for consistent typography.\n *\n * @example\n * ```tsx\n * // Basic progress bar\n * <ProgressBar value={65} />\n *\n * // Activity progress (blue)\n * <ProgressBar variant=\"blue\" value={45} label=\"Progress\" showPercentage />\n *\n * // Performance metrics (green)\n * <ProgressBar variant=\"green\" size=\"medium\" value={85} label=\"Performance\" />\n *\n * // Small size with custom max value\n * <ProgressBar size=\"small\" value={3} max={5} showPercentage />\n * ```\n */\nconst ProgressBar = ({\n value,\n max = 100,\n size = 'medium',\n variant = 'blue',\n label,\n showPercentage = false,\n className = '',\n labelClassName = '',\n percentageClassName = '',\n}: ProgressBarProps) => {\n // Ensure value is within bounds and handle NaN/Infinity\n const safeValue = isNaN(value) ? 0 : value;\n const clampedValue = Math.max(0, Math.min(safeValue, max));\n const percentage = max === 0 ? 0 : (clampedValue / max) * 100;\n\n // Get size and variant classes\n const sizeClasses = SIZE_CLASSES[size];\n const variantClasses = VARIANT_CLASSES[variant];\n\n return (\n <div\n className={`flex ${sizeClasses.layout} ${sizeClasses.spacing} ${className}`}\n >\n {/* For small size: vertical layout with label/percentage on top */}\n {size === 'small' && (label || showPercentage) && (\n <div className=\"flex flex-row items-center justify-between w-full\">\n {/* Label */}\n {label && (\n <Text\n as=\"div\"\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-950 ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n\n {/* Percentage */}\n {showPercentage && (\n <Text\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-700 text-center ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n </div>\n )}\n\n {/* Progress bar container */}\n <div\n className={`${size === 'medium' ? 'flex-grow' : 'w-full'} ${sizeClasses.container} ${variantClasses.background} ${sizeClasses.borderRadius} overflow-hidden relative`}\n >\n {/* Native progress element for accessibility */}\n <progress\n value={clampedValue}\n max={max}\n aria-label={typeof label === 'string' ? label : 'Progress'}\n className=\"absolute inset-0 w-full h-full opacity-0\"\n />\n\n {/* Progress bar fill */}\n <div\n className={`${sizeClasses.bar} ${variantClasses.fill} ${sizeClasses.borderRadius} transition-all duration-300 ease-out shadow-hard-shadow-3`}\n style={{ width: `${percentage}%` }}\n />\n </div>\n\n {/* For medium size: horizontal layout with percentage on the right */}\n {size === 'medium' && showPercentage && (\n <Text\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-950 text-center flex-none w-[70px] ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n\n {/* For medium size: label below if provided */}\n {size === 'medium' && label && !showPercentage && (\n <Text\n as=\"div\"\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-950 flex-none ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n </div>\n );\n};\n\nexport default ProgressBar;\n","import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';\n\n/**\n * Base text component props\n */\ntype BaseTextProps = {\n /** Content to be displayed */\n children?: ReactNode;\n /** Text size variant */\n size?:\n | '2xs'\n | 'xs'\n | 'sm'\n | 'md'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl'\n | '5xl'\n | '6xl';\n /** Font weight variant */\n weight?:\n | 'hairline'\n | 'light'\n | 'normal'\n | 'medium'\n | 'semibold'\n | 'bold'\n | 'extrabold'\n | 'black';\n /** Color variant - white for light backgrounds, black for dark backgrounds */\n color?: string;\n /** Additional CSS classes to apply */\n className?: string;\n};\n\n/**\n * Polymorphic text component props that ensures type safety based on the 'as' prop\n */\ntype TextProps<T extends ElementType = 'p'> = BaseTextProps & {\n /** HTML tag to render */\n as?: T;\n} & Omit<ComponentPropsWithoutRef<T>, keyof BaseTextProps>;\n\n/**\n * Text component for Analytica Ensino platforms\n *\n * A flexible polymorphic text component with multiple sizes, weights, and colors.\n * Automatically adapts to dark and light themes with full type safety.\n *\n * @param children - The content to display\n * @param size - The text size variant (2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl)\n * @param weight - The font weight variant (hairline, light, normal, medium, semibold, bold, extrabold, black)\n * @param color - The color variant - adapts to theme\n * @param as - The HTML tag to render - determines allowed attributes via TypeScript\n * @param className - Additional CSS classes\n * @param props - HTML attributes valid for the chosen tag only\n * @returns A styled text element with type-safe attributes\n *\n * @example\n * ```tsx\n * <Text size=\"lg\" weight=\"bold\" color=\"text-info-800\">\n * This is a large, bold text\n * </Text>\n *\n * <Text as=\"a\" href=\"/link\" target=\"_blank\">\n * Link with type-safe anchor attributes\n * </Text>\n *\n * <Text as=\"button\" onClick={handleClick} disabled>\n * Button with type-safe button attributes\n * </Text>\n * ```\n */\nconst Text = <T extends ElementType = 'p'>({\n children,\n size = 'md',\n weight = 'normal',\n color = 'text-text-950',\n as,\n className = '',\n ...props\n}: TextProps<T>) => {\n let sizeClasses = '';\n let weightClasses = '';\n\n // Text size classes mapping\n const sizeClassMap = {\n '2xs': 'text-2xs',\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n lg: 'text-lg',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n '3xl': 'text-3xl',\n '4xl': 'text-4xl',\n '5xl': 'text-5xl',\n '6xl': 'text-6xl',\n } as const;\n\n sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;\n\n // Font weight classes mapping\n const weightClassMap = {\n hairline: 'font-hairline',\n light: 'font-light',\n normal: 'font-normal',\n medium: 'font-medium',\n semibold: 'font-semibold',\n bold: 'font-bold',\n extrabold: 'font-extrabold',\n black: 'font-black',\n } as const;\n\n weightClasses = weightClassMap[weight] ?? weightClassMap.normal;\n\n const baseClasses = 'font-primary';\n const Component = as ?? ('p' as ElementType);\n\n return (\n <Component\n className={`${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`}\n {...props}\n >\n {children}\n </Component>\n );\n};\n\nexport default Text;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0HI;AA/CJ,IAAM,OAAO,CAA8B;AAAA,EACzC;AAAA,EACA,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,MAAoB;AAClB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AAGpB,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,IACP,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAEA,gBAAc,aAAa,IAAI,KAAK,aAAa;AAGjD,QAAM,iBAAiB;AAAA,IACrB,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,EACT;AAEA,kBAAgB,eAAe,MAAM,KAAK,eAAe;AAEzD,QAAM,cAAc;AACpB,QAAM,YAAY,MAAO;AAEzB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,WAAW,IAAI,WAAW,IAAI,aAAa,IAAI,KAAK,IAAI,SAAS;AAAA,MAC9E,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,eAAQ;;;ADNH,IAAAA,sBAAA;AA7GZ,IAAM,eAAe;AAAA,EACnB,OAAO;AAAA,IACL,WAAW;AAAA;AAAA,IACX,KAAK;AAAA;AAAA,IACL,WAAW;AAAA,IACX,SAAS;AAAA;AAAA,IACT,QAAQ;AA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;AAAA,cAE1D;AAAA,qBAAK,MAAM,UAAU;AAAA,gBAAE;AAAA;AAAA;AAAA,UAC1B;AAAA,WAEJ;AAAA,QAIF;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,GAAG,SAAS,WAAW,cAAc,QAAQ,IAAI,YAAY,SAAS,IAAI,eAAe,UAAU,IAAI,YAAY,YAAY;AAAA,YAG1I;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,OAAO;AAAA,kBACP;AAAA,kBACA,cAAY,OAAO,UAAU,WAAW,QAAQ;AAAA,kBAChD,WAAU;AAAA;AAAA,cACZ;AAAA,cAGA;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAW,GAAG,YAAY,GAAG,IAAI,eAAe,IAAI,IAAI,YAAY,YAAY;AAAA,kBAChF,OAAO,EAAE,OAAO,GAAG,UAAU,IAAI;AAAA;AAAA,cACnC;AAAA;AAAA;AAAA,QACF;AAAA,QAGC,SAAS,YAAY,kBACpB;AAAA,UAAC;AAAA;AAAA,YACC,MAAM,YAAY;AAAA,YAClB,QAAO;AAAA,YACP,WAAW,gDAAgD,mBAAmB;AAAA,YAE7E;AAAA,mBAAK,MAAM,UAAU;AAAA,cAAE;AAAA;AAAA;AAAA,QAC1B;AAAA,QAID,SAAS,YAAY,SAAS,CAAC,kBAC9B;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAM,YAAY;AAAA,YAClB,QAAO;AAAA,YACP,WAAW,2BAA2B,cAAc;AAAA,YAEnD;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,sBAAQ;","names":["import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/ProgressBar/ProgressBar.tsx","../../src/components/Text/Text.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport Text from '../Text/Text';\n\n/**\n * Progress bar size variants\n */\ntype ProgressBarSize = 'small' | 'medium';\n\n/**\n * Progress bar color variants\n */\ntype ProgressBarVariant = 'blue' | 'green';\n\n/**\n * Size configurations using Tailwind classes\n */\nconst SIZE_CLASSES = {\n small: {\n container: 'h-1', // 4px height (h-1 = 4px in Tailwind)\n bar: 'h-1', // 4px height for the fill bar\n spacing: 'gap-2', // 8px gap between label and progress bar\n layout: 'flex-col', // vertical layout for small\n borderRadius: 'rounded-full', // 9999px border radius\n },\n medium: {\n container: 'h-2', // 8px height (h-2 = 8px in Tailwind)\n bar: 'h-2', // 8px height for the fill bar\n spacing: 'gap-2', // 8px gap between progress bar and label\n layout: 'flex-row items-center', // horizontal layout for medium\n borderRadius: 'rounded-lg', // 8px border radius\n },\n} as const;\n\n/**\n * Color configurations using design system colors\n */\nconst VARIANT_CLASSES = {\n blue: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-primary-700', // Blue for activity progress (#2271C4)\n },\n green: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-success-200', // Green for performance (#84D3A2)\n },\n} as const;\n\n/**\n * ProgressBar component props interface\n */\nexport type ProgressBarProps = {\n /** Progress value between 0 and 100 */\n value: number;\n /** Maximum value (defaults to 100) */\n max?: number;\n /** Size variant of the progress bar */\n size?: ProgressBarSize;\n /** Color variant of the progress bar */\n variant?: ProgressBarVariant;\n /** Optional label to display */\n label?: ReactNode;\n /** Show percentage text */\n showPercentage?: boolean;\n /** Additional CSS classes */\n className?: string;\n /** Label CSS classes */\n labelClassName?: string;\n /** Percentage text CSS classes */\n percentageClassName?: string;\n};\n\n/**\n * ProgressBar component for Analytica Ensino platforms\n *\n * A progress bar component with size and color variants designed for tracking\n * activity progress (blue) and performance metrics (green).\n * Uses the Analytica Ensino Design System colors from styles.css with automatic\n * light/dark mode support. Includes Text component integration for consistent typography.\n *\n * @example\n * ```tsx\n * // Basic progress bar\n * <ProgressBar value={65} />\n *\n * // Activity progress (blue)\n * <ProgressBar variant=\"blue\" value={45} label=\"Progress\" showPercentage />\n *\n * // Performance metrics (green)\n * <ProgressBar variant=\"green\" size=\"medium\" value={85} label=\"Performance\" />\n *\n * // Small size with custom max value\n * <ProgressBar size=\"small\" value={3} max={5} showPercentage />\n * ```\n */\nconst ProgressBar = ({\n value,\n max = 100,\n size = 'medium',\n variant = 'blue',\n label,\n showPercentage = false,\n className = '',\n labelClassName = '',\n percentageClassName = '',\n}: ProgressBarProps) => {\n // Ensure value is within bounds and handle NaN/Infinity\n const safeValue = isNaN(value) ? 0 : value;\n const clampedValue = Math.max(0, Math.min(safeValue, max));\n const percentage = max === 0 ? 0 : (clampedValue / max) * 100;\n\n // Get size and variant classes\n const sizeClasses = SIZE_CLASSES[size];\n const variantClasses = VARIANT_CLASSES[variant];\n\n return (\n <div\n className={`flex ${sizeClasses.layout} ${size === 'medium' ? 'gap-2' : sizeClasses.spacing} ${className}`}\n >\n {/* For small size: vertical layout with label/percentage on top */}\n {size === 'small' && (label || showPercentage) && (\n <div className=\"flex flex-row items-center justify-between w-full\">\n {/* Label */}\n {label && (\n <Text\n as=\"div\"\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n\n {/* Percentage */}\n {showPercentage && (\n <Text\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n </div>\n )}\n\n {/* Progress bar container */}\n <div\n className={`${size === 'medium' ? 'flex-grow' : 'w-full'} ${sizeClasses.container} ${variantClasses.background} ${sizeClasses.borderRadius} overflow-hidden relative`}\n >\n {/* Native progress element for accessibility */}\n <progress\n value={clampedValue}\n max={max}\n aria-label={typeof label === 'string' ? label : 'Progress'}\n className=\"absolute inset-0 w-full h-full opacity-0\"\n />\n\n {/* Progress bar fill */}\n <div\n className={`${sizeClasses.bar} ${variantClasses.fill} ${sizeClasses.borderRadius} transition-all duration-300 ease-out shadow-hard-shadow-3`}\n style={{ width: `${percentage}%` }}\n />\n </div>\n\n {/* For medium size: horizontal layout with percentage on the right */}\n {size === 'medium' && showPercentage && (\n <Text\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n\n {/* For medium size: label below if provided */}\n {size === 'medium' && label && !showPercentage && (\n <Text\n as=\"div\"\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n </div>\n );\n};\n\nexport default ProgressBar;\n","import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';\n\n/**\n * Base text component props\n */\ntype BaseTextProps = {\n /** Content to be displayed */\n children?: ReactNode;\n /** Text size variant */\n size?:\n | '2xs'\n | 'xs'\n | 'sm'\n | 'md'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl'\n | '5xl'\n | '6xl';\n /** Font weight variant */\n weight?:\n | 'hairline'\n | 'light'\n | 'normal'\n | 'medium'\n | 'semibold'\n | 'bold'\n | 'extrabold'\n | 'black';\n /** Color variant - white for light backgrounds, black for dark backgrounds */\n color?: string;\n /** Additional CSS classes to apply */\n className?: string;\n};\n\n/**\n * Polymorphic text component props that ensures type safety based on the 'as' prop\n */\ntype TextProps<T extends ElementType = 'p'> = BaseTextProps & {\n /** HTML tag to render */\n as?: T;\n} & Omit<ComponentPropsWithoutRef<T>, keyof BaseTextProps>;\n\n/**\n * Text component for Analytica Ensino platforms\n *\n * A flexible polymorphic text component with multiple sizes, weights, and colors.\n * Automatically adapts to dark and light themes with full type safety.\n *\n * @param children - The content to display\n * @param size - The text size variant (2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl)\n * @param weight - The font weight variant (hairline, light, normal, medium, semibold, bold, extrabold, black)\n * @param color - The color variant - adapts to theme\n * @param as - The HTML tag to render - determines allowed attributes via TypeScript\n * @param className - Additional CSS classes\n * @param props - HTML attributes valid for the chosen tag only\n * @returns A styled text element with type-safe attributes\n *\n * @example\n * ```tsx\n * <Text size=\"lg\" weight=\"bold\" color=\"text-info-800\">\n * This is a large, bold text\n * </Text>\n *\n * <Text as=\"a\" href=\"/link\" target=\"_blank\">\n * Link with type-safe anchor attributes\n * </Text>\n *\n * <Text as=\"button\" onClick={handleClick} disabled>\n * Button with type-safe button attributes\n * </Text>\n * ```\n */\nconst Text = <T extends ElementType = 'p'>({\n children,\n size = 'md',\n weight = 'normal',\n color = 'text-text-950',\n as,\n className = '',\n ...props\n}: TextProps<T>) => {\n let sizeClasses = '';\n let weightClasses = '';\n\n // Text size classes mapping\n const sizeClassMap = {\n '2xs': 'text-2xs',\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n lg: 'text-lg',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n '3xl': 'text-3xl',\n '4xl': 'text-4xl',\n '5xl': 'text-5xl',\n '6xl': 'text-6xl',\n } as const;\n\n sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;\n\n // Font weight classes mapping\n const weightClassMap = {\n hairline: 'font-hairline',\n light: 'font-light',\n normal: 'font-normal',\n medium: 'font-medium',\n semibold: 'font-semibold',\n bold: 'font-bold',\n extrabold: 'font-extrabold',\n black: 'font-black',\n } as const;\n\n weightClasses = weightClassMap[weight] ?? weightClassMap.normal;\n\n const baseClasses = 'font-primary';\n const Component = as ?? ('p' as ElementType);\n\n return (\n <Component\n className={`${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`}\n {...props}\n >\n {children}\n </Component>\n );\n};\n\nexport default Text;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0HI;AA/CJ,IAAM,OAAO,CAA8B;AAAA,EACzC;AAAA,EACA,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,MAAoB;AAClB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AAGpB,Q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WAAW,GAAG,YAAY,GAAG,IAAI,eAAe,IAAI,IAAI,YAAY,YAAY;AAAA,kBAChF,OAAO,EAAE,OAAO,GAAG,UAAU,IAAI;AAAA;AAAA,cACnC;AAAA;AAAA;AAAA,QACF;AAAA,QAGC,SAAS,YAAY,kBACpB;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,QAAO;AAAA,YACP,WAAW,oEAAoE,mBAAmB;AAAA,YAEjG;AAAA,mBAAK,MAAM,UAAU;AAAA,cAAE;AAAA;AAAA;AAAA,QAC1B;AAAA,QAID,SAAS,YAAY,SAAS,CAAC,kBAC9B;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACL,QAAO;AAAA,YACP,WAAW,oEAAoE,cAAc;AAAA,YAE5F;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,sBAAQ;","names":["import_jsx_runtime"]}
|
|
@@ -57,7 +57,6 @@ var SIZE_CLASSES = {
|
|
|
57
57
|
// 4px height (h-1 = 4px in Tailwind)
|
|
58
58
|
bar: "h-1",
|
|
59
59
|
// 4px height for the fill bar
|
|
60
|
-
labelSize: "xs",
|
|
61
60
|
spacing: "gap-2",
|
|
62
61
|
// 8px gap between label and progress bar
|
|
63
62
|
layout: "flex-col",
|
|
@@ -70,8 +69,6 @@ var SIZE_CLASSES = {
|
|
|
70
69
|
// 8px height (h-2 = 8px in Tailwind)
|
|
71
70
|
bar: "h-2",
|
|
72
71
|
// 8px height for the fill bar
|
|
73
|
-
labelSize: "xs",
|
|
74
|
-
// 12px font size (xs in Tailwind)
|
|
75
72
|
spacing: "gap-2",
|
|
76
73
|
// 8px gap between progress bar and label
|
|
77
74
|
layout: "flex-row items-center",
|
|
@@ -113,25 +110,25 @@ var ProgressBar = ({
|
|
|
113
110
|
return /* @__PURE__ */ jsxs(
|
|
114
111
|
"div",
|
|
115
112
|
{
|
|
116
|
-
className: `flex ${sizeClasses.layout} ${sizeClasses.spacing} ${className}`,
|
|
113
|
+
className: `flex ${sizeClasses.layout} ${size === "medium" ? "gap-2" : sizeClasses.spacing} ${className}`,
|
|
117
114
|
children: [
|
|
118
115
|
size === "small" && (label || showPercentage) && /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between w-full", children: [
|
|
119
116
|
label && /* @__PURE__ */ jsx2(
|
|
120
117
|
Text_default,
|
|
121
118
|
{
|
|
122
119
|
as: "div",
|
|
123
|
-
size:
|
|
120
|
+
size: "xs",
|
|
124
121
|
weight: "medium",
|
|
125
|
-
className: `text-text-950 ${labelClassName}`,
|
|
122
|
+
className: `text-text-950 leading-none tracking-normal text-center ${labelClassName}`,
|
|
126
123
|
children: label
|
|
127
124
|
}
|
|
128
125
|
),
|
|
129
126
|
showPercentage && /* @__PURE__ */ jsxs(
|
|
130
127
|
Text_default,
|
|
131
128
|
{
|
|
132
|
-
size:
|
|
129
|
+
size: "xs",
|
|
133
130
|
weight: "medium",
|
|
134
|
-
className: `text-text-
|
|
131
|
+
className: `text-text-950 leading-none tracking-normal text-center ${percentageClassName}`,
|
|
135
132
|
children: [
|
|
136
133
|
Math.round(percentage),
|
|
137
134
|
"%"
|
|
@@ -166,9 +163,9 @@ var ProgressBar = ({
|
|
|
166
163
|
size === "medium" && showPercentage && /* @__PURE__ */ jsxs(
|
|
167
164
|
Text_default,
|
|
168
165
|
{
|
|
169
|
-
size:
|
|
166
|
+
size: "xs",
|
|
170
167
|
weight: "medium",
|
|
171
|
-
className: `text-text-950 text-center flex-none
|
|
168
|
+
className: `text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`,
|
|
172
169
|
children: [
|
|
173
170
|
Math.round(percentage),
|
|
174
171
|
"%"
|
|
@@ -179,9 +176,9 @@ var ProgressBar = ({
|
|
|
179
176
|
Text_default,
|
|
180
177
|
{
|
|
181
178
|
as: "div",
|
|
182
|
-
size:
|
|
179
|
+
size: "xs",
|
|
183
180
|
weight: "medium",
|
|
184
|
-
className: `text-text-950 flex-none ${labelClassName}`,
|
|
181
|
+
className: `text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`,
|
|
185
182
|
children: label
|
|
186
183
|
}
|
|
187
184
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Text/Text.tsx","../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';\n\n/**\n * Base text component props\n */\ntype BaseTextProps = {\n /** Content to be displayed */\n children?: ReactNode;\n /** Text size variant */\n size?:\n | '2xs'\n | 'xs'\n | 'sm'\n | 'md'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl'\n | '5xl'\n | '6xl';\n /** Font weight variant */\n weight?:\n | 'hairline'\n | 'light'\n | 'normal'\n | 'medium'\n | 'semibold'\n | 'bold'\n | 'extrabold'\n | 'black';\n /** Color variant - white for light backgrounds, black for dark backgrounds */\n color?: string;\n /** Additional CSS classes to apply */\n className?: string;\n};\n\n/**\n * Polymorphic text component props that ensures type safety based on the 'as' prop\n */\ntype TextProps<T extends ElementType = 'p'> = BaseTextProps & {\n /** HTML tag to render */\n as?: T;\n} & Omit<ComponentPropsWithoutRef<T>, keyof BaseTextProps>;\n\n/**\n * Text component for Analytica Ensino platforms\n *\n * A flexible polymorphic text component with multiple sizes, weights, and colors.\n * Automatically adapts to dark and light themes with full type safety.\n *\n * @param children - The content to display\n * @param size - The text size variant (2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl)\n * @param weight - The font weight variant (hairline, light, normal, medium, semibold, bold, extrabold, black)\n * @param color - The color variant - adapts to theme\n * @param as - The HTML tag to render - determines allowed attributes via TypeScript\n * @param className - Additional CSS classes\n * @param props - HTML attributes valid for the chosen tag only\n * @returns A styled text element with type-safe attributes\n *\n * @example\n * ```tsx\n * <Text size=\"lg\" weight=\"bold\" color=\"text-info-800\">\n * This is a large, bold text\n * </Text>\n *\n * <Text as=\"a\" href=\"/link\" target=\"_blank\">\n * Link with type-safe anchor attributes\n * </Text>\n *\n * <Text as=\"button\" onClick={handleClick} disabled>\n * Button with type-safe button attributes\n * </Text>\n * ```\n */\nconst Text = <T extends ElementType = 'p'>({\n children,\n size = 'md',\n weight = 'normal',\n color = 'text-text-950',\n as,\n className = '',\n ...props\n}: TextProps<T>) => {\n let sizeClasses = '';\n let weightClasses = '';\n\n // Text size classes mapping\n const sizeClassMap = {\n '2xs': 'text-2xs',\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n lg: 'text-lg',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n '3xl': 'text-3xl',\n '4xl': 'text-4xl',\n '5xl': 'text-5xl',\n '6xl': 'text-6xl',\n } as const;\n\n sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;\n\n // Font weight classes mapping\n const weightClassMap = {\n hairline: 'font-hairline',\n light: 'font-light',\n normal: 'font-normal',\n medium: 'font-medium',\n semibold: 'font-semibold',\n bold: 'font-bold',\n extrabold: 'font-extrabold',\n black: 'font-black',\n } as const;\n\n weightClasses = weightClassMap[weight] ?? weightClassMap.normal;\n\n const baseClasses = 'font-primary';\n const Component = as ?? ('p' as ElementType);\n\n return (\n <Component\n className={`${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`}\n {...props}\n >\n {children}\n </Component>\n );\n};\n\nexport default Text;\n","import { ReactNode } from 'react';\nimport Text from '../Text/Text';\n\n/**\n * Progress bar size variants\n */\ntype ProgressBarSize = 'small' | 'medium';\n\n/**\n * Progress bar color variants\n */\ntype ProgressBarVariant = 'blue' | 'green';\n\n/**\n * Size configurations using Tailwind classes\n */\nconst SIZE_CLASSES = {\n small: {\n container: 'h-1', // 4px height (h-1 = 4px in Tailwind)\n bar: 'h-1', // 4px height for the fill bar\n labelSize: 'xs' as const,\n spacing: 'gap-2', // 8px gap between label and progress bar\n layout: 'flex-col', // vertical layout for small\n borderRadius: 'rounded-full', // 9999px border radius\n },\n medium: {\n container: 'h-2', // 8px height (h-2 = 8px in Tailwind)\n bar: 'h-2', // 8px height for the fill bar\n labelSize: 'xs' as const, // 12px font size (xs in Tailwind)\n spacing: 'gap-2', // 8px gap between progress bar and label\n layout: 'flex-row items-center', // horizontal layout for medium\n borderRadius: 'rounded-lg', // 8px border radius\n },\n} as const;\n\n/**\n * Color configurations using design system colors\n */\nconst VARIANT_CLASSES = {\n blue: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-primary-700', // Blue for activity progress (#2271C4)\n },\n green: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-success-200', // Green for performance (#84D3A2)\n },\n} as const;\n\n/**\n * ProgressBar component props interface\n */\nexport type ProgressBarProps = {\n /** Progress value between 0 and 100 */\n value: number;\n /** Maximum value (defaults to 100) */\n max?: number;\n /** Size variant of the progress bar */\n size?: ProgressBarSize;\n /** Color variant of the progress bar */\n variant?: ProgressBarVariant;\n /** Optional label to display */\n label?: ReactNode;\n /** Show percentage text */\n showPercentage?: boolean;\n /** Additional CSS classes */\n className?: string;\n /** Label CSS classes */\n labelClassName?: string;\n /** Percentage text CSS classes */\n percentageClassName?: string;\n};\n\n/**\n * ProgressBar component for Analytica Ensino platforms\n *\n * A progress bar component with size and color variants designed for tracking\n * activity progress (blue) and performance metrics (green).\n * Uses the Analytica Ensino Design System colors from styles.css with automatic\n * light/dark mode support. Includes Text component integration for consistent typography.\n *\n * @example\n * ```tsx\n * // Basic progress bar\n * <ProgressBar value={65} />\n *\n * // Activity progress (blue)\n * <ProgressBar variant=\"blue\" value={45} label=\"Progress\" showPercentage />\n *\n * // Performance metrics (green)\n * <ProgressBar variant=\"green\" size=\"medium\" value={85} label=\"Performance\" />\n *\n * // Small size with custom max value\n * <ProgressBar size=\"small\" value={3} max={5} showPercentage />\n * ```\n */\nconst ProgressBar = ({\n value,\n max = 100,\n size = 'medium',\n variant = 'blue',\n label,\n showPercentage = false,\n className = '',\n labelClassName = '',\n percentageClassName = '',\n}: ProgressBarProps) => {\n // Ensure value is within bounds and handle NaN/Infinity\n const safeValue = isNaN(value) ? 0 : value;\n const clampedValue = Math.max(0, Math.min(safeValue, max));\n const percentage = max === 0 ? 0 : (clampedValue / max) * 100;\n\n // Get size and variant classes\n const sizeClasses = SIZE_CLASSES[size];\n const variantClasses = VARIANT_CLASSES[variant];\n\n return (\n <div\n className={`flex ${sizeClasses.layout} ${sizeClasses.spacing} ${className}`}\n >\n {/* For small size: vertical layout with label/percentage on top */}\n {size === 'small' && (label || showPercentage) && (\n <div className=\"flex flex-row items-center justify-between w-full\">\n {/* Label */}\n {label && (\n <Text\n as=\"div\"\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-950 ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n\n {/* Percentage */}\n {showPercentage && (\n <Text\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-700 text-center ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n </div>\n )}\n\n {/* Progress bar container */}\n <div\n className={`${size === 'medium' ? 'flex-grow' : 'w-full'} ${sizeClasses.container} ${variantClasses.background} ${sizeClasses.borderRadius} overflow-hidden relative`}\n >\n {/* Native progress element for accessibility */}\n <progress\n value={clampedValue}\n max={max}\n aria-label={typeof label === 'string' ? label : 'Progress'}\n className=\"absolute inset-0 w-full h-full opacity-0\"\n />\n\n {/* Progress bar fill */}\n <div\n className={`${sizeClasses.bar} ${variantClasses.fill} ${sizeClasses.borderRadius} transition-all duration-300 ease-out shadow-hard-shadow-3`}\n style={{ width: `${percentage}%` }}\n />\n </div>\n\n {/* For medium size: horizontal layout with percentage on the right */}\n {size === 'medium' && showPercentage && (\n <Text\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-950 text-center flex-none w-[70px] ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n\n {/* For medium size: label below if provided */}\n {size === 'medium' && label && !showPercentage && (\n <Text\n as=\"div\"\n size={sizeClasses.labelSize}\n weight=\"medium\"\n className={`text-text-950 flex-none ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n </div>\n );\n};\n\nexport default ProgressBar;\n"],"mappings":";AA0HI;AA/CJ,IAAM,OAAO,CAA8B;AAAA,EACzC;AAAA,EACA,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,MAAoB;AAClB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AAGpB,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,IACP,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAEA,gBAAc,aAAa,IAAI,KAAK,aAAa;AAGjD,QAAM,iBAAiB;AAAA,IACrB,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,EACT;AAEA,kBAAgB,eAAe,MAAM,KAAK,eAAe;AAEzD,QAAM,cAAc;AACpB,QAAM,YAAY,MAAO;AAEzB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,WAAW,IAAI,WAAW,IAAI,aAAa,IAAI,KAAK,IAAI,SAAS;AAAA,MAC9E,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,eAAQ;;;ACNH,gBAAAA,MAYA,YAZA;AA7GZ,IAAM,eAAe;AAAA,EACnB,OAAO;AAAA,IACL,WAAW;AAAA;AAAA,IACX,KAAK;AAAA;AAAA,IACL,WAAW;AAAA,IACX,SAAS;AAAA;AAAA,IACT,QAAQ;AAAA;AAAA,IACR,cAAc;AAAA;AAAA,EAChB;AAAA,EACA,QA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A,gBAAE;AAAA;AAAA;AAAA,UAC1B;AAAA,WAEJ;AAAA,QAIF;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,GAAG,SAAS,WAAW,cAAc,QAAQ,IAAI,YAAY,SAAS,IAAI,eAAe,UAAU,IAAI,YAAY,YAAY;AAAA,YAG1I;AAAA,8BAAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,OAAO;AAAA,kBACP;AAAA,kBACA,cAAY,OAAO,UAAU,WAAW,QAAQ;AAAA,kBAChD,WAAU;AAAA;AAAA,cACZ;AAAA,cAGA,gBAAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAW,GAAG,YAAY,GAAG,IAAI,eAAe,IAAI,IAAI,YAAY,YAAY;AAAA,kBAChF,OAAO,EAAE,OAAO,GAAG,UAAU,IAAI;AAAA;AAAA,cACnC;AAAA;AAAA;AAAA,QACF;AAAA,QAGC,SAAS,YAAY,kBACpB;AAAA,UAAC;AAAA;AAAA,YACC,MAAM,YAAY;AAAA,YAClB,QAAO;AAAA,YACP,WAAW,gDAAgD,mBAAmB;AAAA,YAE7E;AAAA,mBAAK,MAAM,UAAU;AAAA,cAAE;AAAA;AAAA;AAAA,QAC1B;AAAA,QAID,SAAS,YAAY,SAAS,CAAC,kBAC9B,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAM,YAAY;AAAA,YAClB,QAAO;AAAA,YACP,WAAW,2BAA2B,cAAc;AAAA,YAEnD;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,sBAAQ;","names":["jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Text/Text.tsx","../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';\n\n/**\n * Base text component props\n */\ntype BaseTextProps = {\n /** Content to be displayed */\n children?: ReactNode;\n /** Text size variant */\n size?:\n | '2xs'\n | 'xs'\n | 'sm'\n | 'md'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl'\n | '5xl'\n | '6xl';\n /** Font weight variant */\n weight?:\n | 'hairline'\n | 'light'\n | 'normal'\n | 'medium'\n | 'semibold'\n | 'bold'\n | 'extrabold'\n | 'black';\n /** Color variant - white for light backgrounds, black for dark backgrounds */\n color?: string;\n /** Additional CSS classes to apply */\n className?: string;\n};\n\n/**\n * Polymorphic text component props that ensures type safety based on the 'as' prop\n */\ntype TextProps<T extends ElementType = 'p'> = BaseTextProps & {\n /** HTML tag to render */\n as?: T;\n} & Omit<ComponentPropsWithoutRef<T>, keyof BaseTextProps>;\n\n/**\n * Text component for Analytica Ensino platforms\n *\n * A flexible polymorphic text component with multiple sizes, weights, and colors.\n * Automatically adapts to dark and light themes with full type safety.\n *\n * @param children - The content to display\n * @param size - The text size variant (2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl)\n * @param weight - The font weight variant (hairline, light, normal, medium, semibold, bold, extrabold, black)\n * @param color - The color variant - adapts to theme\n * @param as - The HTML tag to render - determines allowed attributes via TypeScript\n * @param className - Additional CSS classes\n * @param props - HTML attributes valid for the chosen tag only\n * @returns A styled text element with type-safe attributes\n *\n * @example\n * ```tsx\n * <Text size=\"lg\" weight=\"bold\" color=\"text-info-800\">\n * This is a large, bold text\n * </Text>\n *\n * <Text as=\"a\" href=\"/link\" target=\"_blank\">\n * Link with type-safe anchor attributes\n * </Text>\n *\n * <Text as=\"button\" onClick={handleClick} disabled>\n * Button with type-safe button attributes\n * </Text>\n * ```\n */\nconst Text = <T extends ElementType = 'p'>({\n children,\n size = 'md',\n weight = 'normal',\n color = 'text-text-950',\n as,\n className = '',\n ...props\n}: TextProps<T>) => {\n let sizeClasses = '';\n let weightClasses = '';\n\n // Text size classes mapping\n const sizeClassMap = {\n '2xs': 'text-2xs',\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n lg: 'text-lg',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n '3xl': 'text-3xl',\n '4xl': 'text-4xl',\n '5xl': 'text-5xl',\n '6xl': 'text-6xl',\n } as const;\n\n sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;\n\n // Font weight classes mapping\n const weightClassMap = {\n hairline: 'font-hairline',\n light: 'font-light',\n normal: 'font-normal',\n medium: 'font-medium',\n semibold: 'font-semibold',\n bold: 'font-bold',\n extrabold: 'font-extrabold',\n black: 'font-black',\n } as const;\n\n weightClasses = weightClassMap[weight] ?? weightClassMap.normal;\n\n const baseClasses = 'font-primary';\n const Component = as ?? ('p' as ElementType);\n\n return (\n <Component\n className={`${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`}\n {...props}\n >\n {children}\n </Component>\n );\n};\n\nexport default Text;\n","import { ReactNode } from 'react';\nimport Text from '../Text/Text';\n\n/**\n * Progress bar size variants\n */\ntype ProgressBarSize = 'small' | 'medium';\n\n/**\n * Progress bar color variants\n */\ntype ProgressBarVariant = 'blue' | 'green';\n\n/**\n * Size configurations using Tailwind classes\n */\nconst SIZE_CLASSES = {\n small: {\n container: 'h-1', // 4px height (h-1 = 4px in Tailwind)\n bar: 'h-1', // 4px height for the fill bar\n spacing: 'gap-2', // 8px gap between label and progress bar\n layout: 'flex-col', // vertical layout for small\n borderRadius: 'rounded-full', // 9999px border radius\n },\n medium: {\n container: 'h-2', // 8px height (h-2 = 8px in Tailwind)\n bar: 'h-2', // 8px height for the fill bar\n spacing: 'gap-2', // 8px gap between progress bar and label\n layout: 'flex-row items-center', // horizontal layout for medium\n borderRadius: 'rounded-lg', // 8px border radius\n },\n} as const;\n\n/**\n * Color configurations using design system colors\n */\nconst VARIANT_CLASSES = {\n blue: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-primary-700', // Blue for activity progress (#2271C4)\n },\n green: {\n background: 'bg-background-300', // Background track color (#D5D4D4)\n fill: 'bg-success-200', // Green for performance (#84D3A2)\n },\n} as const;\n\n/**\n * ProgressBar component props interface\n */\nexport type ProgressBarProps = {\n /** Progress value between 0 and 100 */\n value: number;\n /** Maximum value (defaults to 100) */\n max?: number;\n /** Size variant of the progress bar */\n size?: ProgressBarSize;\n /** Color variant of the progress bar */\n variant?: ProgressBarVariant;\n /** Optional label to display */\n label?: ReactNode;\n /** Show percentage text */\n showPercentage?: boolean;\n /** Additional CSS classes */\n className?: string;\n /** Label CSS classes */\n labelClassName?: string;\n /** Percentage text CSS classes */\n percentageClassName?: string;\n};\n\n/**\n * ProgressBar component for Analytica Ensino platforms\n *\n * A progress bar component with size and color variants designed for tracking\n * activity progress (blue) and performance metrics (green).\n * Uses the Analytica Ensino Design System colors from styles.css with automatic\n * light/dark mode support. Includes Text component integration for consistent typography.\n *\n * @example\n * ```tsx\n * // Basic progress bar\n * <ProgressBar value={65} />\n *\n * // Activity progress (blue)\n * <ProgressBar variant=\"blue\" value={45} label=\"Progress\" showPercentage />\n *\n * // Performance metrics (green)\n * <ProgressBar variant=\"green\" size=\"medium\" value={85} label=\"Performance\" />\n *\n * // Small size with custom max value\n * <ProgressBar size=\"small\" value={3} max={5} showPercentage />\n * ```\n */\nconst ProgressBar = ({\n value,\n max = 100,\n size = 'medium',\n variant = 'blue',\n label,\n showPercentage = false,\n className = '',\n labelClassName = '',\n percentageClassName = '',\n}: ProgressBarProps) => {\n // Ensure value is within bounds and handle NaN/Infinity\n const safeValue = isNaN(value) ? 0 : value;\n const clampedValue = Math.max(0, Math.min(safeValue, max));\n const percentage = max === 0 ? 0 : (clampedValue / max) * 100;\n\n // Get size and variant classes\n const sizeClasses = SIZE_CLASSES[size];\n const variantClasses = VARIANT_CLASSES[variant];\n\n return (\n <div\n className={`flex ${sizeClasses.layout} ${size === 'medium' ? 'gap-2' : sizeClasses.spacing} ${className}`}\n >\n {/* For small size: vertical layout with label/percentage on top */}\n {size === 'small' && (label || showPercentage) && (\n <div className=\"flex flex-row items-center justify-between w-full\">\n {/* Label */}\n {label && (\n <Text\n as=\"div\"\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n\n {/* Percentage */}\n {showPercentage && (\n <Text\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n </div>\n )}\n\n {/* Progress bar container */}\n <div\n className={`${size === 'medium' ? 'flex-grow' : 'w-full'} ${sizeClasses.container} ${variantClasses.background} ${sizeClasses.borderRadius} overflow-hidden relative`}\n >\n {/* Native progress element for accessibility */}\n <progress\n value={clampedValue}\n max={max}\n aria-label={typeof label === 'string' ? label : 'Progress'}\n className=\"absolute inset-0 w-full h-full opacity-0\"\n />\n\n {/* Progress bar fill */}\n <div\n className={`${sizeClasses.bar} ${variantClasses.fill} ${sizeClasses.borderRadius} transition-all duration-300 ease-out shadow-hard-shadow-3`}\n style={{ width: `${percentage}%` }}\n />\n </div>\n\n {/* For medium size: horizontal layout with percentage on the right */}\n {size === 'medium' && showPercentage && (\n <Text\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`}\n >\n {Math.round(percentage)}%\n </Text>\n )}\n\n {/* For medium size: label below if provided */}\n {size === 'medium' && label && !showPercentage && (\n <Text\n as=\"div\"\n size=\"xs\"\n weight=\"medium\"\n className={`text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`}\n >\n {label}\n </Text>\n )}\n </div>\n );\n};\n\nexport default ProgressBar;\n"],"mappings":";AA0HI;AA/CJ,IAAM,OAAO,CAA8B;AAAA,EACzC;AAAA,EACA,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,MAAoB;AAClB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AAGpB,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,IACP,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI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AAY,YAAY;AAAA,kBAChF,OAAO,EAAE,OAAO,GAAG,UAAU,IAAI;AAAA;AAAA,cACnC;AAAA;AAAA;AAAA,QACF;AAAA,QAGC,SAAS,YAAY,kBACpB;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,QAAO;AAAA,YACP,WAAW,oEAAoE,mBAAmB;AAAA,YAEjG;AAAA,mBAAK,MAAM,UAAU;AAAA,cAAE;AAAA;AAAA;AAAA,QAC1B;AAAA,QAID,SAAS,YAAY,SAAS,CAAC,kBAC9B,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACL,QAAO;AAAA,YACP,WAAW,oEAAoE,cAAc;AAAA,YAE5F;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,sBAAQ;","names":["jsx"]}
|
package/dist/Radio/index.js
CHANGED
|
@@ -81,48 +81,34 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
|
81
81
|
var SIZE_CLASSES = {
|
|
82
82
|
small: {
|
|
83
83
|
radio: "w-5 h-5",
|
|
84
|
-
// 20px x 20px
|
|
85
84
|
textSize: "sm",
|
|
86
85
|
spacing: "gap-1.5",
|
|
87
|
-
// 6px
|
|
88
86
|
borderWidth: "border-2",
|
|
89
|
-
dotSize: "w-
|
|
90
|
-
// 6px inner dot
|
|
87
|
+
dotSize: "w-2 h-2",
|
|
91
88
|
labelHeight: "h-5"
|
|
92
89
|
},
|
|
93
90
|
medium: {
|
|
94
91
|
radio: "w-6 h-6",
|
|
95
|
-
// 24px x 24px
|
|
96
92
|
textSize: "md",
|
|
97
93
|
spacing: "gap-2",
|
|
98
|
-
// 8px
|
|
99
94
|
borderWidth: "border-2",
|
|
100
|
-
dotSize: "w-2 h-2",
|
|
101
|
-
// 8px inner dot
|
|
95
|
+
dotSize: "w-2.5 h-2.5",
|
|
102
96
|
labelHeight: "h-6"
|
|
103
97
|
},
|
|
104
98
|
large: {
|
|
105
99
|
radio: "w-7 h-7",
|
|
106
|
-
// 28px x 28px
|
|
107
100
|
textSize: "lg",
|
|
108
101
|
spacing: "gap-2",
|
|
109
|
-
// 8px
|
|
110
102
|
borderWidth: "border-2",
|
|
111
|
-
|
|
112
|
-
dotSize: "w-2.5 h-2.5",
|
|
113
|
-
// 10px inner dot
|
|
103
|
+
dotSize: "w-3 h-3",
|
|
114
104
|
labelHeight: "h-7"
|
|
115
105
|
},
|
|
116
106
|
extraLarge: {
|
|
117
107
|
radio: "w-8 h-8",
|
|
118
|
-
// 32px x 32px (larger than large)
|
|
119
108
|
textSize: "xl",
|
|
120
109
|
spacing: "gap-3",
|
|
121
|
-
// 12px
|
|
122
110
|
borderWidth: "border-2",
|
|
123
|
-
|
|
124
|
-
dotSize: "w-3 h-3",
|
|
125
|
-
// 12px inner dot
|
|
111
|
+
dotSize: "w-3.5 h-3.5",
|
|
126
112
|
labelHeight: "h-8"
|
|
127
113
|
}
|
|
128
114
|
};
|
|
@@ -134,39 +120,27 @@ var STATE_CLASSES = {
|
|
|
134
120
|
},
|
|
135
121
|
hovered: {
|
|
136
122
|
unchecked: "border-border-500 bg-background",
|
|
137
|
-
// #8C8D8D hover state for unchecked
|
|
138
123
|
checked: "border-info-700 bg-background"
|
|
139
|
-
// Adjust checked border for hover
|
|
140
124
|
},
|
|
141
125
|
focused: {
|
|
142
126
|
unchecked: "border-border-400 bg-background",
|
|
143
|
-
// #A5A3A3 for unchecked radio
|
|
144
127
|
checked: "border-primary-950 bg-background"
|
|
145
|
-
// #124393 for checked radio
|
|
146
128
|
},
|
|
147
129
|
invalid: {
|
|
148
130
|
unchecked: "border-border-400 bg-background",
|
|
149
|
-
// #A5A3A3 for unchecked radio
|
|
150
131
|
checked: "border-primary-950 bg-background"
|
|
151
|
-
// #124393 for checked radio
|
|
152
132
|
},
|
|
153
133
|
disabled: {
|
|
154
134
|
unchecked: "border-border-400 bg-background cursor-not-allowed",
|
|
155
|
-
// #A5A3A3 for unchecked radio
|
|
156
135
|
checked: "border-primary-950 bg-background cursor-not-allowed"
|
|
157
|
-
// #124393 for checked radio
|
|
158
136
|
}
|
|
159
137
|
};
|
|
160
138
|
var DOT_CLASSES = {
|
|
161
139
|
default: "bg-primary-950",
|
|
162
140
|
hovered: "bg-info-700",
|
|
163
|
-
// #1C61B2 hover state for checked dot
|
|
164
141
|
focused: "bg-primary-950",
|
|
165
|
-
// #124393 for focused checked dot
|
|
166
142
|
invalid: "bg-primary-950",
|
|
167
|
-
// #124393 for invalid checked dot
|
|
168
143
|
disabled: "bg-primary-950"
|
|
169
|
-
// #124393 for disabled checked dot
|
|
170
144
|
};
|
|
171
145
|
var Radio = (0, import_react.forwardRef)(
|
|
172
146
|
({
|
|
@@ -252,7 +226,7 @@ var Radio = (0, import_react.forwardRef)(
|
|
|
252
226
|
label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
253
227
|
"div",
|
|
254
228
|
{
|
|
255
|
-
className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
|
|
229
|
+
className: `flex flex-row items-center ${sizeClasses.labelHeight} flex-1 min-w-0`,
|
|
256
230
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
257
231
|
Text_default,
|
|
258
232
|
{
|
|
@@ -260,7 +234,7 @@ var Radio = (0, import_react.forwardRef)(
|
|
|
260
234
|
htmlFor: inputId,
|
|
261
235
|
size: sizeClasses.textSize,
|
|
262
236
|
weight: "normal",
|
|
263
|
-
className: `${getCursorClass()} select-none leading-normal flex items-center font-roboto ${labelClassName}`,
|
|
237
|
+
className: `${getCursorClass()} select-none leading-normal flex items-center font-roboto truncate ${labelClassName}`,
|
|
264
238
|
color: getTextColor(),
|
|
265
239
|
children: label
|
|
266
240
|
}
|
|
@@ -275,7 +249,7 @@ var Radio = (0, import_react.forwardRef)(
|
|
|
275
249
|
{
|
|
276
250
|
size: "sm",
|
|
277
251
|
weight: "normal",
|
|
278
|
-
className: "mt-1.5",
|
|
252
|
+
className: "mt-1.5 truncate",
|
|
279
253
|
color: "text-error-600",
|
|
280
254
|
children: errorMessage
|
|
281
255
|
}
|
|
@@ -285,7 +259,7 @@ var Radio = (0, import_react.forwardRef)(
|
|
|
285
259
|
{
|
|
286
260
|
size: "sm",
|
|
287
261
|
weight: "normal",
|
|
288
|
-
className: "mt-1.5",
|
|
262
|
+
className: "mt-1.5 truncate",
|
|
289
263
|
color: "text-text-500",
|
|
290
264
|
children: helperText
|
|
291
265
|
}
|
package/dist/Radio/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Radio/Radio.tsx","../../src/components/Text/Text.tsx"],"sourcesContent":["import {\n InputHTMLAttributes,\n ReactNode,\n forwardRef,\n useState,\n useId,\n ChangeEvent,\n} from 'react';\nimport Text from '../Text/Text';\n\n/**\n * Radio size variants\n */\ntype RadioSize = 'small' | 'medium' | 'large' | 'extraLarge';\n\n/**\n * Radio visual state\n */\ntype RadioState = 'default' | 'hovered' | 'focused' | 'invalid' | 'disabled';\n\n/**\n * Size configurations using Tailwind classes\n */\nconst SIZE_CLASSES = {\n small: {\n radio: 'w-5 h-5', // 20px x 20px\n textSize: 'sm' as const,\n spacing: 'gap-1.5', // 6px\n borderWidth: 'border-2',\n dotSize: 'w-1.5 h-1.5', // 6px inner dot\n labelHeight: 'h-5',\n },\n medium: {\n radio: 'w-6 h-6', // 24px x 24px\n textSize: 'md' as const,\n spacing: 'gap-2', // 8px\n borderWidth: 'border-2',\n dotSize: 'w-2 h-2', // 8px inner dot\n labelHeight: 'h-6',\n },\n large: {\n radio: 'w-7 h-7', // 28px x 28px\n textSize: 'lg' as const,\n spacing: 'gap-2', // 8px\n borderWidth: 'border-2', // 2px border (consistent with others)\n dotSize: 'w-2.5 h-2.5', // 10px inner dot\n labelHeight: 'h-7',\n },\n extraLarge: {\n radio: 'w-8 h-8', // 32px x 32px (larger than large)\n textSize: 'xl' as const,\n spacing: 'gap-3', // 12px\n borderWidth: 'border-2', // 2px border (consistent with others)\n dotSize: 'w-3 h-3', // 12px inner dot\n labelHeight: 'h-8',\n },\n} as const;\n\n/**\n * Focused state maintains the same sizes as default state\n * Only adds wrapper styling, does not change radio/dot sizes\n */\n\n/**\n * Base radio styling classes using design system colors\n */\nconst BASE_RADIO_CLASSES =\n 'rounded-full border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none';\n\n/**\n * State-based styling classes using design system colors from styles.css\n */\nconst STATE_CLASSES = {\n default: {\n unchecked: 'border-border-400 bg-background hover:border-border-500',\n checked: 'border-primary-950 bg-background hover:border-primary-800',\n },\n hovered: {\n unchecked: 'border-border-500 bg-background', // #8C8D8D hover state for unchecked\n checked: 'border-info-700 bg-background', // Adjust checked border for hover\n },\n focused: {\n unchecked: 'border-border-400 bg-background', // #A5A3A3 for unchecked radio\n checked: 'border-primary-950 bg-background', // #124393 for checked radio\n },\n invalid: {\n unchecked: 'border-border-400 bg-background', // #A5A3A3 for unchecked radio\n checked: 'border-primary-950 bg-background', // #124393 for checked radio\n },\n disabled: {\n unchecked: 'border-border-400 bg-background cursor-not-allowed', // #A5A3A3 for unchecked radio\n checked: 'border-primary-950 bg-background cursor-not-allowed', // #124393 for checked radio\n },\n} as const;\n\n/**\n * Dot styling classes for the inner dot when checked\n */\nconst DOT_CLASSES = {\n default: 'bg-primary-950',\n hovered: 'bg-info-700', // #1C61B2 hover state for checked dot\n focused: 'bg-primary-950', // #124393 for focused checked dot\n invalid: 'bg-primary-950', // #124393 for invalid checked dot\n disabled: 'bg-primary-950', // #124393 for disabled checked dot\n} as const;\n\n/**\n * Radio component props interface\n */\nexport type RadioProps = {\n /** Label text to display next to the radio */\n label?: ReactNode;\n /** Size variant of the radio */\n size?: RadioSize;\n /** Visual state of the radio */\n state?: RadioState;\n /** Error message to display */\n errorMessage?: string;\n /** Helper text to display */\n helperText?: string;\n /** Additional CSS classes */\n className?: string;\n /** Label CSS classes */\n labelClassName?: string;\n /** Radio group name */\n name?: string;\n /** Radio value */\n value?: string;\n /** Default checked state for uncontrolled radios */\n defaultChecked?: boolean;\n} & Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'type' | 'defaultChecked'\n>;\n\n/**\n * Radio component for Analytica Ensino platforms\n *\n * A radio button component with essential states, sizes and themes.\n * Uses the Analytica Ensino Design System colors from styles.css with automatic\n * light/dark mode support. Includes Text component integration for consistent typography.\n *\n * @example\n * ```tsx\n * // Basic radio\n * <Radio name=\"option\" value=\"1\" label=\"Option 1\" />\n *\n * // Small size\n * <Radio size=\"small\" name=\"option\" value=\"2\" label=\"Small option\" />\n *\n * // Invalid state\n * <Radio state=\"invalid\" name=\"option\" value=\"3\" label=\"Required field\" />\n *\n * // Disabled state\n * <Radio disabled name=\"option\" value=\"4\" label=\"Disabled option\" />\n *\n * // Default checked (uncontrolled)\n * <Radio defaultChecked name=\"option\" value=\"5\" label=\"Initially checked\" />\n * ```\n */\nconst Radio = forwardRef<HTMLInputElement, RadioProps>(\n (\n {\n label,\n size = 'medium',\n state = 'default',\n errorMessage,\n helperText,\n className = '',\n labelClassName = '',\n checked: checkedProp,\n defaultChecked = false,\n disabled,\n id,\n name,\n value,\n onChange,\n ...props\n },\n ref\n ) => {\n // Generate unique ID if not provided\n const generatedId = useId();\n const inputId = id ?? `radio-${generatedId}`;\n\n // Handle controlled vs uncontrolled behavior\n const [internalChecked, setInternalChecked] = useState(defaultChecked);\n const isControlled = checkedProp !== undefined;\n const checked = isControlled ? checkedProp : internalChecked;\n\n // Handle change events\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const newChecked = event.target.checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(event);\n };\n\n // Determine current state based on props\n const currentState = disabled ? 'disabled' : state;\n\n // Get size classes\n const sizeClasses = SIZE_CLASSES[size];\n\n // Focused state maintains original sizes, only adds wrapper\n const actualRadioSize = sizeClasses.radio;\n const actualDotSize = sizeClasses.dotSize;\n\n // Determine radio visual variant\n const radioVariant = checked ? 'checked' : 'unchecked';\n\n // Get styling classes\n const stylingClasses = STATE_CLASSES[currentState][radioVariant];\n\n // Border width logic - consistent across all states and sizes\n const getBorderWidth = () => {\n if (currentState === 'focused') {\n return 'border-2'; // Consistent border for all focused radios inside wrapper\n }\n return sizeClasses.borderWidth;\n };\n\n const borderWidthClass = getBorderWidth();\n\n // Get final radio classes\n const radioClasses = `${BASE_RADIO_CLASSES} ${actualRadioSize} ${borderWidthClass} ${stylingClasses} ${className}`;\n\n // Get dot classes\n const dotClasses = `${actualDotSize} rounded-full ${DOT_CLASSES[currentState]} transition-all duration-200`;\n\n // Determine if wrapper is needed only for focused or invalid states\n const isWrapperNeeded =\n currentState === 'focused' || currentState === 'invalid';\n const wrapperBorderColor =\n currentState === 'focused'\n ? 'border-indicator-info' // #5399EC for focused\n : 'border-indicator-error'; // #B91C1C for invalid\n\n // Determine text color based on state and checked status\n const getTextColor = () => {\n if (currentState === 'disabled') {\n return checked ? 'text-text-900' : 'text-text-600'; // #262627 for disabled checked, #737373 for disabled unchecked\n }\n\n if (currentState === 'focused') {\n return 'text-text-900'; // #262627 for focused (both checked and unchecked)\n }\n\n return checked ? 'text-text-900' : 'text-text-600'; // #262627 for checked, #737373 for unchecked\n };\n\n // Determine cursor class based on disabled state\n const getCursorClass = () => {\n return currentState === 'disabled'\n ? 'cursor-not-allowed'\n : 'cursor-pointer';\n };\n\n return (\n <div className=\"flex flex-col\">\n <div\n className={`flex flex-row items-center ${\n isWrapperNeeded\n ? `p-1 border-2 ${wrapperBorderColor} rounded-lg gap-1.5` // Wrapper apenas para focused/invalid\n : sizeClasses.spacing\n } ${disabled ? 'opacity-40' : ''}`}\n >\n {/* Hidden native input for accessibility and form submission */}\n <input\n ref={ref}\n type=\"radio\"\n id={inputId}\n checked={checked}\n disabled={disabled}\n name={name}\n value={value}\n onChange={handleChange}\n className=\"sr-only\"\n {...props}\n />\n\n {/* Custom styled radio */}\n <label htmlFor={inputId} className={radioClasses}>\n {/* Show dot when checked */}\n {checked && <div className={dotClasses} />}\n </label>\n\n {/* Label text */}\n {label && (\n <div\n className={`flex flex-row items-center ${sizeClasses.labelHeight}`}\n >\n <Text\n as=\"label\"\n htmlFor={inputId}\n size={sizeClasses.textSize}\n weight=\"normal\"\n className={`${getCursorClass()} select-none leading-normal flex items-center font-roboto ${labelClassName}`}\n color={getTextColor()}\n >\n {label}\n </Text>\n </div>\n )}\n </div>\n\n {/* Error message */}\n {errorMessage && (\n <Text\n size=\"sm\"\n weight=\"normal\"\n className=\"mt-1.5\"\n color=\"text-error-600\"\n >\n {errorMessage}\n </Text>\n )}\n\n {/* Helper text */}\n {helperText && !errorMessage && (\n <Text\n size=\"sm\"\n weight=\"normal\"\n className=\"mt-1.5\"\n color=\"text-text-500\"\n >\n {helperText}\n </Text>\n )}\n </div>\n );\n }\n);\n\nRadio.displayName = 'Radio';\n\nexport default Radio;\n","import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';\n\n/**\n * Base text component props\n */\ntype BaseTextProps = {\n /** Content to be displayed */\n children?: ReactNode;\n /** Text size variant */\n size?:\n | '2xs'\n | 'xs'\n | 'sm'\n | 'md'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl'\n | '5xl'\n | '6xl';\n /** Font weight variant */\n weight?:\n | 'hairline'\n | 'light'\n | 'normal'\n | 'medium'\n | 'semibold'\n | 'bold'\n | 'extrabold'\n | 'black';\n /** Color variant - white for light backgrounds, black for dark backgrounds */\n color?: string;\n /** Additional CSS classes to apply */\n className?: string;\n};\n\n/**\n * Polymorphic text component props that ensures type safety based on the 'as' prop\n */\ntype TextProps<T extends ElementType = 'p'> = BaseTextProps & {\n /** HTML tag to render */\n as?: T;\n} & Omit<ComponentPropsWithoutRef<T>, keyof BaseTextProps>;\n\n/**\n * Text component for Analytica Ensino platforms\n *\n * A flexible polymorphic text component with multiple sizes, weights, and colors.\n * Automatically adapts to dark and light themes with full type safety.\n *\n * @param children - The content to display\n * @param size - The text size variant (2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl)\n * @param weight - The font weight variant (hairline, light, normal, medium, semibold, bold, extrabold, black)\n * @param color - The color variant - adapts to theme\n * @param as - The HTML tag to render - determines allowed attributes via TypeScript\n * @param className - Additional CSS classes\n * @param props - HTML attributes valid for the chosen tag only\n * @returns A styled text element with type-safe attributes\n *\n * @example\n * ```tsx\n * <Text size=\"lg\" weight=\"bold\" color=\"text-info-800\">\n * This is a large, bold text\n * </Text>\n *\n * <Text as=\"a\" href=\"/link\" target=\"_blank\">\n * Link with type-safe anchor attributes\n * </Text>\n *\n * <Text as=\"button\" onClick={handleClick} disabled>\n * Button with type-safe button attributes\n * </Text>\n * ```\n */\nconst Text = <T extends ElementType = 'p'>({\n children,\n size = 'md',\n weight = 'normal',\n color = 'text-text-950',\n as,\n className = '',\n ...props\n}: TextProps<T>) => {\n let sizeClasses = '';\n let weightClasses = '';\n\n // Text size classes mapping\n const sizeClassMap = {\n '2xs': 'text-2xs',\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n lg: 'text-lg',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n '3xl': 'text-3xl',\n '4xl': 'text-4xl',\n '5xl': 'text-5xl',\n '6xl': 'text-6xl',\n } as const;\n\n sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;\n\n // Font weight classes mapping\n const weightClassMap = {\n hairline: 'font-hairline',\n light: 'font-light',\n normal: 'font-normal',\n medium: 'font-medium',\n semibold: 'font-semibold',\n bold: 'font-bold',\n extrabold: 'font-extrabold',\n black: 'font-black',\n } as const;\n\n weightClasses = weightClassMap[weight] ?? weightClassMap.normal;\n\n const baseClasses = 'font-primary';\n const Component = as ?? ('p' as ElementType);\n\n return (\n <Component\n className={`${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`}\n {...props}\n >\n {children}\n </Component>\n );\n};\n\nexport default Text;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;A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BACC;AAAA,gBACA,MAAK;AAAA,gBACL,IAAI;AAAA,gBACJ;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAU;AAAA,gBACV,WAAU;AAAA,gBACT,GAAG;AAAA;AAAA,YACN;AAAA,YAGA,6CAAC,WAAM,SAAS,SAAS,WAAW,cAEjC,qBAAW,6CAAC,SAAI,WAAW,YAAY,GAC1C;AAAA,YAGC,SACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW,8BAA8B,YAAY,WAAW;AAAA,gBAEhE;AAAA,kBAAC;AAAA;AAAA,oBACC,IAAG;AAAA,oBACH,SAAS;AAAA,oBACT,MAAM,YAAY;AAAA,oBAClB,QAAO;AAAA,oBACP,WAAW,GAAG,eAAe,CAAC,6DAA6D,cAAc;AAAA,oBACzG,OAAO,aAAa;AAAA,oBAEnB;AAAA;AAAA,gBACH;AAAA;AAAA,YACF;AAAA;AAAA;AAAA,MAEJ;AAAA,MAGC,gBACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,QAAO;AAAA,UACP,WAAU;AAAA,UACV,OAAM;AAAA,UAEL;AAAA;AAAA,MACH;AAAA,MAID,cAAc,CAAC,gBACd;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,QAAO;AAAA,UACP,WAAU;AAAA,UACV,OAAM;AAAA,UAEL;AAAA;AAAA,MACH;AAAA,OAEJ;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc;AAEpB,IAAO,gBAAQ;","names":["import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Radio/Radio.tsx","../../src/components/Text/Text.tsx"],"sourcesContent":["import {\n InputHTMLAttributes,\n ReactNode,\n forwardRef,\n useState,\n useId,\n ChangeEvent,\n} from 'react';\nimport Text from '../Text/Text';\n\n/**\n * Radio size variants\n */\ntype RadioSize = 'small' | 'medium' | 'large' | 'extraLarge';\n\n/**\n * Radio visual state\n */\ntype RadioState = 'default' | 'hovered' | 'focused' | 'invalid' | 'disabled';\n\n/**\n * Size configurations using Tailwind classes\n */\nconst SIZE_CLASSES = {\n small: {\n radio: 'w-5 h-5',\n textSize: 'sm' as const,\n spacing: 'gap-1.5',\n borderWidth: 'border-2',\n dotSize: 'w-2 h-2',\n labelHeight: 'h-5',\n },\n medium: {\n radio: 'w-6 h-6',\n textSize: 'md' as const,\n spacing: 'gap-2',\n borderWidth: 'border-2',\n dotSize: 'w-2.5 h-2.5',\n labelHeight: 'h-6',\n },\n large: {\n radio: 'w-7 h-7',\n textSize: 'lg' as const,\n spacing: 'gap-2',\n borderWidth: 'border-2',\n dotSize: 'w-3 h-3',\n labelHeight: 'h-7',\n },\n extraLarge: {\n radio: 'w-8 h-8',\n textSize: 'xl' as const,\n spacing: 'gap-3',\n borderWidth: 'border-2',\n dotSize: 'w-3.5 h-3.5',\n labelHeight: 'h-8',\n },\n} as const;\n\n/**\n * Focused state maintains the same sizes as default state\n * Only adds wrapper styling, does not change radio/dot sizes\n */\n\n/**\n * Base radio styling classes using design system colors\n */\nconst BASE_RADIO_CLASSES =\n 'rounded-full border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none';\n\n/**\n * State-based styling classes using design system colors from styles.css\n */\nconst STATE_CLASSES = {\n default: {\n unchecked: 'border-border-400 bg-background hover:border-border-500',\n checked: 'border-primary-950 bg-background hover:border-primary-800',\n },\n hovered: {\n unchecked: 'border-border-500 bg-background',\n checked: 'border-info-700 bg-background',\n },\n focused: {\n unchecked: 'border-border-400 bg-background',\n checked: 'border-primary-950 bg-background',\n },\n invalid: {\n unchecked: 'border-border-400 bg-background',\n checked: 'border-primary-950 bg-background',\n },\n disabled: {\n unchecked: 'border-border-400 bg-background cursor-not-allowed',\n checked: 'border-primary-950 bg-background cursor-not-allowed',\n },\n} as const;\n\n/**\n * Dot styling classes for the inner dot when checked\n */\nconst DOT_CLASSES = {\n default: 'bg-primary-950',\n hovered: 'bg-info-700',\n focused: 'bg-primary-950',\n invalid: 'bg-primary-950',\n disabled: 'bg-primary-950',\n} as const;\n\n/**\n * Radio component props interface\n */\nexport type RadioProps = {\n /** Label text to display next to the radio */\n label?: ReactNode;\n /** Size variant of the radio */\n size?: RadioSize;\n /** Visual state of the radio */\n state?: RadioState;\n /** Error message to display */\n errorMessage?: string;\n /** Helper text to display */\n helperText?: string;\n /** Additional CSS classes */\n className?: string;\n /** Label CSS classes */\n labelClassName?: string;\n /** Radio group name */\n name?: string;\n /** Radio value */\n value?: string;\n /** Default checked state for uncontrolled radios */\n defaultChecked?: boolean;\n} & Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'type' | 'defaultChecked'\n>;\n\n/**\n * Radio component for Analytica Ensino platforms\n *\n * A radio button component with essential states, sizes and themes.\n * Uses the Analytica Ensino Design System colors from styles.css with automatic\n * light/dark mode support. Includes Text component integration for consistent typography.\n *\n * @example\n * ```tsx\n * // Basic radio\n * <Radio name=\"option\" value=\"1\" label=\"Option 1\" />\n *\n * // Small size\n * <Radio size=\"small\" name=\"option\" value=\"2\" label=\"Small option\" />\n *\n * // Invalid state\n * <Radio state=\"invalid\" name=\"option\" value=\"3\" label=\"Required field\" />\n *\n * // Disabled state\n * <Radio disabled name=\"option\" value=\"4\" label=\"Disabled option\" />\n *\n * // Default checked (uncontrolled)\n * <Radio defaultChecked name=\"option\" value=\"5\" label=\"Initially checked\" />\n * ```\n */\nconst Radio = forwardRef<HTMLInputElement, RadioProps>(\n (\n {\n label,\n size = 'medium',\n state = 'default',\n errorMessage,\n helperText,\n className = '',\n labelClassName = '',\n checked: checkedProp,\n defaultChecked = false,\n disabled,\n id,\n name,\n value,\n onChange,\n ...props\n },\n ref\n ) => {\n // Generate unique ID if not provided\n const generatedId = useId();\n const inputId = id ?? `radio-${generatedId}`;\n\n // Handle controlled vs uncontrolled behavior\n const [internalChecked, setInternalChecked] = useState(defaultChecked);\n const isControlled = checkedProp !== undefined;\n const checked = isControlled ? checkedProp : internalChecked;\n\n // Handle change events\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const newChecked = event.target.checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(event);\n };\n\n // Determine current state based on props\n const currentState = disabled ? 'disabled' : state;\n\n // Get size classes\n const sizeClasses = SIZE_CLASSES[size];\n\n // Focused state maintains original sizes, only adds wrapper\n const actualRadioSize = sizeClasses.radio;\n const actualDotSize = sizeClasses.dotSize;\n\n // Determine radio visual variant\n const radioVariant = checked ? 'checked' : 'unchecked';\n\n // Get styling classes\n const stylingClasses = STATE_CLASSES[currentState][radioVariant];\n\n // Border width logic - consistent across all states and sizes\n const getBorderWidth = () => {\n if (currentState === 'focused') {\n return 'border-2';\n }\n return sizeClasses.borderWidth;\n };\n\n const borderWidthClass = getBorderWidth();\n\n // Get final radio classes\n const radioClasses = `${BASE_RADIO_CLASSES} ${actualRadioSize} ${borderWidthClass} ${stylingClasses} ${className}`;\n\n // Get dot classes\n const dotClasses = `${actualDotSize} rounded-full ${DOT_CLASSES[currentState]} transition-all duration-200`;\n\n // Determine if wrapper is needed only for focused or invalid states\n const isWrapperNeeded =\n currentState === 'focused' || currentState === 'invalid';\n const wrapperBorderColor =\n currentState === 'focused'\n ? 'border-indicator-info'\n : 'border-indicator-error';\n\n // Determine text color based on state and checked status\n const getTextColor = () => {\n if (currentState === 'disabled') {\n return checked ? 'text-text-900' : 'text-text-600';\n }\n\n if (currentState === 'focused') {\n return 'text-text-900';\n }\n\n return checked ? 'text-text-900' : 'text-text-600';\n };\n\n // Determine cursor class based on disabled state\n const getCursorClass = () => {\n return currentState === 'disabled'\n ? 'cursor-not-allowed'\n : 'cursor-pointer';\n };\n\n return (\n <div className=\"flex flex-col\">\n <div\n className={`flex flex-row items-center ${\n isWrapperNeeded\n ? `p-1 border-2 ${wrapperBorderColor} rounded-lg gap-1.5`\n : sizeClasses.spacing\n } ${disabled ? 'opacity-40' : ''}`}\n >\n {/* Hidden native input for accessibility and form submission */}\n <input\n ref={ref}\n type=\"radio\"\n id={inputId}\n checked={checked}\n disabled={disabled}\n name={name}\n value={value}\n onChange={handleChange}\n className=\"sr-only\"\n {...props}\n />\n\n {/* Custom styled radio */}\n <label htmlFor={inputId} className={radioClasses}>\n {/* Show dot when checked */}\n {checked && <div className={dotClasses} />}\n </label>\n\n {/* Label text */}\n {label && (\n <div\n className={`flex flex-row items-center ${sizeClasses.labelHeight} flex-1 min-w-0`}\n >\n <Text\n as=\"label\"\n htmlFor={inputId}\n size={sizeClasses.textSize}\n weight=\"normal\"\n className={`${getCursorClass()} select-none leading-normal flex items-center font-roboto truncate ${labelClassName}`}\n color={getTextColor()}\n >\n {label}\n </Text>\n </div>\n )}\n </div>\n\n {/* Error message */}\n {errorMessage && (\n <Text\n size=\"sm\"\n weight=\"normal\"\n className=\"mt-1.5 truncate\"\n color=\"text-error-600\"\n >\n {errorMessage}\n </Text>\n )}\n\n {/* Helper text */}\n {helperText && !errorMessage && (\n <Text\n size=\"sm\"\n weight=\"normal\"\n className=\"mt-1.5 truncate\"\n color=\"text-text-500\"\n >\n {helperText}\n </Text>\n )}\n </div>\n );\n }\n);\n\nRadio.displayName = 'Radio';\n\nexport default Radio;\n","import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';\n\n/**\n * Base text component props\n */\ntype BaseTextProps = {\n /** Content to be displayed */\n children?: ReactNode;\n /** Text size variant */\n size?:\n | '2xs'\n | 'xs'\n | 'sm'\n | 'md'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl'\n | '5xl'\n | '6xl';\n /** Font weight variant */\n weight?:\n | 'hairline'\n | 'light'\n | 'normal'\n | 'medium'\n | 'semibold'\n | 'bold'\n | 'extrabold'\n | 'black';\n /** Color variant - white for light backgrounds, black for dark backgrounds */\n color?: string;\n /** Additional CSS classes to apply */\n className?: string;\n};\n\n/**\n * Polymorphic text component props that ensures type safety based on the 'as' prop\n */\ntype TextProps<T extends ElementType = 'p'> = BaseTextProps & {\n /** HTML tag to render */\n as?: T;\n} & Omit<ComponentPropsWithoutRef<T>, keyof BaseTextProps>;\n\n/**\n * Text component for Analytica Ensino platforms\n *\n * A flexible polymorphic text component with multiple sizes, weights, and colors.\n * Automatically adapts to dark and light themes with full type safety.\n *\n * @param children - The content to display\n * @param size - The text size variant (2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl)\n * @param weight - The font weight variant (hairline, light, normal, medium, semibold, bold, extrabold, black)\n * @param color - The color variant - adapts to theme\n * @param as - The HTML tag to render - determines allowed attributes via TypeScript\n * @param className - Additional CSS classes\n * @param props - HTML attributes valid for the chosen tag only\n * @returns A styled text element with type-safe attributes\n *\n * @example\n * ```tsx\n * <Text size=\"lg\" weight=\"bold\" color=\"text-info-800\">\n * This is a large, bold text\n * </Text>\n *\n * <Text as=\"a\" href=\"/link\" target=\"_blank\">\n * Link with type-safe anchor attributes\n * </Text>\n *\n * <Text as=\"button\" onClick={handleClick} disabled>\n * Button with type-safe button attributes\n * </Text>\n * ```\n */\nconst Text = <T extends ElementType = 'p'>({\n children,\n size = 'md',\n weight = 'normal',\n color = 'text-text-950',\n as,\n className = '',\n ...props\n}: TextProps<T>) => {\n let sizeClasses = '';\n let weightClasses = '';\n\n // Text size classes mapping\n const sizeClassMap = {\n '2xs': 'text-2xs',\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n lg: 'text-lg',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n '3xl': 'text-3xl',\n '4xl': 'text-4xl',\n '5xl': 'text-5xl',\n '6xl': 'text-6xl',\n } as const;\n\n sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;\n\n // Font weight classes mapping\n const weightClassMap = {\n hairline: 'font-hairline',\n light: 'font-light',\n normal: 'font-normal',\n medium: 'font-medium',\n semibold: 'font-semibold',\n bold: 'font-bold',\n extrabold: 'font-extrabold',\n black: 'font-black',\n } as const;\n\n weightClasses = weightClassMap[weight] ?? weightClassMap.normal;\n\n const baseClasses = 'font-primary';\n const Component = as ?? ('p' as ElementType);\n\n return (\n <Component\n className={`${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`}\n {...props}\n >\n {children}\n </Component>\n );\n};\n\nexport default Text;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAOO;;;ACmHH;AA/CJ,IAAM,OAAO,CAA8B;AAAA,EACzC;AAAA,EACA,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,MAAoB;AAClB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AAGpB,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,IACP,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAEA,gBAAc,aAAa,IAAI,KAAK,aAAa;AAGjD,QAAM,iBAAiB;AAAA,IACrB,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,EACT;AAEA,kBAAgB,eAAe,MAAM,KAAK,eAAe;AAEzD,QAAM,cAAc;AACpB,QAAM,YAAY,MAAO;AAEzB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,WAAW,IAAI,WAAW,IAAI,aAAa,IAAI,KAAK,IAAI,SAAS;AAAA,MAC9E,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,eAAQ;;;ADoIP,IAAAA,sBAAA;AAhPR,IAAM,eAAe;AAAA,EACnB,OAAO;AAAA,IACL,OAAO;AAAA,IACP,UAAU;AAAA,IACV,SAAS;AAAA,IACT,aAAa;AAAA,IACb,SAAS;AAAA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A;AAAA,gBACC;AAAA,gBACA,MAAK;AAAA,gBACL,IAAI;AAAA,gBACJ;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAU;AAAA,gBACV,WAAU;AAAA,gBACT,GAAG;AAAA;AAAA,YACN;AAAA,YAGA,6CAAC,WAAM,SAAS,SAAS,WAAW,cAEjC,qBAAW,6CAAC,SAAI,WAAW,YAAY,GAC1C;AAAA,YAGC,SACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW,8BAA8B,YAAY,WAAW;AAAA,gBAEhE;AAAA,kBAAC;AAAA;AAAA,oBACC,IAAG;AAAA,oBACH,SAAS;AAAA,oBACT,MAAM,YAAY;AAAA,oBAClB,QAAO;AAAA,oBACP,WAAW,GAAG,eAAe,CAAC,sEAAsE,cAAc;AAAA,oBAClH,OAAO,aAAa;AAAA,oBAEnB;AAAA;AAAA,gBACH;AAAA;AAAA,YACF;AAAA;AAAA;AAAA,MAEJ;AAAA,MAGC,gBACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,QAAO;AAAA,UACP,WAAU;AAAA,UACV,OAAM;AAAA,UAEL;AAAA;AAAA,MACH;AAAA,MAID,cAAc,CAAC,gBACd;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,QAAO;AAAA,UACP,WAAU;AAAA,UACV,OAAM;AAAA,UAEL;AAAA;AAAA,MACH;AAAA,OAEJ;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc;AAEpB,IAAO,gBAAQ;","names":["import_jsx_runtime"]}
|
package/dist/Radio/index.mjs
CHANGED
|
@@ -61,48 +61,34 @@ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
|
61
61
|
var SIZE_CLASSES = {
|
|
62
62
|
small: {
|
|
63
63
|
radio: "w-5 h-5",
|
|
64
|
-
// 20px x 20px
|
|
65
64
|
textSize: "sm",
|
|
66
65
|
spacing: "gap-1.5",
|
|
67
|
-
// 6px
|
|
68
66
|
borderWidth: "border-2",
|
|
69
|
-
dotSize: "w-
|
|
70
|
-
// 6px inner dot
|
|
67
|
+
dotSize: "w-2 h-2",
|
|
71
68
|
labelHeight: "h-5"
|
|
72
69
|
},
|
|
73
70
|
medium: {
|
|
74
71
|
radio: "w-6 h-6",
|
|
75
|
-
// 24px x 24px
|
|
76
72
|
textSize: "md",
|
|
77
73
|
spacing: "gap-2",
|
|
78
|
-
// 8px
|
|
79
74
|
borderWidth: "border-2",
|
|
80
|
-
dotSize: "w-2 h-2",
|
|
81
|
-
// 8px inner dot
|
|
75
|
+
dotSize: "w-2.5 h-2.5",
|
|
82
76
|
labelHeight: "h-6"
|
|
83
77
|
},
|
|
84
78
|
large: {
|
|
85
79
|
radio: "w-7 h-7",
|
|
86
|
-
// 28px x 28px
|
|
87
80
|
textSize: "lg",
|
|
88
81
|
spacing: "gap-2",
|
|
89
|
-
// 8px
|
|
90
82
|
borderWidth: "border-2",
|
|
91
|
-
|
|
92
|
-
dotSize: "w-2.5 h-2.5",
|
|
93
|
-
// 10px inner dot
|
|
83
|
+
dotSize: "w-3 h-3",
|
|
94
84
|
labelHeight: "h-7"
|
|
95
85
|
},
|
|
96
86
|
extraLarge: {
|
|
97
87
|
radio: "w-8 h-8",
|
|
98
|
-
// 32px x 32px (larger than large)
|
|
99
88
|
textSize: "xl",
|
|
100
89
|
spacing: "gap-3",
|
|
101
|
-
// 12px
|
|
102
90
|
borderWidth: "border-2",
|
|
103
|
-
|
|
104
|
-
dotSize: "w-3 h-3",
|
|
105
|
-
// 12px inner dot
|
|
91
|
+
dotSize: "w-3.5 h-3.5",
|
|
106
92
|
labelHeight: "h-8"
|
|
107
93
|
}
|
|
108
94
|
};
|
|
@@ -114,39 +100,27 @@ var STATE_CLASSES = {
|
|
|
114
100
|
},
|
|
115
101
|
hovered: {
|
|
116
102
|
unchecked: "border-border-500 bg-background",
|
|
117
|
-
// #8C8D8D hover state for unchecked
|
|
118
103
|
checked: "border-info-700 bg-background"
|
|
119
|
-
// Adjust checked border for hover
|
|
120
104
|
},
|
|
121
105
|
focused: {
|
|
122
106
|
unchecked: "border-border-400 bg-background",
|
|
123
|
-
// #A5A3A3 for unchecked radio
|
|
124
107
|
checked: "border-primary-950 bg-background"
|
|
125
|
-
// #124393 for checked radio
|
|
126
108
|
},
|
|
127
109
|
invalid: {
|
|
128
110
|
unchecked: "border-border-400 bg-background",
|
|
129
|
-
// #A5A3A3 for unchecked radio
|
|
130
111
|
checked: "border-primary-950 bg-background"
|
|
131
|
-
// #124393 for checked radio
|
|
132
112
|
},
|
|
133
113
|
disabled: {
|
|
134
114
|
unchecked: "border-border-400 bg-background cursor-not-allowed",
|
|
135
|
-
// #A5A3A3 for unchecked radio
|
|
136
115
|
checked: "border-primary-950 bg-background cursor-not-allowed"
|
|
137
|
-
// #124393 for checked radio
|
|
138
116
|
}
|
|
139
117
|
};
|
|
140
118
|
var DOT_CLASSES = {
|
|
141
119
|
default: "bg-primary-950",
|
|
142
120
|
hovered: "bg-info-700",
|
|
143
|
-
// #1C61B2 hover state for checked dot
|
|
144
121
|
focused: "bg-primary-950",
|
|
145
|
-
// #124393 for focused checked dot
|
|
146
122
|
invalid: "bg-primary-950",
|
|
147
|
-
// #124393 for invalid checked dot
|
|
148
123
|
disabled: "bg-primary-950"
|
|
149
|
-
// #124393 for disabled checked dot
|
|
150
124
|
};
|
|
151
125
|
var Radio = forwardRef(
|
|
152
126
|
({
|
|
@@ -232,7 +206,7 @@ var Radio = forwardRef(
|
|
|
232
206
|
label && /* @__PURE__ */ jsx2(
|
|
233
207
|
"div",
|
|
234
208
|
{
|
|
235
|
-
className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
|
|
209
|
+
className: `flex flex-row items-center ${sizeClasses.labelHeight} flex-1 min-w-0`,
|
|
236
210
|
children: /* @__PURE__ */ jsx2(
|
|
237
211
|
Text_default,
|
|
238
212
|
{
|
|
@@ -240,7 +214,7 @@ var Radio = forwardRef(
|
|
|
240
214
|
htmlFor: inputId,
|
|
241
215
|
size: sizeClasses.textSize,
|
|
242
216
|
weight: "normal",
|
|
243
|
-
className: `${getCursorClass()} select-none leading-normal flex items-center font-roboto ${labelClassName}`,
|
|
217
|
+
className: `${getCursorClass()} select-none leading-normal flex items-center font-roboto truncate ${labelClassName}`,
|
|
244
218
|
color: getTextColor(),
|
|
245
219
|
children: label
|
|
246
220
|
}
|
|
@@ -255,7 +229,7 @@ var Radio = forwardRef(
|
|
|
255
229
|
{
|
|
256
230
|
size: "sm",
|
|
257
231
|
weight: "normal",
|
|
258
|
-
className: "mt-1.5",
|
|
232
|
+
className: "mt-1.5 truncate",
|
|
259
233
|
color: "text-error-600",
|
|
260
234
|
children: errorMessage
|
|
261
235
|
}
|
|
@@ -265,7 +239,7 @@ var Radio = forwardRef(
|
|
|
265
239
|
{
|
|
266
240
|
size: "sm",
|
|
267
241
|
weight: "normal",
|
|
268
|
-
className: "mt-1.5",
|
|
242
|
+
className: "mt-1.5 truncate",
|
|
269
243
|
color: "text-text-500",
|
|
270
244
|
children: helperText
|
|
271
245
|
}
|