@aspprev/versi-ds 0.5.3 → 0.5.5

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/barcode/barcode.tsx","../src/components/file-upload/validation.ts","../src/components/file-upload/FileDropzone.tsx","../src/components/file-upload/FileUploadProgress.tsx","../src/components/file-upload/FileList.tsx","../src/components/file-upload/FileViewer.tsx","../src/components/qr-code/QRCode.tsx"],"sourcesContent":["\"use client\";\n\nimport JsBarcode from \"jsbarcode\";\nimport { useEffect, useRef, useState, type ReactNode } from \"react\";\n\nconst linhaDigitavelParaCodigoBarras = (linha: string): string => {\n const d = linha.replace(/\\D/g, \"\");\n\n const banco = d.substring(0, 3);\n const moeda = d.substring(3, 4);\n const campo1 = d.substring(4, 9);\n const campo2 = d.substring(10, 20);\n const campo3 = d.substring(21, 31);\n const digitoGeral = d.substring(32, 33);\n const vencimento = d.substring(33, 37);\n const valor = d.substring(37, 47);\n\n return banco + moeda + digitoGeral + vencimento + valor + campo1 + campo2 + campo3;\n};\n\nexport interface BoletoBarCodeProps {\n linhaDigitavel: string;\n /** Bar width passed to JsBarcode. */\n width?: number;\n /** Bar height in pixels. */\n height?: number;\n /** Quiet zone/margin in pixels. */\n quietZone?: number;\n error?: ReactNode;\n onError?: (error: Error) => void;\n}\n\nexport function BoletoBarCode({\n linhaDigitavel,\n width = 2,\n height = 80,\n quietZone = 0,\n error,\n onError,\n}: BoletoBarCodeProps) {\n const svgRef = useRef<SVGSVGElement>(null);\n const [generationError, setGenerationError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (!svgRef.current) return;\n setGenerationError(null);\n\n try {\n const codigoBarras = linhaDigitavelParaCodigoBarras(linhaDigitavel);\n\n JsBarcode(svgRef.current, codigoBarras, {\n format: \"ITF\",\n lineColor: \"#000000\",\n background: \"#FFFFFF\",\n displayValue: false,\n width,\n height,\n margin: quietZone,\n });\n } catch (cause: unknown) {\n const nextError = cause instanceof Error\n ? cause\n : new Error(\"Não foi possível gerar o código de barras.\");\n setGenerationError(nextError);\n onError?.(nextError);\n }\n }, [height, linhaDigitavel, onError, quietZone, width]);\n\n const displayError = error ?? generationError?.message;\n\n return (\n <div className=\"w-full space-y-3 bg-surface-card\">\n {displayError ? (\n <p role=\"alert\" className=\"text-sm text-field-assistive-error\">\n {displayError}\n </p>\n ) : (\n <svg ref={svgRef} className=\"w-full\" />\n )}\n <p className=\"text-center font-mono text-sm tracking-widest text-content-primary\">\n {linhaDigitavel}\n </p>\n </div>\n );\n}\n","export type FileValidationReason =\n | \"type\"\n | \"size\"\n | \"count\"\n | \"empty\"\n | \"invalid\";\n\nexport interface FileRejectionContext {\n code: FileValidationReason;\n fileName: string;\n extension: string;\n size: number;\n maxSize?: number;\n}\n\nexport type FileValidationMessage =\n | string\n | ((context: FileRejectionContext) => string);\n\nexport interface FileRejection {\n file: File;\n code: FileValidationReason;\n reason: FileValidationReason;\n fileName: string;\n extension: string;\n size: number;\n maxSize?: number;\n message: string;\n}\n\nexport interface FileValidationOptions {\n accept?: string;\n multiple?: boolean;\n maxFiles?: number;\n maxSize?: number;\n messages?: Partial<Record<FileValidationReason, FileValidationMessage>>;\n}\n\nexport interface FileValidationResult {\n accepted: File[];\n rejected: FileRejection[];\n}\n\nfunction acceptsFile(file: File, accept?: string) {\n if (!accept?.trim()) return true;\n\n return accept\n .split(\",\")\n .map((item) => item.trim().toLowerCase())\n .some((rule) => {\n if (rule.endsWith(\"/*\")) {\n return file.type.toLowerCase().startsWith(rule.slice(0, -1));\n }\n if (rule.startsWith(\".\")) {\n return file.name.toLowerCase().endsWith(rule);\n }\n return file.type.toLowerCase() === rule;\n });\n}\n\nfunction getExtension(fileName: string) {\n const extension = fileName.split(\".\").pop()?.trim().toLowerCase();\n return extension && extension !== fileName.toLowerCase() ? extension : \"\";\n}\n\nfunction rejectionMessage(\n reason: FileValidationReason,\n context: FileRejectionContext,\n messages?: FileValidationOptions[\"messages\"],\n) {\n const customMessage = messages?.[reason];\n if (typeof customMessage === \"function\") return customMessage(context);\n if (typeof customMessage === \"string\") return customMessage;\n if (reason === \"type\") return \"Tipo de arquivo não permitido.\";\n if (reason === \"size\") return \"O arquivo excede o tamanho máximo permitido.\";\n if (reason === \"empty\") return \"O arquivo está vazio.\";\n if (reason === \"invalid\") return \"O arquivo não é válido.\";\n return \"Quantidade máxima de arquivos excedida.\";\n}\n\nfunction normalizeMaxFiles(options: FileValidationOptions) {\n if (options.multiple === false) return 1;\n if (options.maxFiles === undefined || !Number.isFinite(options.maxFiles)) {\n return Number.POSITIVE_INFINITY;\n }\n return Math.max(1, Math.floor(options.maxFiles));\n}\n\nfunction normalizeMaxSize(maxSize?: number) {\n if (maxSize === undefined || !Number.isFinite(maxSize)) return undefined;\n return Math.max(0, maxSize);\n}\n\nexport function validateFiles(\n files: readonly File[] | FileList,\n options: FileValidationOptions = {},\n): FileValidationResult {\n const selected = Array.from(files);\n const maxFiles = normalizeMaxFiles(options);\n const maxSize = normalizeMaxSize(options.maxSize);\n const accepted: File[] = [];\n const rejected: FileRejection[] = [];\n\n selected.forEach((file, index) => {\n const isInvalid =\n !file ||\n typeof file.name !== \"string\" ||\n !file.name.trim() ||\n typeof file.size !== \"number\" ||\n !Number.isFinite(file.size) ||\n file.size < 0;\n const reason: FileValidationReason | undefined = isInvalid\n ? \"invalid\"\n : file.size === 0\n ? \"empty\"\n : !acceptsFile(file, options.accept)\n ? \"type\"\n : maxSize !== undefined && file.size > maxSize\n ? \"size\"\n : index >= maxFiles\n ? \"count\"\n : undefined;\n\n if (reason) {\n const fileName = typeof file?.name === \"string\" ? file.name : \"\";\n const size = typeof file?.size === \"number\" && Number.isFinite(file.size)\n ? file.size\n : 0;\n const context: FileRejectionContext = {\n code: reason,\n fileName,\n extension: getExtension(fileName),\n size,\n maxSize,\n };\n rejected.push({\n file,\n ...context,\n reason,\n message: rejectionMessage(reason, context, options.messages),\n });\n } else {\n accepted.push(file);\n }\n });\n\n return { accepted, rejected };\n}\n","\"use client\";\n\nimport classNames from \"classnames\";\nimport { useId, useRef, useState, type ChangeEvent, type DragEvent, type ReactNode } from \"react\";\nimport { validateFiles, type FileRejection, type FileValidationMessage } from \"./validation\";\n\nexport type { FileRejection } from \"./validation\";\n\nexport interface FileDropzoneProps {\n accept?: string;\n multiple?: boolean;\n maxFiles?: number;\n maxSize?: number;\n disabled?: boolean;\n id?: string;\n name?: string;\n required?: boolean;\n label?: ReactNode;\n hint?: ReactNode;\n error?: ReactNode;\n messages?: Partial<Record<\"type\" | \"size\" | \"count\" | \"empty\" | \"invalid\", FileValidationMessage>>;\n actions?: ReactNode;\n className?: string;\n onFilesAccepted?: (files: File[]) => void;\n onFilesRejected?: (rejections: FileRejection[]) => void;\n}\n\nexport function FileDropzone({\n accept,\n multiple = false,\n maxFiles = multiple ? Number.POSITIVE_INFINITY : 1,\n maxSize,\n disabled = false,\n id,\n name,\n required = false,\n label = \"Selecionar arquivos\",\n hint = \"Arraste e solte os arquivos aqui ou use o teclado para selecionar.\",\n error,\n messages,\n actions,\n className,\n onFilesAccepted,\n onFilesRejected,\n}: FileDropzoneProps) {\n const generatedInputId = useId();\n const inputId = id ?? generatedInputId;\n const messageId = `${inputId}-message`;\n const inputRef = useRef<HTMLInputElement>(null);\n const [isDragging, setIsDragging] = useState(false);\n const [rejectionMessage, setRejectionMessage] = useState<string>();\n\n const processFiles = (fileList: FileList | File[]) => {\n if (disabled) return;\n const { accepted, rejected } = validateFiles(fileList, {\n accept,\n maxFiles,\n maxSize,\n multiple,\n messages,\n });\n setRejectionMessage(rejected.length ? rejected.map((item) => item.message).join(\" \") : undefined);\n if (accepted.length) onFilesAccepted?.(accepted);\n if (rejected.length) onFilesRejected?.(rejected);\n };\n\n const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (event.target.files) processFiles(event.target.files);\n event.target.value = \"\";\n };\n const handleDrop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setIsDragging(false);\n processFiles(event.dataTransfer.files);\n };\n const hasError = Boolean(error || rejectionMessage);\n const message = error || rejectionMessage || hint;\n\n return (\n <div\n onDragEnter={(event) => { event.preventDefault(); if (!disabled) setIsDragging(true); }}\n onDragOver={(event) => event.preventDefault()}\n onDragLeave={(event) => { if (event.currentTarget === event.target) setIsDragging(false); }}\n onDrop={handleDrop}\n className={classNames(\n \"flex min-h-32 w-full cursor-pointer flex-col items-center justify-center rounded-sm border-2 border-dashed p-6 text-center transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring\",\n isDragging ? \"border-action-primary bg-primary-1/10\" : \"border-border-default bg-surface-card hover:border-border-strong\",\n disabled && \"cursor-not-allowed opacity-60\",\n hasError && \"border-field-border-error\",\n className,\n )}\n >\n <label htmlFor={inputId} className=\"flex cursor-pointer flex-col items-center focus-within:outline focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-focus-ring\">\n <span className=\"font-semibold text-content-primary\">{label}</span>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n name={name}\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n required={required}\n onChange={handleInputChange}\n aria-describedby={message ? messageId : undefined}\n aria-invalid={hasError ? true : undefined}\n className=\"sr-only\"\n />\n </label>\n {message && <span id={messageId} role={hasError ? \"alert\" : undefined} className={classNames(\"mt-1 text-sm\", hasError ? \"font-semibold text-field-assistive-error\" : \"text-content-secondary\")}>{message}</span>}\n {actions && <div className=\"mt-3 flex flex-wrap justify-center gap-2\">{actions}</div>}\n </div>\n );\n}\n\nexport default FileDropzone;\n","\"use client\";\n\nimport classNames from \"classnames\";\n\nexport type FileUploadProgressStatus = \"idle\" | \"uploading\" | \"success\" | \"error\";\n\nexport interface FileUploadProgressProps {\n value?: number | null;\n label?: string;\n status?: FileUploadProgressStatus;\n showValue?: boolean;\n className?: string;\n}\n\nexport function FileUploadProgress({\n value,\n label = \"Progresso do upload\",\n status = \"uploading\",\n showValue = true,\n className,\n}: FileUploadProgressProps) {\n const resolvedValue = typeof value === \"number\"\n ? Math.min(100, Math.max(0, value))\n : undefined;\n const statusText = status === \"success\"\n ? \"Concluído\"\n : status === \"error\"\n ? \"Erro\"\n : resolvedValue === undefined\n ? \"Em andamento\"\n : `${Math.round(resolvedValue)}%`;\n\n return (\n <div className={classNames(\"w-full\", className)}>\n <div className=\"mb-1 flex items-center justify-between gap-2 text-xs text-content-secondary\">\n <span>{label}</span>\n {showValue && <span aria-hidden=\"true\">{statusText}</span>}\n </div>\n <div\n role=\"progressbar\"\n aria-label={label}\n aria-valuemin={resolvedValue === undefined ? undefined : 0}\n aria-valuemax={resolvedValue === undefined ? undefined : 100}\n aria-valuenow={resolvedValue}\n aria-valuetext={statusText}\n className=\"h-2 w-full overflow-hidden rounded-full bg-surface-muted\"\n >\n <div\n className={classNames(\n \"h-full rounded-full transition-[width] duration-200\",\n status === \"error\" ? \"bg-feedback-danger-strong\" : \"bg-action-primary\",\n resolvedValue === undefined ? \"w-1/2 animate-pulse\" : undefined,\n )}\n style={resolvedValue === undefined ? undefined : { width: `${resolvedValue}%` }}\n />\n </div>\n <span className=\"sr-only\" role=\"status\" aria-live=\"polite\">{statusText}</span>\n </div>\n );\n}\n\nexport default FileUploadProgress;\n","\"use client\";\n\nimport classNames from \"classnames\";\nimport { MdClose, MdRefresh } from \"react-icons/md\";\nimport type { ReactNode } from \"react\";\nimport FileUploadProgress, { type FileUploadProgressStatus } from \"./FileUploadProgress\";\n\nexport type FileUploadItemStatus = FileUploadProgressStatus | \"pending\";\n\nexport interface FileUploadItem {\n id?: string;\n file: File;\n progress?: number | null;\n status?: FileUploadItemStatus;\n error?: string;\n}\n\nexport interface FileListProps {\n files: FileUploadItem[];\n accessibleName?: string;\n onRemove?: (item: FileUploadItem, index: number) => void;\n onRetry?: (item: FileUploadItem, index: number) => void;\n actions?: (item: FileUploadItem, index: number) => ReactNode;\n className?: string;\n}\n\nconst fileId = (item: FileUploadItem, index: number) => item.id ?? `${item.file.name}-${item.file.size}-${item.file.lastModified}-${index}`;\n\nconst statusDescription = (status: FileUploadItemStatus) => {\n if (status === \"uploading\") return \"Enviando\";\n if (status === \"success\") return \"Enviado\";\n if (status === \"error\") return \"Erro no envio\";\n return \"Aguardando envio\";\n};\n\nexport function FileList({ files, accessibleName = \"Arquivos selecionados\", onRemove, onRetry, actions, className }: FileListProps) {\n return (\n <ul aria-label={accessibleName} className={classNames(\"w-full space-y-2\", className)}>\n {files.map((item, index) => {\n const status = item.status ?? \"pending\";\n const progressStatus: FileUploadProgressStatus = status === \"pending\" ? \"idle\" : status;\n return (\n <li key={fileId(item, index)} aria-busy={status === \"uploading\" || undefined} className=\"flex min-w-0 flex-wrap items-center gap-3 rounded-sm border border-border-default bg-surface-card p-3\">\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate font-semibold text-content-primary\" title={item.file.name}>{item.file.name}</p>\n <p className=\"text-xs text-content-secondary\">{Math.ceil(item.file.size / 1024)} KB</p>\n <span className=\"sr-only\">Status: {statusDescription(status)}</span>\n {(status === \"uploading\" || status === \"success\" || status === \"error\") && (\n <FileUploadProgress value={item.progress} status={progressStatus} label={`Progresso de ${item.file.name}`} />\n )}\n {item.error && <p role=\"alert\" className=\"mt-1 text-sm font-semibold text-field-assistive-error\">{item.error}</p>}\n </div>\n <div className=\"flex shrink-0 items-center gap-1\">\n {actions?.(item, index)}\n {status === \"error\" && onRetry && <button type=\"button\" onClick={() => onRetry(item, index)} aria-label={`Tentar novamente ${item.file.name}`} className=\"flex h-11 w-11 items-center justify-center rounded-sm text-content-secondary hover:bg-surface-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus-ring\"><MdRefresh aria-hidden=\"true\" className=\"h-5 w-5\" /></button>}\n {onRemove && <button type=\"button\" onClick={() => onRemove(item, index)} aria-label={`Remover ${item.file.name}`} className=\"flex h-11 w-11 items-center justify-center rounded-sm text-content-secondary hover:bg-surface-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus-ring\"><MdClose aria-hidden=\"true\" className=\"h-5 w-5\" /></button>}\n </div>\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport default FileList;\n","\"use client\";\n\nimport classNames from \"classnames\";\nimport { useEffect, useRef, useState, type ReactNode } from \"react\";\n\nexport type FileViewerSource = string | Blob | {\n url?: string;\n blob?: Blob;\n contentType?: string;\n fileName?: string;\n};\n\nexport type FileViewerSourceInput =\n | FileViewerSource\n | Promise<FileViewerSource | null | undefined>;\n\nexport interface FileViewerProps {\n source?: FileViewerSourceInput;\n fileName?: string;\n contentType?: string;\n loading?: boolean;\n error?: ReactNode;\n onLoad?: () => void;\n onError?: (error: Error) => void;\n onDownload?: () => void;\n /** Consumer-owned actions such as retry, share or remove. */\n actions?: ReactNode;\n fallback?: ReactNode;\n title?: string;\n className?: string;\n}\n\nconst extensionType = (fileName?: string) => {\n const extension = fileName?.split(\".\").pop()?.toLowerCase();\n if (extension === \"pdf\") return \"application/pdf\";\n if ([\"png\", \"jpg\", \"jpeg\", \"gif\", \"webp\", \"svg\"].includes(extension ?? \"\")) {\n return `image/${extension === \"jpg\" ? \"jpeg\" : extension}`;\n }\n if ([\"txt\", \"csv\", \"json\", \"xml\", \"md\"].includes(extension ?? \"\")) return \"text/plain\";\n return \"application/octet-stream\";\n};\n\nconst normalizeContentType = (contentType: string) => contentType.split(\";\", 1)[0].trim().toLowerCase();\n\nconst toError = (cause: unknown) => (\n cause instanceof Error ? cause : new Error(\"Não foi possível ler o arquivo.\")\n);\n\nexport function FileViewer({\n source,\n fileName,\n contentType,\n loading = false,\n error,\n onLoad,\n onError,\n onDownload,\n actions,\n fallback,\n title = fileName ?? \"Visualização do arquivo\",\n className,\n}: FileViewerProps) {\n const [objectUrl, setObjectUrl] = useState<string>();\n const [textContent, setTextContent] = useState<string>();\n const [readError, setReadError] = useState<Error | null>(null);\n const [asyncSource, setAsyncSource] = useState<FileViewerSource>();\n const [sourceLoading, setSourceLoading] = useState(false);\n const onLoadRef = useRef(onLoad);\n const onErrorRef = useRef(onError);\n const isAsyncSource = Boolean(\n source &&\n typeof source === \"object\" &&\n \"then\" in source &&\n typeof source.then === \"function\",\n );\n\n useEffect(() => {\n if (!isAsyncSource) {\n setAsyncSource(undefined);\n setSourceLoading(false);\n return;\n }\n\n let active = true;\n setSourceLoading(true);\n setReadError(null);\n\n Promise.resolve(source as Promise<FileViewerSource | null | undefined>)\n .then((nextSource) => {\n if (!active) return;\n setAsyncSource(nextSource ?? undefined);\n setSourceLoading(false);\n })\n .catch((cause: unknown) => {\n if (!active) return;\n const nextError = toError(cause);\n setReadError(nextError);\n setSourceLoading(false);\n onErrorRef.current?.(nextError);\n });\n\n return () => {\n active = false;\n };\n }, [isAsyncSource, source]);\n\n const resolvedSource: FileViewerSource | undefined = isAsyncSource\n ? asyncSource\n : (source as FileViewerSource | undefined);\n const resolved = typeof resolvedSource === \"object\" && resolvedSource !== null && !(resolvedSource instanceof Blob) ? resolvedSource : undefined;\n const blob = resolvedSource instanceof Blob ? resolvedSource : resolved?.blob;\n const url = typeof resolvedSource === \"string\" ? resolvedSource : resolved?.url;\n const resolvedName = fileName ?? resolved?.fileName;\n const rawType = contentType?.trim() || resolved?.contentType || blob?.type || extensionType(resolvedName);\n const resolvedType = normalizeContentType(rawType);\n const isText = resolvedType.startsWith(\"text/\") || resolvedType === \"application/json\";\n const displayError = error ?? readError?.message;\n\n useEffect(() => {\n onLoadRef.current = onLoad;\n }, [onLoad]);\n\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n useEffect(() => {\n let active = true;\n setReadError(null);\n setTextContent(undefined);\n\n if (!blob) {\n setObjectUrl(undefined);\n return () => { active = false; };\n }\n\n let nextUrl: string;\n try {\n nextUrl = URL.createObjectURL(blob);\n setObjectUrl(nextUrl);\n } catch (cause) {\n const nextError = toError(cause);\n setReadError(nextError);\n onErrorRef.current?.(nextError);\n return () => { active = false; };\n }\n\n if (isText) {\n blob.text()\n .then((text: string) => {\n if (!active) return;\n setTextContent(text);\n onLoadRef.current?.();\n })\n .catch((cause: unknown) => {\n if (!active) return;\n const nextError = toError(cause);\n setReadError(nextError);\n onErrorRef.current?.(nextError);\n });\n }\n\n return () => {\n active = false;\n URL.revokeObjectURL(nextUrl);\n };\n }, [blob, isText]);\n\n const handleMediaError = () => {\n const nextError = new Error(\"Não foi possível carregar a visualização do arquivo.\");\n setReadError(nextError);\n onErrorRef.current?.(nextError);\n };\n const handleLoad = () => onLoadRef.current?.();\n\n if (loading || sourceLoading) {\n return (\n <div\n className={classNames(\"flex min-h-32 items-center justify-center rounded-sm border border-border-default bg-surface-card p-6 text-content-secondary\", className)}\n role=\"status\"\n aria-busy=\"true\"\n aria-live=\"polite\"\n >\n Carregando arquivo…\n </div>\n );\n }\n\n if (displayError) {\n return (\n <div className={classNames(\"rounded-sm border border-field-border-error bg-surface-card p-4 text-field-assistive-error\", className)} role=\"alert\">\n {displayError}\n </div>\n );\n }\n\n const displayUrl = objectUrl ?? url;\n if (!displayUrl && !textContent) {\n return (\n <div\n className={classNames(\"rounded-sm border border-border-default bg-surface-card p-4 text-content-secondary\", className)}\n role=\"region\"\n aria-label={title}\n >\n {fallback ?? \"Arquivo indisponível.\"}\n </div>\n );\n }\n\n const download = onDownload\n ? <button type=\"button\" onClick={onDownload} className=\"min-h-11 rounded-sm border border-border-default px-3 text-sm font-semibold text-content-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring\">Baixar arquivo</button>\n : displayUrl\n ? <a href={displayUrl} download={resolvedName} className=\"inline-flex min-h-11 items-center rounded-sm border border-border-default px-3 text-sm font-semibold text-content-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring\">Baixar arquivo</a>\n : null;\n\n return (\n <div\n className={classNames(\"flex min-w-0 flex-col gap-3 rounded-sm border border-border-default bg-surface-card p-3\", className)}\n role=\"region\"\n aria-label={title}\n >\n {resolvedType.startsWith(\"image/\") && displayUrl && (\n <img src={displayUrl} alt={title} onLoad={handleLoad} onError={handleMediaError} className=\"max-h-[70vh] max-w-full object-contain\" />\n )}\n {resolvedType === \"application/pdf\" && displayUrl && (\n <iframe src={displayUrl} title={title} onLoad={handleLoad} onError={handleMediaError} sandbox=\"\" className=\"min-h-[32rem] w-full border-0\" />\n )}\n {isText && (textContent !== undefined\n ? <pre className=\"max-h-[70vh] overflow-auto whitespace-pre-wrap break-words text-sm text-content-primary\">{textContent}</pre>\n : displayUrl && <iframe src={displayUrl} title={title} onLoad={handleLoad} onError={handleMediaError} sandbox=\"\" className=\"min-h-64 w-full border-0\" />)}\n {!resolvedType.startsWith(\"image/\") && resolvedType !== \"application/pdf\" && !isText && (\n fallback ?? <p className=\"text-content-secondary\">Este tipo de arquivo não possui visualização disponível.</p>\n )}\n {(download || actions) && (\n <div className=\"flex flex-wrap justify-end gap-2\">\n {actions}\n {download}\n </div>\n )}\n </div>\n );\n}\n\nexport default FileViewer;\n","\"use client\";\n\nimport QRCodeGenerator from \"qrcode\";\nimport { useEffect, useId, useMemo, useRef, useState, type HTMLAttributes, type ReactNode } from \"react\";\nimport classNames from \"classnames\";\n\nexport type QRCodeErrorCorrectionLevel = \"L\" | \"M\" | \"Q\" | \"H\";\n\nexport interface QRCodeProps extends Omit<HTMLAttributes<HTMLDivElement>, \"color\" | \"onError\"> {\n value: string;\n size?: number;\n level?: QRCodeErrorCorrectionLevel;\n includeMargin?: boolean;\n fgColor?: string;\n bgColor?: string;\n ariaLabel?: string;\n description?: string;\n loading?: boolean;\n error?: ReactNode;\n onError?: (error: Error) => void;\n}\n\nfunction getRelativeLuminance(color: string) {\n const match = color.trim().match(/^#([\\da-f]{6})$/i);\n if (!match) return null;\n\n const channels = [0, 2, 4].map((offset) => Number.parseInt(match[1].slice(offset, offset + 2), 16) / 255);\n const linear = channels.map((channel) => (\n channel <= 0.03928 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4\n ));\n\n return 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2];\n}\n\nfunction resolveAccessibleColors(fgColor: string, bgColor: string) {\n const foregroundLuminance = getRelativeLuminance(fgColor);\n const backgroundLuminance = getRelativeLuminance(bgColor);\n\n if (foregroundLuminance === null || backgroundLuminance === null) {\n return { dark: fgColor, light: bgColor };\n }\n\n const lighter = Math.max(foregroundLuminance, backgroundLuminance);\n const darker = Math.min(foregroundLuminance, backgroundLuminance);\n const contrastRatio = (lighter + 0.05) / (darker + 0.05);\n\n return contrastRatio >= 3\n ? { dark: fgColor, light: bgColor }\n : { dark: \"#000000\", light: \"#FFFFFF\" };\n}\n\nexport function QRCode({\n value,\n size = 192,\n level = \"M\",\n includeMargin = true,\n fgColor = \"#000000\",\n bgColor = \"#FFFFFF\",\n ariaLabel = \"Código QR\",\n description,\n loading = false,\n error,\n onError,\n className,\n ...rest\n}: QRCodeProps) {\n const [dataUrl, setDataUrl] = useState<string | null>(null);\n const [generationError, setGenerationError] = useState<Error | null>(null);\n const onErrorRef = useRef(onError);\n const generatedId = useId();\n const resolvedSize = Math.max(1, Number.isFinite(size) ? Math.floor(size) : 192);\n const descriptionId = description\n ? `${rest.id ?? generatedId}-description`\n : undefined;\n const colors = useMemo(\n () => resolveAccessibleColors(fgColor, bgColor),\n [bgColor, fgColor],\n );\n const describedBy = [rest[\"aria-describedby\"], descriptionId].filter(Boolean).join(\" \") || undefined;\n const displayError = error ?? generationError?.message;\n const isLoading = loading || (!dataUrl && !displayError);\n\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n useEffect(() => {\n let active = true;\n if (error) {\n setDataUrl(null);\n setGenerationError(null);\n return () => { active = false; };\n }\n setDataUrl(null);\n setGenerationError(null);\n QRCodeGenerator.toDataURL(value, {\n width: resolvedSize,\n margin: includeMargin ? 4 : 0,\n errorCorrectionLevel: level,\n color: colors,\n })\n .then((url) => { if (active) setDataUrl(url); })\n .catch((cause: unknown) => {\n if (!active) return;\n const nextError = cause instanceof Error\n ? cause\n : new Error(\"Não foi possível gerar o código QR.\");\n setDataUrl(null);\n setGenerationError(nextError);\n onErrorRef.current?.(nextError);\n });\n return () => { active = false; };\n }, [colors, error, includeMargin, level, resolvedSize, value]);\n\n return (\n <div\n {...rest}\n role=\"img\"\n aria-label={ariaLabel}\n aria-describedby={describedBy}\n aria-busy={isLoading || undefined}\n aria-invalid={displayError ? true : undefined}\n className={classNames(\"inline-flex max-w-full flex-col items-center gap-2\", className)}\n >\n {displayError ? (\n <span role=\"alert\" className=\"rounded-sm border border-field-border-error p-3 text-sm text-field-assistive-error\">\n {displayError}\n </span>\n ) : dataUrl ? (\n <img src={dataUrl} alt=\"\" width={resolvedSize} height={resolvedSize} className=\"h-auto max-w-full\" />\n ) : (\n <span\n aria-hidden=\"true\"\n className=\"inline-block animate-pulse rounded-sm bg-surface-muted\"\n style={{ width: resolvedSize, height: resolvedSize, maxWidth: \"100%\" }}\n />\n )}\n {description && <span id={descriptionId} className=\"sr-only\">{description}</span>}\n </div>\n );\n}\n\nexport default QRCode;\n"],"mappings":";AAEA,OAAO,eAAe;AACtB,SAAS,WAAW,QAAQ,gBAAgC;AAoExD,SAEI,KAFJ;AAlEJ,IAAM,iCAAiC,CAAC,UAA0B;AAChE,QAAM,IAAI,MAAM,QAAQ,OAAO,EAAE;AAEjC,QAAM,QAAQ,EAAE,UAAU,GAAG,CAAC;AAC9B,QAAM,QAAQ,EAAE,UAAU,GAAG,CAAC;AAC9B,QAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAC/B,QAAM,SAAS,EAAE,UAAU,IAAI,EAAE;AACjC,QAAM,SAAS,EAAE,UAAU,IAAI,EAAE;AACjC,QAAM,cAAc,EAAE,UAAU,IAAI,EAAE;AACtC,QAAM,aAAa,EAAE,UAAU,IAAI,EAAE;AACrC,QAAM,QAAQ,EAAE,UAAU,IAAI,EAAE;AAEhC,SAAO,QAAQ,QAAQ,cAAc,aAAa,QAAQ,SAAS,SAAS;AAC9E;AAcO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,QAAQ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AK;AAAA,MACL,cAAY;AAAA,MACZ,oBAAkB;AAAA,MAClB,aAAW,aAAa;AAAA,MACxB,gBAAc,eAAe,OAAO;AAAA,MACpC,WAAWF,YAAW,sDAAsD,SAAS;AAAA,MAEpF;AAAA,uBACC,gBAAAC,KAAC,UAAK,MAAK,SAAQ,WAAU,sFAC1B,wBACH,IACE,UACF,gBAAAA,KAAC,SAAI,KAAK,SAAS,KAAI,IAAG,OAAO,cAAc,QAAQ,cAAc,WAAU,qBAAoB,IAEnG,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC,eAAY;AAAA,YACZ,WAAU;AAAA,YACV,OAAO,EAAE,OAAO,cAAc,QAAQ,cAAc,UAAU,OAAO;AAAA;AAAA,QACvE;AAAA,QAED,eAAe,gBAAAA,KAAC,UAAK,IAAI,eAAe,WAAU,WAAW,uBAAY;AAAA;AAAA;AAAA,EAC5E;AAEJ;AAEA,IAAO,iBAAQ;","names":["useRef","useState","jsx","jsxs","useRef","useState","rejectionMessage","classNames","jsx","jsxs","classNames","jsx","jsxs","classNames","classNames","useEffect","useRef","useState","jsx","jsxs","useEffect","useId","useRef","useState","classNames","jsx","jsxs"]}
@@ -23,12 +23,12 @@ import { forwardRef } from "react";
23
23
  // src/components/field/field-styles.ts
24
24
  var FIELD_ROOT_CLASS = "field-layout flex w-full min-w-0 flex-col leading-6";
25
25
  var FIELD_LABEL_CLASS = "field-label-slot px-0.5 text-md tracking-wide text-field-content";
26
- var FIELD_CONTROL_CLASS = "field-control-slot field-keyboard-focus-ring relative mt-4xs mb-[4px] flex min-h-control-md w-full min-w-0 items-center gap-3 rounded-sm border border-field-border-default bg-field-surface px-3 text-field-icon transition-colors focus-within:border-field-border-active focus-within:text-field-content data-[has-value=true]:text-field-content";
27
- var FIELD_DISABLED_CLASS = "cursor-not-allowed border-field-border-default bg-field-surface-disabled text-field-content-disabled focus-within:border-field-border-default";
28
- var FIELD_ERROR_CLASS = "border-field-border-error text-field-assistive-error focus-within:border-field-border-error";
29
- var FIELD_MESSAGE_CLASS = "field-message-slot text-xs tracking-wide text-field-assistive-error";
26
+ var FIELD_CONTROL_CLASS = "field-control-slot field-keyboard-focus-ring relative mt-4xs mb-[4px] flex min-h-control-md w-full min-w-0 items-center gap-3 rounded-sm border border-field-border-default bg-field-surface px-[var(--field-padding-x,var(--spacing-xs))] [&.border-2]:px-[calc(var(--field-padding-x,var(--spacing-xs))-1px)] text-field-icon transition-colors focus-within:border-field-border-active focus-within:text-field-content data-[has-value=true]:text-field-content";
27
+ var FIELD_DISABLED_CLASS = "cursor-not-allowed border-field-border-default bg-field-surface-disabled text-field-placeholder-disabled data-[has-value=true]:text-field-content-disabled focus-within:border-field-border-default";
28
+ var FIELD_ERROR_CLASS = "border-2 border-field-border-error text-field-assistive-error focus-within:border-field-border-error";
29
+ var FIELD_MESSAGE_CLASS = "field-message-slot min-w-0 whitespace-normal break-words text-xs font-semibold tracking-wide text-field-assistive-error";
30
30
  var FIELD_DESCRIPTION_CLASS = "field-message-slot text-xs tracking-wide text-field-assistive";
31
- var FIELD_INPUT_CLASS = "w-full border-none bg-transparent text-field-content outline-none placeholder:text-field-placeholder focus:outline-none disabled:text-field-content-disabled disabled:placeholder:text-field-content-disabled";
31
+ var FIELD_INPUT_CLASS = "field-value w-full border-none bg-transparent text-field-content outline-none placeholder:text-field-placeholder focus:outline-none disabled:text-field-content-disabled disabled:placeholder:text-field-placeholder-disabled";
32
32
 
33
33
  // src/components/field/FieldFrame.tsx
34
34
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1281,7 +1281,9 @@ var InputSelect = ({
1281
1281
  "span",
1282
1282
  {
1283
1283
  className: classNames3("block w-full truncate overflow-hidden", {
1284
- "text-field-placeholder": !selectedOption && placeholder
1284
+ "text-field-placeholder": !disabled && !selectedOption && placeholder,
1285
+ "text-field-content-disabled": disabled && Boolean(selectedOption),
1286
+ "text-field-placeholder-disabled": disabled && !selectedOption
1285
1287
  }),
1286
1288
  children: selectedOption ? selectedOption.label : placeholder
1287
1289
  }
@@ -1446,7 +1448,7 @@ var InputSelect = ({
1446
1448
  closeDropdown();
1447
1449
  }
1448
1450
  },
1449
- className: classNames3(`${FIELD_CONTROL_CLASS} px-2`, {
1451
+ className: classNames3(`${FIELD_CONTROL_CLASS} [--field-padding-x:var(--spacing-2xs)]`, {
1450
1452
  [FIELD_DISABLED_CLASS]: disabled,
1451
1453
  [FIELD_ERROR_CLASS]: hasError,
1452
1454
  "cursor-pointer": !disabled
@@ -1459,7 +1461,8 @@ var InputSelect = ({
1459
1461
  className: classNames3(`h-5 w-5`, {
1460
1462
  "text-field-assistive-error": hasError,
1461
1463
  "text-field-content": !hasError && (open || selectedOption),
1462
- "text-field-content-disabled": disabled,
1464
+ "text-field-content-disabled": disabled && Boolean(selectedOption),
1465
+ "text-field-placeholder-disabled": disabled && !selectedOption,
1463
1466
  "cursor-not-allowed": disabled,
1464
1467
  "cursor-pointer": !disabled
1465
1468
  })
@@ -1470,10 +1473,12 @@ var InputSelect = ({
1470
1473
  "span",
1471
1474
  {
1472
1475
  className: classNames3(
1473
- "flex-1 min-w-0 flex items-center justify-between leading-5",
1474
- "bg-transparent text-field-content text-left",
1476
+ "field-value flex-1 min-w-0 flex items-center justify-between leading-5",
1477
+ "bg-transparent text-left",
1475
1478
  {
1476
- "text-field-content-disabled": disabled,
1479
+ "text-field-content": !disabled,
1480
+ "text-field-content-disabled": disabled && Boolean(selectedOption),
1481
+ "text-field-placeholder-disabled": disabled && !selectedOption,
1477
1482
  "cursor-not-allowed": disabled,
1478
1483
  "cursor-pointer": !disabled
1479
1484
  }
@@ -1488,7 +1493,8 @@ var InputSelect = ({
1488
1493
  className: classNames3(`h-5 w-5`, {
1489
1494
  "text-field-assistive-error": hasError,
1490
1495
  "text-field-content": !hasError && (open || selectedOption),
1491
- "text-field-content-disabled": disabled,
1496
+ "text-field-content-disabled": disabled && Boolean(selectedOption),
1497
+ "text-field-placeholder-disabled": disabled && !selectedOption,
1492
1498
  "cursor-not-allowed": disabled,
1493
1499
  "cursor-pointer": !disabled
1494
1500
  })
@@ -1497,11 +1503,13 @@ var InputSelect = ({
1497
1503
  "span",
1498
1504
  {
1499
1505
  className: classNames3(
1500
- "flex items-center justify-center text-field-icon",
1506
+ "flex items-center justify-center",
1501
1507
  {
1508
+ "text-field-icon": !hasError && !open && !selectedOption && !disabled,
1502
1509
  "text-field-assistive-error": hasError,
1503
1510
  "text-field-content": !hasError && (open || selectedOption),
1504
- "text-field-content-disabled": disabled,
1511
+ "text-field-content-disabled": disabled && Boolean(selectedOption),
1512
+ "text-field-placeholder-disabled": disabled && !selectedOption,
1505
1513
  "cursor-not-allowed": disabled,
1506
1514
  "cursor-pointer": !disabled
1507
1515
  }
@@ -1584,7 +1592,8 @@ var TextArea = ({
1584
1592
  {
1585
1593
  "data-has-value": String(field.value ?? "").length > 0,
1586
1594
  className: classNames4(
1587
- `${FIELD_CONTROL_CLASS} py-1`,
1595
+ FIELD_CONTROL_CLASS,
1596
+ hasError ? "py-[calc(var(--spacing-4xs)-1px)]" : "py-1",
1588
1597
  {
1589
1598
  [FIELD_DISABLED_CLASS]: disabled,
1590
1599
  [FIELD_ERROR_CLASS]: hasError
@@ -2001,7 +2010,7 @@ function InputPhone({
2001
2010
  field.value,
2002
2011
  availableCountries
2003
2012
  );
2004
- helpers.setValue(parsed);
2013
+ helpers.setValue(parsed, false);
2005
2014
  initializedRef.current = true;
2006
2015
  }, [availableCountries, field.value, helpers]);
2007
2016
  useEffect3(() => {
@@ -2079,11 +2088,16 @@ function InputPhone({
2079
2088
  },
2080
2089
  onBlur: () => helpers.setTouched(true),
2081
2090
  className: classNames5(
2082
- "flex h-full items-center gap-1.5 pl-2 pr-1 text-left",
2083
- "border-r border-field-border-default bg-transparent text-field-content focus:outline-none",
2091
+ "flex shrink-0 self-stretch items-center gap-0.5 pl-1 pr-0.5 text-left",
2092
+ "border-r bg-transparent focus:outline-none",
2084
2093
  {
2094
+ "pl-[calc(var(--spacing-4xs)-1px)]": hasError,
2095
+ "border-field-border-error text-field-assistive-error": hasError && !disabled,
2096
+ "border-field-border-default text-field-content": !hasError && !disabled,
2085
2097
  "cursor-pointer": !disabled,
2086
- "cursor-not-allowed text-content-disabled": disabled
2098
+ "cursor-not-allowed border-field-border-default": disabled,
2099
+ "text-field-content-disabled": disabled && phoneDigits.length > 0,
2100
+ "text-field-placeholder-disabled": disabled && phoneDigits.length === 0
2087
2101
  }
2088
2102
  ),
2089
2103
  children: [
@@ -2093,24 +2107,28 @@ function InputPhone({
2093
2107
  MdOutlineKeyboardArrowUp2,
2094
2108
  {
2095
2109
  className: classNames5("h-4 w-4 shrink-0", {
2096
- "text-field-assistive-error": hasError,
2097
- "text-field-content": !hasError
2110
+ "text-field-assistive-error": hasError && !disabled,
2111
+ "text-field-content": !hasError && !disabled,
2112
+ "text-field-content-disabled": disabled && phoneDigits.length > 0,
2113
+ "text-field-placeholder-disabled": disabled && phoneDigits.length === 0
2098
2114
  })
2099
2115
  }
2100
2116
  ) : /* @__PURE__ */ jsx6(
2101
2117
  MdOutlineKeyboardArrowDown2,
2102
2118
  {
2103
2119
  className: classNames5("h-4 w-4 shrink-0", {
2104
- "text-field-assistive-error": hasError,
2105
- "text-field-content": !hasError && phoneDigits.length > 0,
2106
- "text-field-icon": !hasError && phoneDigits.length === 0
2120
+ "text-field-assistive-error": hasError && !disabled,
2121
+ "text-field-content": !hasError && !disabled && phoneDigits.length > 0,
2122
+ "text-field-icon": !hasError && !disabled && phoneDigits.length === 0,
2123
+ "text-field-content-disabled": disabled && phoneDigits.length > 0,
2124
+ "text-field-placeholder-disabled": disabled && phoneDigits.length === 0
2107
2125
  })
2108
2126
  }
2109
2127
  )
2110
2128
  ]
2111
2129
  }
2112
2130
  ),
2113
- /* @__PURE__ */ jsx6("div", { className: "min-w-0 flex-1 pl-1 pr-3", children: phoneMask ? /* @__PURE__ */ jsx6(
2131
+ /* @__PURE__ */ jsx6("div", { className: classNames5("min-w-0 flex-1 pl-1", hasError ? "pr-[calc(var(--spacing-xs)-1px)]" : "pr-3"), children: phoneMask ? /* @__PURE__ */ jsx6(
2114
2132
  PatternFormat2,
2115
2133
  {
2116
2134
  id: name,
@@ -2812,13 +2830,16 @@ var UnifiedDatePicker = ({
2812
2830
  type: "button",
2813
2831
  disabled: isFieldDisabled,
2814
2832
  onClick: openCalendar,
2815
- className: "flex items-center justify-center disabled:cursor-not-allowed",
2833
+ className: classNames6(
2834
+ "flex items-center justify-center disabled:cursor-not-allowed",
2835
+ draftValue ? "disabled:text-field-content-disabled" : "disabled:text-field-placeholder-disabled"
2836
+ ),
2816
2837
  "aria-label": "Abrir calendario",
2817
2838
  children: /* @__PURE__ */ jsx7(
2818
2839
  MdCalendarMonth,
2819
2840
  {
2820
2841
  className: classNames6("h-5 w-5", {
2821
- "text-field-assistive-error": hasError
2842
+ "text-field-assistive-error": hasError && !isFieldDisabled
2822
2843
  })
2823
2844
  }
2824
2845
  )
@@ -3101,6 +3122,9 @@ function SelectMultiView(props) {
3101
3122
  const containerRef = useRef6(null);
3102
3123
  const triggerRef = useRef6(null);
3103
3124
  const groupRef = useRef6(null);
3125
+ const valueRef = useRef6(null);
3126
+ const measurementRef = useRef6(null);
3127
+ const [visibleCount, setVisibleCount] = useState6(null);
3104
3128
  const baseId = useId4();
3105
3129
  const triggerId = `${baseId}-trigger`;
3106
3130
  const labelId = `${baseId}-label`;
@@ -3108,7 +3132,18 @@ function SelectMultiView(props) {
3108
3132
  const summaryId = `${baseId}-summary`;
3109
3133
  const errorId = `${baseId}-error`;
3110
3134
  const selectedCount = checkedList.length;
3135
+ const selectedLabels = checkedList.map(
3136
+ (value) => options.find((option) => option.value === value)?.label ?? value
3137
+ );
3138
+ const selectionKey = JSON.stringify(selectedLabels);
3139
+ const displayedCount = Math.min(selectedCount, visibleCount ?? selectedCount);
3140
+ const hiddenCount = selectedCount - displayedCount;
3141
+ const chipClass = cs(
3142
+ "rounded-full px-1 py-0.5 text-sm",
3143
+ disabled ? "bg-surface-muted text-field-content-disabled" : "bg-action-primary text-action-primary-content"
3144
+ );
3111
3145
  const selectedSummary = selectedCount === 0 ? "Nenhuma op\xE7\xE3o selecionada" : selectedCount === 1 ? "1 op\xE7\xE3o selecionada" : `${selectedCount} op\xE7\xF5es selecionadas`;
3146
+ const accessibleSummary = selectedCount > 0 ? `${selectedSummary}: ${selectedLabels.join(", ")}` : selectedSummary;
3112
3147
  const describedBy = [summaryId, error ? errorId : void 0].filter(Boolean).join(" ");
3113
3148
  const floatingLayerClass = getFloatingLayerClass(
3114
3149
  triggerRef.current,
@@ -3119,6 +3154,53 @@ function SelectMultiView(props) {
3119
3154
  setIsOpened(false);
3120
3155
  triggerRef.current?.focus({ preventScroll: true });
3121
3156
  };
3157
+ useEffect5(() => {
3158
+ const valueElement = valueRef.current;
3159
+ const measurements = measurementRef.current;
3160
+ if (!valueElement || !measurements || selectedCount === 0) return;
3161
+ let active = true;
3162
+ const update = () => {
3163
+ if (!active) return;
3164
+ const available = valueElement.getBoundingClientRect().width;
3165
+ const labels = Array.from(measurements.querySelectorAll("[data-label-width]"));
3166
+ const partialLabels = Array.from(measurements.querySelectorAll("[data-partial-width]"));
3167
+ const counters = Array.from(measurements.querySelectorAll("[data-counter-width]"));
3168
+ const gap = Number.parseFloat(window.getComputedStyle(valueElement).columnGap) || 0;
3169
+ const totalWidth = labels.reduce((sum, element) => sum + element.getBoundingClientRect().width, 0) + Math.max(0, selectedCount - 1) * gap;
3170
+ if (totalWidth <= available) {
3171
+ setVisibleCount(selectedCount);
3172
+ return;
3173
+ }
3174
+ let used = 0;
3175
+ let fitting = 0;
3176
+ for (let index = 0; index < labels.length; index += 1) {
3177
+ const fullWidth = labels[index].getBoundingClientRect().width;
3178
+ used += fullWidth + (index > 0 ? gap : 0);
3179
+ const remaining = selectedCount - index - 1;
3180
+ const counterWidth = remaining > 0 ? counters[remaining - 1].getBoundingClientRect().width + gap : 0;
3181
+ if (used + counterWidth <= available) fitting = index + 1;
3182
+ else {
3183
+ const partialWidth = Math.min(fullWidth, partialLabels[index].getBoundingClientRect().width);
3184
+ if (used - fullWidth + partialWidth + counterWidth <= available) fitting = index + 1;
3185
+ break;
3186
+ }
3187
+ }
3188
+ setVisibleCount(Math.max(1, fitting));
3189
+ };
3190
+ update();
3191
+ const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : void 0;
3192
+ observer?.observe(valueElement);
3193
+ observer?.observe(measurements);
3194
+ window.addEventListener("resize", update);
3195
+ document.fonts?.addEventListener("loadingdone", update);
3196
+ void document.fonts?.ready.then(update);
3197
+ return () => {
3198
+ active = false;
3199
+ observer?.disconnect();
3200
+ window.removeEventListener("resize", update);
3201
+ document.fonts?.removeEventListener("loadingdone", update);
3202
+ };
3203
+ }, [selectionKey, selectedCount, onClear]);
3122
3204
  useEffect5(() => {
3123
3205
  if (!isOpened) return;
3124
3206
  groupRef.current?.querySelector('input[type="checkbox"]')?.focus({ preventScroll: true });
@@ -3194,6 +3276,7 @@ function SelectMultiView(props) {
3194
3276
  {
3195
3277
  type: "button",
3196
3278
  id: triggerId,
3279
+ "data-has-value": selectedCount > 0,
3197
3280
  ref: triggerRef,
3198
3281
  "aria-controls": groupId,
3199
3282
  "aria-expanded": isOpened,
@@ -3214,24 +3297,46 @@ function SelectMultiView(props) {
3214
3297
  }
3215
3298
  },
3216
3299
  className: cs(
3217
- "flex h-control-md w-full cursor-pointer items-center justify-between rounded-sm border border-field-border-default bg-field-surface px-3 text-field-icon focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring",
3218
- error && "border-field-border-error text-field-assistive-error",
3300
+ "flex h-control-md w-full cursor-pointer items-center justify-between gap-1 rounded-sm border border-field-border-default bg-field-surface px-3 text-field-icon focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring",
3301
+ error && "border-2 px-[calc(var(--spacing-xs)-1px)] border-field-border-error text-field-assistive-error",
3219
3302
  !error && isOpened && "border-field-border-active text-field-content",
3220
3303
  !error && selectedCount > 0 && "text-field-content",
3221
3304
  disabled && "cursor-not-allowed border-field-border-default bg-field-surface-disabled text-field-content-disabled"
3222
3305
  ),
3223
3306
  children: [
3224
- /* @__PURE__ */ jsx8(
3307
+ /* @__PURE__ */ jsxs7(
3225
3308
  "span",
3226
3309
  {
3310
+ ref: valueRef,
3311
+ title: selectedCount > 0 ? selectedLabels.join(", ") : void 0,
3227
3312
  className: cs(
3228
- "min-w-0 flex-1 truncate text-left text-base font-normal text-field-placeholder",
3313
+ "field-value relative flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-left text-base font-normal",
3229
3314
  {
3230
- "pr-12 text-field-content": !disabled && selectedCount > 0,
3231
- "text-field-content-disabled": disabled
3315
+ "mr-[40px]": selectedCount > 0 && Boolean(onClear),
3316
+ "text-field-placeholder": !disabled && selectedCount === 0,
3317
+ "text-field-content": !disabled && selectedCount > 0,
3318
+ "text-field-content-disabled": disabled && selectedCount > 0,
3319
+ "text-field-placeholder-disabled": disabled && selectedCount === 0
3232
3320
  }
3233
3321
  ),
3234
- children: "Selecione"
3322
+ children: [
3323
+ selectedCount === 0 ? /* @__PURE__ */ jsx8("span", { className: "min-w-0 truncate", "aria-hidden": "true", children: "Selecione" }) : selectedLabels.slice(0, displayedCount).map((text, index) => /* @__PURE__ */ jsx8("span", { className: cs("min-w-0 truncate", index < displayedCount - 1 && "shrink-0", chipClass), "aria-hidden": "true", children: text }, index)),
3324
+ hiddenCount > 0 && /* @__PURE__ */ jsxs7("span", { "aria-hidden": "true", className: cs("shrink-0", chipClass), children: [
3325
+ "+",
3326
+ hiddenCount
3327
+ ] }),
3328
+ selectedCount > 0 && /* @__PURE__ */ jsxs7("span", { ref: measurementRef, "aria-hidden": "true", className: "pointer-events-none invisible absolute left-0 top-0 flex w-max whitespace-pre", style: { font: "inherit" }, children: [
3329
+ selectedLabels.map((text, index) => /* @__PURE__ */ jsx8("span", { "data-label-width": true, className: chipClass, children: text }, index)),
3330
+ selectedLabels.map((text, index) => /* @__PURE__ */ jsxs7("span", { "data-partial-width": true, className: chipClass, children: [
3331
+ Array.from(text).slice(0, 6).join(""),
3332
+ "\u2026"
3333
+ ] }, index)),
3334
+ selectedLabels.map((_, index) => /* @__PURE__ */ jsxs7("span", { "data-counter-width": true, className: chipClass, children: [
3335
+ "+",
3336
+ index + 1
3337
+ ] }, index))
3338
+ ] })
3339
+ ]
3235
3340
  }
3236
3341
  ),
3237
3342
  /* @__PURE__ */ jsx8(
@@ -3239,12 +3344,14 @@ function SelectMultiView(props) {
3239
3344
  {
3240
3345
  "aria-hidden": "true",
3241
3346
  className: cs(
3242
- "shrink-0 text-base text-field-icon transition-transform",
3347
+ "shrink-0 text-base transition-transform",
3243
3348
  {
3349
+ "text-field-icon": !error && !isOpened && selectedCount === 0 && !disabled,
3244
3350
  "rotate-180": isOpened,
3245
3351
  "text-field-assistive-error": error,
3246
3352
  "text-field-content": !error && (isOpened || selectedCount > 0),
3247
- "text-field-content-disabled": disabled
3353
+ "text-field-content-disabled": disabled && selectedCount > 0,
3354
+ "text-field-placeholder-disabled": disabled && !(selectedCount > 0)
3248
3355
  }
3249
3356
  )
3250
3357
  }
@@ -3252,7 +3359,7 @@ function SelectMultiView(props) {
3252
3359
  ]
3253
3360
  }
3254
3361
  ),
3255
- /* @__PURE__ */ jsx8("span", { id: summaryId, className: "sr-only", children: selectedSummary }),
3362
+ /* @__PURE__ */ jsx8("span", { id: summaryId, className: "sr-only", children: accessibleSummary }),
3256
3363
  isOpened && /* @__PURE__ */ jsx8(
3257
3364
  "div",
3258
3365
  {
@@ -3303,18 +3410,18 @@ function SelectMultiView(props) {
3303
3410
  })
3304
3411
  }
3305
3412
  ),
3306
- selectedCount > 0 && onClear && /* @__PURE__ */ jsxs7(
3413
+ selectedCount > 0 && onClear && /* @__PURE__ */ jsx8(
3307
3414
  "button",
3308
3415
  {
3309
3416
  type: "button",
3310
3417
  "aria-label": `Limpar sele\xE7\xE3o de ${label ?? "op\xE7\xF5es"}`,
3311
3418
  disabled,
3312
- onClick: onClear,
3313
- className: "absolute right-9 top-1/2 flex min-h-6 min-w-6 -translate-y-1/2 touch-manipulation items-center justify-center gap-1 rounded-full bg-action-primary px-2 text-xs text-action-primary-content focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed",
3314
- children: [
3315
- /* @__PURE__ */ jsx8("span", { "aria-hidden": "true", children: selectedCount }),
3316
- /* @__PURE__ */ jsx8(MdClose, { "aria-hidden": "true", size: 10 })
3317
- ]
3419
+ onClick: () => {
3420
+ onClear();
3421
+ triggerRef.current?.focus({ preventScroll: true });
3422
+ },
3423
+ className: "absolute right-[40px] top-1/2 flex h-6 w-6 -translate-y-1/2 touch-manipulation items-center justify-center rounded-sm text-field-icon focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed disabled:text-field-content-disabled",
3424
+ children: /* @__PURE__ */ jsx8(MdClose, { "aria-hidden": "true", size: 16 })
3318
3425
  }
3319
3426
  )
3320
3427
  ]
@@ -3433,7 +3540,7 @@ function RadioGroup({
3433
3540
  /* @__PURE__ */ jsx11("div", { className: "field-control-slot mt-4xs mb-[4px] flex min-h-control-md flex-wrap items-center gap-x-6 gap-y-2", children: options.map((option) => /* @__PURE__ */ jsxs9(
3434
3541
  "label",
3435
3542
  {
3436
- className: "flex min-h-7 cursor-pointer items-center gap-2",
3543
+ className: `flex min-h-7 items-center gap-2 ${rest.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
3437
3544
  children: [
3438
3545
  /* @__PURE__ */ jsx11(
3439
3546
  "input",
@@ -3448,7 +3555,7 @@ function RadioGroup({
3448
3555
  className: "radio-control"
3449
3556
  }
3450
3557
  ),
3451
- /* @__PURE__ */ jsx11("span", { className: "text-content-secondary", children: option.label })
3558
+ /* @__PURE__ */ jsx11("span", { className: rest.disabled ? "text-field-content-disabled" : "text-content-secondary", children: option.label })
3452
3559
  ]
3453
3560
  },
3454
3561
  option.value
@@ -3541,9 +3648,10 @@ function RadioCardGroup({
3541
3648
  htmlFor: optionId,
3542
3649
  className: classNames7(
3543
3650
  "block rounded-md border p-4 transition-colors",
3544
- checked ? "border-primary-1 bg-primary-5" : "border-transparent bg-bg-light",
3545
- hasError && !checked ? "outline outline-1 outline-feedback-danger-border" : "outline outline-1 outline-transparent",
3546
- optionDisabled ? "cursor-not-allowed opacity-60" : "cursor-pointer",
3651
+ optionDisabled ? "bg-field-surface-disabled" : checked ? "bg-primary-5" : "bg-bg-light",
3652
+ !hasError && (checked ? "border-primary-1" : "border-transparent"),
3653
+ hasError ? "border-2 border-field-border-error p-[calc(var(--spacing-sm)-1px)]" : "outline outline-1 outline-transparent",
3654
+ optionDisabled ? "cursor-not-allowed" : "cursor-pointer",
3547
3655
  optionClassName
3548
3656
  ),
3549
3657
  children: /* @__PURE__ */ jsxs10("div", { className: "flex items-start gap-3", children: [
@@ -3567,8 +3675,8 @@ function RadioCardGroup({
3567
3675
  }
3568
3676
  ),
3569
3677
  /* @__PURE__ */ jsxs10("div", { className: "min-w-0 flex-1", children: [
3570
- /* @__PURE__ */ jsx12("div", { className: "font-bold text-content-primary", children: option.title }),
3571
- option.description && /* @__PURE__ */ jsx12("div", { className: "mt-1 text-content-primary", children: option.description })
3678
+ /* @__PURE__ */ jsx12("div", { className: classNames7("font-bold", optionDisabled ? "text-field-content-disabled" : "text-content-primary"), children: option.title }),
3679
+ option.description && /* @__PURE__ */ jsx12("div", { className: classNames7("mt-1", optionDisabled ? "text-field-content-disabled" : "text-content-primary"), children: option.description })
3572
3680
  ] })
3573
3681
  ] })
3574
3682
  },
@@ -3581,7 +3689,7 @@ function RadioCardGroup({
3581
3689
  id: errorId,
3582
3690
  role: "alert",
3583
3691
  "aria-live": "assertive",
3584
- className: "mt-1 text-xs tracking-wide text-feedback-danger-content",
3692
+ className: "mt-1 text-xs font-semibold tracking-wide text-feedback-danger-content",
3585
3693
  children: helperText
3586
3694
  }
3587
3695
  )
@@ -3759,6 +3867,7 @@ var OtpCodeInput = forwardRef2(
3759
3867
  autoComplete: index === 0 ? "one-time-code" : "off",
3760
3868
  maxLength: 1,
3761
3869
  value: currentValues[index],
3870
+ "data-has-value": Boolean(currentValues[index]),
3762
3871
  disabled,
3763
3872
  "aria-label": `${label}, d\xEDgito ${index + 1} de ${safeLength}`,
3764
3873
  "aria-invalid": hasError || void 0,
@@ -3779,8 +3888,8 @@ var OtpCodeInput = forwardRef2(
3779
3888
  if (!event.defaultPrevented) event.currentTarget.select();
3780
3889
  },
3781
3890
  className: classNames8(
3782
- "h-11 w-11 rounded-sm border bg-field-surface text-center text-lg font-bold text-field-content outline-none transition-colors focus-visible:border-field-border-active focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed disabled:bg-field-surface-disabled",
3783
- hasError ? "border-field-border-error" : "border-field-border-default"
3891
+ "field-value h-11 w-11 rounded-sm border bg-field-surface text-center text-lg font-bold text-field-content outline-none transition-colors focus-visible:border-field-border-active focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed disabled:bg-field-surface-disabled disabled:text-field-content-disabled",
3892
+ hasError ? "border-2 border-field-border-error focus-visible:border-field-border-error" : "border-field-border-default"
3784
3893
  )
3785
3894
  }
3786
3895
  ))
@@ -3812,4 +3921,4 @@ export {
3812
3921
  RadioCardGroup,
3813
3922
  OtpCodeInput_default
3814
3923
  };
3815
- //# sourceMappingURL=chunk-2CPV3WH5.js.map
3924
+ //# sourceMappingURL=chunk-VUXHE4S6.js.map