@iclips/ui 2.0.2 → 3.0.0

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.
Files changed (122) hide show
  1. package/MIGRATION-v3.md +244 -0
  2. package/README.md +1 -1
  3. package/dist/alert-theme.css +20 -79
  4. package/dist/components/ui/charts/donut-chart.cjs +1 -1
  5. package/dist/components/ui/charts/donut-chart.cjs.map +1 -1
  6. package/dist/components/ui/charts/donut-chart.js +39 -60
  7. package/dist/components/ui/charts/donut-chart.js.map +1 -1
  8. package/dist/components/ui/charts/kpi-card.cjs +1 -1
  9. package/dist/components/ui/charts/kpi-card.cjs.map +1 -1
  10. package/dist/components/ui/charts/kpi-card.js +19 -19
  11. package/dist/components/ui/charts/kpi-card.js.map +1 -1
  12. package/dist/components/ui/data/comment-system.cjs +1 -1
  13. package/dist/components/ui/data/comment-system.cjs.map +1 -1
  14. package/dist/components/ui/data/comment-system.js +67 -67
  15. package/dist/components/ui/data/comment-system.js.map +1 -1
  16. package/dist/components/ui/data/data-table.cjs +1 -1
  17. package/dist/components/ui/data/data-table.cjs.map +1 -1
  18. package/dist/components/ui/data/data-table.js +112 -101
  19. package/dist/components/ui/data/data-table.js.map +1 -1
  20. package/dist/components/ui/data/editorial-calendar.cjs +1 -1
  21. package/dist/components/ui/data/editorial-calendar.cjs.map +1 -1
  22. package/dist/components/ui/data/editorial-calendar.js +291 -291
  23. package/dist/components/ui/data/editorial-calendar.js.map +1 -1
  24. package/dist/components/ui/data/filter-builder.cjs +1 -1
  25. package/dist/components/ui/data/filter-builder.cjs.map +1 -1
  26. package/dist/components/ui/data/filter-builder.js +1 -1
  27. package/dist/components/ui/data/filter-builder.js.map +1 -1
  28. package/dist/components/ui/feedback/empty-state.cjs +1 -1
  29. package/dist/components/ui/feedback/empty-state.cjs.map +1 -1
  30. package/dist/components/ui/feedback/empty-state.js +14 -14
  31. package/dist/components/ui/feedback/empty-state.js.map +1 -1
  32. package/dist/components/ui/feedback/toast.cjs +1 -1
  33. package/dist/components/ui/feedback/toast.cjs.map +1 -1
  34. package/dist/components/ui/feedback/toast.js +53 -22
  35. package/dist/components/ui/feedback/toast.js.map +1 -1
  36. package/dist/components/ui/forms/calendar.cjs +1 -1
  37. package/dist/components/ui/forms/calendar.cjs.map +1 -1
  38. package/dist/components/ui/forms/calendar.js +16 -16
  39. package/dist/components/ui/forms/calendar.js.map +1 -1
  40. package/dist/components/ui/forms/combobox.cjs +1 -1
  41. package/dist/components/ui/forms/combobox.cjs.map +1 -1
  42. package/dist/components/ui/forms/combobox.js +78 -76
  43. package/dist/components/ui/forms/combobox.js.map +1 -1
  44. package/dist/components/ui/forms/file-attachment-list.cjs +1 -1
  45. package/dist/components/ui/forms/file-attachment-list.cjs.map +1 -1
  46. package/dist/components/ui/forms/file-attachment-list.js +4 -4
  47. package/dist/components/ui/forms/file-attachment-list.js.map +1 -1
  48. package/dist/components/ui/forms/file-upload-zone.cjs +2 -2
  49. package/dist/components/ui/forms/file-upload-zone.cjs.map +1 -1
  50. package/dist/components/ui/forms/file-upload-zone.js +55 -49
  51. package/dist/components/ui/forms/file-upload-zone.js.map +1 -1
  52. package/dist/components/ui/forms/form.cjs +1 -1
  53. package/dist/components/ui/forms/form.cjs.map +1 -1
  54. package/dist/components/ui/forms/form.js +11 -11
  55. package/dist/components/ui/forms/form.js.map +1 -1
  56. package/dist/components/ui/forms/input-validation.cjs +1 -1
  57. package/dist/components/ui/forms/input-validation.cjs.map +1 -1
  58. package/dist/components/ui/forms/input-validation.js +20 -20
  59. package/dist/components/ui/forms/input-validation.js.map +1 -1
  60. package/dist/components/ui/forms/multi-select.cjs +1 -1
  61. package/dist/components/ui/forms/multi-select.cjs.map +1 -1
  62. package/dist/components/ui/forms/multi-select.js +69 -67
  63. package/dist/components/ui/forms/multi-select.js.map +1 -1
  64. package/dist/components/ui/forms/radio-group.cjs +1 -1
  65. package/dist/components/ui/forms/radio-group.cjs.map +1 -1
  66. package/dist/components/ui/forms/radio-group.js +19 -19
  67. package/dist/components/ui/forms/radio-group.js.map +1 -1
  68. package/dist/components/ui/forms/social-button.cjs +1 -1
  69. package/dist/components/ui/forms/social-button.cjs.map +1 -1
  70. package/dist/components/ui/forms/social-button.js +6 -6
  71. package/dist/components/ui/forms/social-button.js.map +1 -1
  72. package/dist/components/ui/forms/toggle.cjs +1 -1
  73. package/dist/components/ui/forms/toggle.cjs.map +1 -1
  74. package/dist/components/ui/forms/toggle.js +7 -7
  75. package/dist/components/ui/forms/toggle.js.map +1 -1
  76. package/dist/components/ui/navigation/navigation-menu.cjs +1 -1
  77. package/dist/components/ui/navigation/navigation-menu.cjs.map +1 -1
  78. package/dist/components/ui/navigation/navigation-menu.js +14 -14
  79. package/dist/components/ui/navigation/navigation-menu.js.map +1 -1
  80. package/dist/components/ui/navigation/sidebar.cjs +1 -1
  81. package/dist/components/ui/navigation/sidebar.cjs.map +1 -1
  82. package/dist/components/ui/navigation/sidebar.js +44 -44
  83. package/dist/components/ui/navigation/sidebar.js.map +1 -1
  84. package/dist/components/ui/overlays/context-menu.cjs +1 -1
  85. package/dist/components/ui/overlays/context-menu.cjs.map +1 -1
  86. package/dist/components/ui/overlays/context-menu.js +1 -1
  87. package/dist/components/ui/overlays/context-menu.js.map +1 -1
  88. package/dist/components/ui/overlays/dropdown-menu.cjs +1 -1
  89. package/dist/components/ui/overlays/dropdown-menu.cjs.map +1 -1
  90. package/dist/components/ui/overlays/dropdown-menu.js +5 -5
  91. package/dist/components/ui/overlays/dropdown-menu.js.map +1 -1
  92. package/dist/components/ui/overlays/menubar.cjs +1 -1
  93. package/dist/components/ui/overlays/menubar.cjs.map +1 -1
  94. package/dist/components/ui/overlays/menubar.js +29 -29
  95. package/dist/components/ui/overlays/menubar.js.map +1 -1
  96. package/dist/components/ui/overlays/tooltip.cjs +1 -1
  97. package/dist/components/ui/overlays/tooltip.cjs.map +1 -1
  98. package/dist/components/ui/overlays/tooltip.js +12 -12
  99. package/dist/components/ui/overlays/tooltip.js.map +1 -1
  100. package/dist/components/ui/primitives/avatar.cjs +1 -1
  101. package/dist/components/ui/primitives/avatar.cjs.map +1 -1
  102. package/dist/components/ui/primitives/avatar.js +20 -27
  103. package/dist/components/ui/primitives/avatar.js.map +1 -1
  104. package/dist/components/ui/primitives/badge.cjs +1 -1
  105. package/dist/components/ui/primitives/badge.cjs.map +1 -1
  106. package/dist/components/ui/primitives/badge.js +13 -13
  107. package/dist/components/ui/primitives/badge.js.map +1 -1
  108. package/dist/components/ui/primitives/button.cjs +1 -1
  109. package/dist/components/ui/primitives/button.cjs.map +1 -1
  110. package/dist/components/ui/primitives/button.js +11 -8
  111. package/dist/components/ui/primitives/button.js.map +1 -1
  112. package/dist/index.cjs +1 -1
  113. package/dist/index.css +1 -1
  114. package/dist/index.d.cts +3 -3
  115. package/dist/index.d.ts +3 -3
  116. package/dist/index.js +34 -35
  117. package/dist/index.js.map +1 -1
  118. package/dist/preset.css +1 -2
  119. package/dist/toast-theme.css +100 -64
  120. package/dist/tokens.css +59 -159
  121. package/package.json +5 -3
  122. package/scripts/check-colors.mjs +208 -0
@@ -1,14 +1,14 @@
1
1
  import { jsxs as l, jsx as a } from "react/jsx-runtime";
2
- import { Upload as W, AlertCircle as M } from "lucide-react";
3
- import { useState as z, useRef as H, useCallback as c } from "react";
4
- import { cn as y } from "../utils.js";
5
- function I(n, t) {
6
- const u = t * 1024 * 1024;
7
- return n.size > u ? `Arquivo muito grande. Máximo: ${t}MB` : null;
2
+ import { Upload as W, AlertCircle as I } from "lucide-react";
3
+ import { useState as K, useRef as M, useCallback as c } from "react";
4
+ import { pressableKeyDown as z, cn as y } from "../utils.js";
5
+ function H(n, o) {
6
+ const u = o * 1024 * 1024;
7
+ return n.size > u ? `Arquivo muito grande. Máximo: ${o}MB` : null;
8
8
  }
9
- function O(n, t) {
10
- if (!t) return null;
11
- const u = t.split(",").map((e) => e.trim().toLowerCase()), s = n.name.toLowerCase(), i = n.type.toLowerCase();
9
+ function O(n, o) {
10
+ if (!o) return null;
11
+ const u = o.split(",").map((e) => e.trim().toLowerCase()), s = n.name.toLowerCase(), i = n.type.toLowerCase();
12
12
  return u.some((e) => {
13
13
  if (e.includes("*")) {
14
14
  const [q] = e.split("/");
@@ -19,59 +19,59 @@ function O(n, t) {
19
19
  }
20
20
  function J({
21
21
  onFilesSelected: n,
22
- accept: t,
22
+ accept: o,
23
23
  multiple: u = !0,
24
24
  maxFiles: s = 10,
25
25
  maxSizeMB: i = 50,
26
- disabled: o = !1,
26
+ disabled: t = !1,
27
27
  isUploading: e = !1,
28
28
  title: q = "Clique para fazer upload de arquivos",
29
29
  description: D,
30
- icon: T,
31
- className: j,
30
+ icon: $,
31
+ className: T,
32
32
  onError: d
33
33
  }) {
34
- const [f, A] = z(!1), h = H(null), N = c((r) => {
34
+ const [f, A] = K(!1), h = M(null), w = c((r) => {
35
35
  d == null || d(r);
36
36
  }, [d]), v = c((r) => {
37
37
  if (!r || r.length === 0) return;
38
- const x = Array.from(r);
39
- if (x.length > s) {
40
- N(`Máximo de ${s} arquivo(s) permitido(s)`);
38
+ const g = Array.from(r);
39
+ if (g.length > s) {
40
+ w(`Máximo de ${s} arquivo(s) permitido(s)`);
41
41
  return;
42
42
  }
43
- const m = [], g = [];
44
- for (const p of x) {
45
- const C = I(p, i);
43
+ const m = [], x = [];
44
+ for (const p of g) {
45
+ const C = H(p, i);
46
46
  if (C) {
47
- g.push(`${p.name}: ${C}`);
47
+ x.push(`${p.name}: ${C}`);
48
48
  continue;
49
49
  }
50
- const $ = O(p, t);
51
- if ($) {
52
- g.push(`${p.name}: ${$}`);
50
+ const b = O(p, o);
51
+ if (b) {
52
+ x.push(`${p.name}: ${b}`);
53
53
  continue;
54
54
  }
55
55
  m.push(p);
56
56
  }
57
- g.length > 0 && N(g.join(`
57
+ x.length > 0 && w(x.join(`
58
58
  `)), m.length > 0 && n(m), h.current && (h.current.value = "");
59
- }, [s, i, t, n, N]), k = c(() => {
59
+ }, [s, i, o, n, w]), j = c(() => {
60
60
  var r;
61
- o || e || (r = h.current) == null || r.click();
62
- }, [o, e]), P = c((r) => {
61
+ t || e || (r = h.current) == null || r.click();
62
+ }, [t, e]), k = c((r) => {
63
63
  v(r.target.files);
64
- }, [v]), V = c((r) => {
65
- r.preventDefault(), r.stopPropagation(), !o && !e && A(!0);
66
- }, [o, e]), b = c((r) => {
64
+ }, [v]), P = c((r) => {
65
+ r.preventDefault(), r.stopPropagation(), !t && !e && A(!0);
66
+ }, [t, e]), V = c((r) => {
67
67
  r.preventDefault(), r.stopPropagation(), A(!1);
68
68
  }, []), L = c((r) => {
69
- r.preventDefault(), r.stopPropagation(), A(!1), !(o || e) && v(r.dataTransfer.files);
70
- }, [o, e, v]), w = D || (() => {
69
+ r.preventDefault(), r.stopPropagation(), A(!1), !(t || e) && v(r.dataTransfer.files);
70
+ }, [t, e, v]), N = D || (() => {
71
71
  const r = [];
72
- if (t) {
73
- const x = t.split(",").map((m) => m.trim().replace(".", "").toUpperCase()).join(", ");
74
- r.push(x);
72
+ if (o) {
73
+ const g = o.split(",").map((m) => m.trim().replace(".", "").toUpperCase()).join(", ");
74
+ r.push(g);
75
75
  }
76
76
  return i && r.push(`máx ${i}MB cada`), r.join(" • ");
77
77
  })();
@@ -81,14 +81,20 @@ function J({
81
81
  className: y(
82
82
  "relative border-2 border-dashed rounded-lg p-8 text-center transition-all cursor-pointer",
83
83
  "hover:border-primary/50 hover:bg-muted/30",
84
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
84
85
  f && "border-primary bg-primary/5 scale-[1.02]",
85
- (o || e) && "opacity-50 cursor-not-allowed hover:border-dashed hover:bg-transparent",
86
+ t && "opacity-50 cursor-not-allowed hover:border-dashed hover:bg-transparent",
87
+ e && "cursor-progress hover:border-dashed hover:bg-transparent",
86
88
  e && "animate-pulse",
87
- j
89
+ T
88
90
  ),
89
- onClick: k,
90
- onDragOver: V,
91
- onDragLeave: b,
91
+ role: "button",
92
+ tabIndex: t || e ? -1 : 0,
93
+ "aria-disabled": t || e,
94
+ onClick: j,
95
+ onKeyDown: z,
96
+ onDragOver: P,
97
+ onDragLeave: V,
92
98
  onDrop: L,
93
99
  children: [
94
100
  /* @__PURE__ */ a(
@@ -97,14 +103,14 @@ function J({
97
103
  ref: h,
98
104
  type: "file",
99
105
  multiple: u,
100
- accept: t,
106
+ accept: o,
101
107
  className: "hidden",
102
- onChange: P,
103
- disabled: o || e
108
+ onChange: k,
109
+ disabled: t || e
104
110
  }
105
111
  ),
106
112
  /* @__PURE__ */ l("div", { className: "flex flex-col items-center gap-3", children: [
107
- T || /* @__PURE__ */ a("div", { className: y(
113
+ $ || /* @__PURE__ */ a("div", { className: y(
108
114
  "transition-transform",
109
115
  f && "scale-110"
110
116
  ), children: e ? /* @__PURE__ */ a("div", { className: "h-12 w-12 mx-auto", children: /* @__PURE__ */ l("svg", { className: "animate-spin h-12 w-12 text-primary", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
@@ -120,15 +126,15 @@ function J({
120
126
  f && "text-primary",
121
127
  e && "text-muted-foreground"
122
128
  ), children: e ? "Enviando arquivos..." : f ? "Solte os arquivos aqui" : q }),
123
- w && /* @__PURE__ */ a("p", { className: "text-xs text-muted-foreground", children: w }),
124
- !o && !e && u && s > 1 && /* @__PURE__ */ l("p", { className: "text-xs text-muted-foreground", children: [
129
+ N && /* @__PURE__ */ a("p", { className: "text-xs text-muted-foreground", children: N }),
130
+ !t && !e && u && s > 1 && /* @__PURE__ */ l("p", { className: "text-xs text-muted-foreground", children: [
125
131
  "Você pode selecionar até ",
126
132
  s,
127
133
  " arquivo(s)"
128
134
  ] })
129
135
  ] }),
130
- o && /* @__PURE__ */ l("div", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
131
- /* @__PURE__ */ a(M, { className: "h-3 w-3" }),
136
+ t && /* @__PURE__ */ l("div", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
137
+ /* @__PURE__ */ a(I, { className: "h-3 w-3" }),
132
138
  /* @__PURE__ */ a("span", { children: "Upload desabilitado" })
133
139
  ] })
134
140
  ] })
@@ -1 +1 @@
1
- {"version":3,"file":"file-upload-zone.js","sources":["../../../../src/components/ui/forms/file-upload-zone.tsx"],"sourcesContent":["import { AlertCircle, Upload } from 'lucide-react';\nimport { useCallback, useRef, useState } from 'react';\n\nimport { cn } from '../utils';\n\n/**\n * Props do componente FileUploadZone\n */\nexport interface FileUploadZoneProps {\n /** Callback quando arquivos são selecionados */\n onFilesSelected: (files: File[]) => void;\n\n /** Tipos de arquivo aceitos (ex: \".pdf,.doc,.docx\" ou \"image/*\") */\n accept?: string;\n\n /** Permitir múltiplos arquivos */\n multiple?: boolean;\n\n /** Número máximo de arquivos */\n maxFiles?: number;\n\n /** Tamanho máximo em MB */\n maxSizeMB?: number;\n\n /** Desabilitar upload */\n disabled?: boolean;\n\n /** Estado de loading/upload em andamento */\n isUploading?: boolean;\n\n /** Título da zona de upload */\n title?: string;\n\n /** Descrição da zona de upload */\n description?: string;\n\n /** Ícone customizado */\n icon?: React.ReactNode;\n\n /** Classe CSS adicional */\n className?: string;\n\n /** Callback quando houver erro de validação */\n onError?: (error: string) => void;\n}\n\n/**\n * Valida o tamanho do arquivo\n */\nfunction validarTamanhoArquivo(arquivo: File, tamanhoMaximoMB: number): string | null {\n const bytesMaximos = tamanhoMaximoMB * 1024 * 1024;\n if (arquivo.size > bytesMaximos) {\n return `Arquivo muito grande. Máximo: ${tamanhoMaximoMB}MB`;\n }\n return null;\n}\n\n/**\n * Valida o tipo do arquivo\n */\nfunction validarTipoArquivo(arquivo: File, tiposAceitos?: string): string | null {\n if (!tiposAceitos) return null;\n\n const tiposAceitosArray = tiposAceitos.split(',').map(t => t.trim().toLowerCase());\n const nomeArquivo = arquivo.name.toLowerCase();\n const tipoArquivo = arquivo.type.toLowerCase();\n\n const eValido = tiposAceitosArray.some(tipo => {\n // Wildcard (ex: image/*)\n if (tipo.includes('*')) {\n const [categoria] = tipo.split('/');\n return tipoArquivo.startsWith(categoria + '/');\n }\n\n // Extensão (ex: .pdf)\n if (tipo.startsWith('.')) {\n return nomeArquivo.endsWith(tipo);\n }\n\n // MIME type exato\n return tipoArquivo === tipo;\n });\n\n if (!eValido) {\n return 'Tipo de arquivo não suportado';\n }\n\n return null;\n}\n\n/**\n * Componente de zona de upload com drag-and-drop\n */\nexport function FileUploadZone({\n onFilesSelected,\n accept,\n multiple = true,\n maxFiles = 10,\n maxSizeMB = 50,\n disabled = false,\n isUploading = false,\n title = 'Clique para fazer upload de arquivos',\n description,\n icon,\n className,\n onError,\n}: FileUploadZoneProps) {\n const [estaArrastando, setEstaArrastando] = useState(false);\n const refInput = useRef<HTMLInputElement>(null);\n\n const gerenciarErro = useCallback((erro: string) => {\n onError?.(erro);\n }, [onError]);\n\n const validarEProcessarArquivos = useCallback((arquivos: FileList | null) => {\n if (!arquivos || arquivos.length === 0) return;\n\n const arrayArquivos = Array.from(arquivos);\n\n // Validar número de arquivos\n if (arrayArquivos.length > maxFiles) {\n gerenciarErro(`Máximo de ${maxFiles} arquivo(s) permitido(s)`);\n return;\n }\n\n // Validar cada arquivo\n const arquivosValidos: File[] = [];\n const erros: string[] = [];\n\n for (const arquivo of arrayArquivos) {\n // Validar tamanho\n const erroTamanho = validarTamanhoArquivo(arquivo, maxSizeMB);\n if (erroTamanho) {\n erros.push(`${arquivo.name}: ${erroTamanho}`);\n continue;\n }\n\n // Validar tipo\n const erroTipo = validarTipoArquivo(arquivo, accept);\n if (erroTipo) {\n erros.push(`${arquivo.name}: ${erroTipo}`);\n continue;\n }\n\n arquivosValidos.push(arquivo);\n }\n\n // Mostrar erros\n if (erros.length > 0) {\n gerenciarErro(erros.join('\\n'));\n }\n\n // Processar arquivos válidos\n if (arquivosValidos.length > 0) {\n onFilesSelected(arquivosValidos);\n }\n\n // Limpar input\n if (refInput.current) {\n refInput.current.value = '';\n }\n }, [maxFiles, maxSizeMB, accept, onFilesSelected, gerenciarErro]);\n\n const gerenciarClique = useCallback(() => {\n if (disabled || isUploading) return;\n refInput.current?.click();\n }, [disabled, isUploading]);\n\n const gerenciarMudancaArquivo = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n validarEProcessarArquivos(e.target.files);\n }, [validarEProcessarArquivos]);\n\n const gerenciarArrastarSobre = useCallback((e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n e.stopPropagation();\n if (!disabled && !isUploading) {\n setEstaArrastando(true);\n }\n }, [disabled, isUploading]);\n\n const gerenciarArrastarSair = useCallback((e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setEstaArrastando(false);\n }, []);\n\n const gerenciarSoltar = useCallback((e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setEstaArrastando(false);\n\n if (disabled || isUploading) return;\n\n validarEProcessarArquivos(e.dataTransfer.files);\n }, [disabled, isUploading, validarEProcessarArquivos]);\n\n const descricaoPadrao = description || (() => {\n const partes: string[] = [];\n\n if (accept) {\n const tipos = accept.split(',').map(t => t.trim().replace('.', '').toUpperCase()).join(', ');\n partes.push(tipos);\n }\n\n if (maxSizeMB) {\n partes.push(`máx ${maxSizeMB}MB cada`);\n }\n\n return partes.join(' • ');\n })();\n\n return (\n <div\n className={cn(\n 'relative border-2 border-dashed rounded-lg p-8 text-center transition-all cursor-pointer',\n 'hover:border-primary/50 hover:bg-muted/30',\n estaArrastando && 'border-primary bg-primary/5 scale-[1.02]',\n (disabled || isUploading) && 'opacity-50 cursor-not-allowed hover:border-dashed hover:bg-transparent',\n isUploading && 'animate-pulse',\n className,\n )}\n onClick={gerenciarClique}\n onDragOver={gerenciarArrastarSobre}\n onDragLeave={gerenciarArrastarSair}\n onDrop={gerenciarSoltar}\n >\n <input\n ref={refInput}\n type=\"file\"\n multiple={multiple}\n accept={accept}\n className=\"hidden\"\n onChange={gerenciarMudancaArquivo}\n disabled={disabled || isUploading}\n />\n\n <div className=\"flex flex-col items-center gap-3\">\n {icon || (\n <div className={cn(\n 'transition-transform',\n estaArrastando && 'scale-110',\n )}>\n {isUploading ? (\n <div className=\"h-12 w-12 mx-auto\">\n <svg className=\"animate-spin h-12 w-12 text-primary\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\"></circle>\n <path className=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"></path>\n </svg>\n </div>\n ) : (\n <Upload className={cn(\n 'h-12 w-12 mx-auto text-muted-foreground transition-colors',\n estaArrastando && 'text-primary',\n )} />\n )}\n </div>\n )}\n\n <div className=\"space-y-1\">\n <p className={cn(\n 'font-medium transition-colors',\n estaArrastando && 'text-primary',\n isUploading && 'text-muted-foreground',\n )}>\n {isUploading ? 'Enviando arquivos...' : estaArrastando ? 'Solte os arquivos aqui' : title}\n </p>\n\n {descricaoPadrao && (\n <p className=\"text-xs text-muted-foreground\">\n {descricaoPadrao}\n </p>\n )}\n\n {!disabled && !isUploading && multiple && maxFiles > 1 && (\n <p className=\"text-xs text-muted-foreground\">\n Você pode selecionar até {maxFiles} arquivo(s)\n </p>\n )}\n </div>\n\n {disabled && (\n <div className=\"flex items-center gap-1 text-xs text-muted-foreground\">\n <AlertCircle className=\"h-3 w-3\" />\n <span>Upload desabilitado</span>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"names":["validarTamanhoArquivo","arquivo","tamanhoMaximoMB","bytesMaximos","validarTipoArquivo","tiposAceitos","tiposAceitosArray","t","nomeArquivo","tipoArquivo","tipo","categoria","FileUploadZone","onFilesSelected","accept","multiple","maxFiles","maxSizeMB","disabled","isUploading","title","description","icon","className","onError","estaArrastando","setEstaArrastando","useState","refInput","useRef","gerenciarErro","useCallback","erro","validarEProcessarArquivos","arquivos","arrayArquivos","arquivosValidos","erros","erroTamanho","erroTipo","gerenciarClique","_a","gerenciarMudancaArquivo","e","gerenciarArrastarSobre","gerenciarArrastarSair","gerenciarSoltar","descricaoPadrao","partes","tipos","jsxs","cn","jsx","Upload","AlertCircle"],"mappings":";;;;AAiDA,SAASA,EAAsBC,GAAeC,GAAwC;AACpF,QAAMC,IAAeD,IAAkB,OAAO;AAC9C,SAAID,EAAQ,OAAOE,IACV,iCAAiCD,CAAe,OAElD;AACT;AAKA,SAASE,EAAmBH,GAAeI,GAAsC;AAC/E,MAAI,CAACA,EAAc,QAAO;AAE1B,QAAMC,IAAoBD,EAAa,MAAM,GAAG,EAAE,IAAI,CAAAE,MAAKA,EAAE,KAAA,EAAO,YAAA,CAAa,GAC3EC,IAAcP,EAAQ,KAAK,YAAA,GAC3BQ,IAAcR,EAAQ,KAAK,YAAA;AAkBjC,SAhBgBK,EAAkB,KAAK,CAAAI,MAAQ;AAE7C,QAAIA,EAAK,SAAS,GAAG,GAAG;AACtB,YAAM,CAACC,CAAS,IAAID,EAAK,MAAM,GAAG;AAClC,aAAOD,EAAY,WAAWE,IAAY,GAAG;AAAA,IAC/C;AAGA,WAAID,EAAK,WAAW,GAAG,IACdF,EAAY,SAASE,CAAI,IAI3BD,MAAgBC;AAAA,EACzB,CAAC,IAMM,OAHE;AAIX;AAKO,SAASE,EAAe;AAAA,EAC7B,iBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,UAAAC,IAAW;AAAA,EACX,aAAAC,IAAc;AAAA,EACd,OAAAC,IAAQ;AAAA,EACR,aAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AACF,GAAwB;AACtB,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpDC,IAAWC,EAAyB,IAAI,GAExCC,IAAgBC,EA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UAAA;AAAA,YAAA,gBAAAE,EAACE,GAAA,EAAY,WAAU,UAAA,CAAU;AAAA,YACjC,gBAAAF,EAAC,UAAK,UAAA,sBAAA,CAAmB;AAAA,UAAA,EAAA,CAC3B;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"file-upload-zone.js","sources":["../../../../src/components/ui/forms/file-upload-zone.tsx"],"sourcesContent":["import { AlertCircle, Upload } from 'lucide-react';\nimport { useCallback, useRef, useState } from 'react';\n\nimport { cn, pressableKeyDown } from '../utils';\n\n/**\n * Props do componente FileUploadZone\n */\nexport interface FileUploadZoneProps {\n /** Callback quando arquivos são selecionados */\n onFilesSelected: (files: File[]) => void;\n\n /** Tipos de arquivo aceitos (ex: \".pdf,.doc,.docx\" ou \"image/*\") */\n accept?: string;\n\n /** Permitir múltiplos arquivos */\n multiple?: boolean;\n\n /** Número máximo de arquivos */\n maxFiles?: number;\n\n /** Tamanho máximo em MB */\n maxSizeMB?: number;\n\n /** Desabilitar upload */\n disabled?: boolean;\n\n /** Estado de loading/upload em andamento */\n isUploading?: boolean;\n\n /** Título da zona de upload */\n title?: string;\n\n /** Descrição da zona de upload */\n description?: string;\n\n /** Ícone customizado */\n icon?: React.ReactNode;\n\n /** Classe CSS adicional */\n className?: string;\n\n /** Callback quando houver erro de validação */\n onError?: (error: string) => void;\n}\n\n/**\n * Valida o tamanho do arquivo\n */\nfunction validarTamanhoArquivo(arquivo: File, tamanhoMaximoMB: number): string | null {\n const bytesMaximos = tamanhoMaximoMB * 1024 * 1024;\n if (arquivo.size > bytesMaximos) {\n return `Arquivo muito grande. Máximo: ${tamanhoMaximoMB}MB`;\n }\n return null;\n}\n\n/**\n * Valida o tipo do arquivo\n */\nfunction validarTipoArquivo(arquivo: File, tiposAceitos?: string): string | null {\n if (!tiposAceitos) return null;\n\n const tiposAceitosArray = tiposAceitos.split(',').map(t => t.trim().toLowerCase());\n const nomeArquivo = arquivo.name.toLowerCase();\n const tipoArquivo = arquivo.type.toLowerCase();\n\n const eValido = tiposAceitosArray.some(tipo => {\n // Wildcard (ex: image/*)\n if (tipo.includes('*')) {\n const [categoria] = tipo.split('/');\n return tipoArquivo.startsWith(categoria + '/');\n }\n\n // Extensão (ex: .pdf)\n if (tipo.startsWith('.')) {\n return nomeArquivo.endsWith(tipo);\n }\n\n // MIME type exato\n return tipoArquivo === tipo;\n });\n\n if (!eValido) {\n return 'Tipo de arquivo não suportado';\n }\n\n return null;\n}\n\n/**\n * Componente de zona de upload com drag-and-drop\n */\nexport function FileUploadZone({\n onFilesSelected,\n accept,\n multiple = true,\n maxFiles = 10,\n maxSizeMB = 50,\n disabled = false,\n isUploading = false,\n title = 'Clique para fazer upload de arquivos',\n description,\n icon,\n className,\n onError,\n}: FileUploadZoneProps) {\n const [estaArrastando, setEstaArrastando] = useState(false);\n const refInput = useRef<HTMLInputElement>(null);\n\n const gerenciarErro = useCallback((erro: string) => {\n onError?.(erro);\n }, [onError]);\n\n const validarEProcessarArquivos = useCallback((arquivos: FileList | null) => {\n if (!arquivos || arquivos.length === 0) return;\n\n const arrayArquivos = Array.from(arquivos);\n\n // Validar número de arquivos\n if (arrayArquivos.length > maxFiles) {\n gerenciarErro(`Máximo de ${maxFiles} arquivo(s) permitido(s)`);\n return;\n }\n\n // Validar cada arquivo\n const arquivosValidos: File[] = [];\n const erros: string[] = [];\n\n for (const arquivo of arrayArquivos) {\n // Validar tamanho\n const erroTamanho = validarTamanhoArquivo(arquivo, maxSizeMB);\n if (erroTamanho) {\n erros.push(`${arquivo.name}: ${erroTamanho}`);\n continue;\n }\n\n // Validar tipo\n const erroTipo = validarTipoArquivo(arquivo, accept);\n if (erroTipo) {\n erros.push(`${arquivo.name}: ${erroTipo}`);\n continue;\n }\n\n arquivosValidos.push(arquivo);\n }\n\n // Mostrar erros\n if (erros.length > 0) {\n gerenciarErro(erros.join('\\n'));\n }\n\n // Processar arquivos válidos\n if (arquivosValidos.length > 0) {\n onFilesSelected(arquivosValidos);\n }\n\n // Limpar input\n if (refInput.current) {\n refInput.current.value = '';\n }\n }, [maxFiles, maxSizeMB, accept, onFilesSelected, gerenciarErro]);\n\n const gerenciarClique = useCallback(() => {\n if (disabled || isUploading) return;\n refInput.current?.click();\n }, [disabled, isUploading]);\n\n const gerenciarMudancaArquivo = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n validarEProcessarArquivos(e.target.files);\n }, [validarEProcessarArquivos]);\n\n const gerenciarArrastarSobre = useCallback((e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n e.stopPropagation();\n if (!disabled && !isUploading) {\n setEstaArrastando(true);\n }\n }, [disabled, isUploading]);\n\n const gerenciarArrastarSair = useCallback((e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setEstaArrastando(false);\n }, []);\n\n const gerenciarSoltar = useCallback((e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setEstaArrastando(false);\n\n if (disabled || isUploading) return;\n\n validarEProcessarArquivos(e.dataTransfer.files);\n }, [disabled, isUploading, validarEProcessarArquivos]);\n\n const descricaoPadrao = description || (() => {\n const partes: string[] = [];\n\n if (accept) {\n const tipos = accept.split(',').map(t => t.trim().replace('.', '').toUpperCase()).join(', ');\n partes.push(tipos);\n }\n\n if (maxSizeMB) {\n partes.push(`máx ${maxSizeMB}MB cada`);\n }\n\n return partes.join(' • ');\n })();\n\n return (\n <div\n className={cn(\n 'relative border-2 border-dashed rounded-lg p-8 text-center transition-all cursor-pointer',\n 'hover:border-primary/50 hover:bg-muted/30',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',\n estaArrastando && 'border-primary bg-primary/5 scale-[1.02]',\n disabled && 'opacity-50 cursor-not-allowed hover:border-dashed hover:bg-transparent',\n isUploading && 'cursor-progress hover:border-dashed hover:bg-transparent',\n isUploading && 'animate-pulse',\n className,\n )}\n role=\"button\"\n tabIndex={disabled || isUploading ? -1 : 0}\n aria-disabled={disabled || isUploading}\n onClick={gerenciarClique}\n onKeyDown={pressableKeyDown}\n onDragOver={gerenciarArrastarSobre}\n onDragLeave={gerenciarArrastarSair}\n onDrop={gerenciarSoltar}\n >\n <input\n ref={refInput}\n type=\"file\"\n multiple={multiple}\n accept={accept}\n className=\"hidden\"\n onChange={gerenciarMudancaArquivo}\n disabled={disabled || isUploading}\n />\n\n <div className=\"flex flex-col items-center gap-3\">\n {icon || (\n <div className={cn(\n 'transition-transform',\n estaArrastando && 'scale-110',\n )}>\n {isUploading ? (\n <div className=\"h-12 w-12 mx-auto\">\n <svg className=\"animate-spin h-12 w-12 text-primary\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\"></circle>\n <path className=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"></path>\n </svg>\n </div>\n ) : (\n <Upload className={cn(\n 'h-12 w-12 mx-auto text-muted-foreground transition-colors',\n estaArrastando && 'text-primary',\n )} />\n )}\n </div>\n )}\n\n <div className=\"space-y-1\">\n <p className={cn(\n 'font-medium transition-colors',\n estaArrastando && 'text-primary',\n isUploading && 'text-muted-foreground',\n )}>\n {isUploading ? 'Enviando arquivos...' : estaArrastando ? 'Solte os arquivos aqui' : title}\n </p>\n\n {descricaoPadrao && (\n <p className=\"text-xs text-muted-foreground\">\n {descricaoPadrao}\n </p>\n )}\n\n {!disabled && !isUploading && multiple && maxFiles > 1 && (\n <p className=\"text-xs text-muted-foreground\">\n Você pode selecionar até {maxFiles} arquivo(s)\n </p>\n )}\n </div>\n\n {disabled && (\n <div className=\"flex items-center gap-1 text-xs text-muted-foreground\">\n <AlertCircle className=\"h-3 w-3\" />\n <span>Upload desabilitado</span>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"names":["validarTamanhoArquivo","arquivo","tamanhoMaximoMB","bytesMaximos","validarTipoArquivo","tiposAceitos","tiposAceitosArray","t","nomeArquivo","tipoArquivo","tipo","categoria","FileUploadZone","onFilesSelected","accept","multiple","maxFiles","maxSizeMB","disabled","isUploading","title","description","icon","className","onError","estaArrastando","setEstaArrastando","useState","refInput","useRef","gerenciarErro","useCallback","erro","validarEProcessarArquivos","arquivos","arrayArquivos","arquivosValidos","erros","erroTamanho","erroTipo","gerenciarClique","_a","gerenciarMudancaArquivo","e","gerenciarArrastarSobre","gerenciarArrastarSair","gerenciarSoltar","descricaoPadrao","partes","tipos","jsxs","cn","pressableKeyDown","jsx","Upload","AlertCircle"],"mappings":";;;;AAiDA,SAASA,EAAsBC,GAAeC,GAAwC;AACpF,QAAMC,IAAeD,IAAkB,OAAO;AAC9C,SAAID,EAAQ,OAAOE,IACV,iCAAiCD,CAAe,OAElD;AACT;AAKA,SAASE,EAAmBH,GAAeI,GAAsC;AAC/E,MAAI,CAACA,EAAc,QAAO;AAE1B,QAAMC,IAAoBD,EAAa,MAAM,GAAG,EAAE,IAAI,CAAAE,MAAKA,EAAE,KAAA,EAAO,YAAA,CAAa,GAC3EC,IAAcP,EAAQ,KAAK,YAAA,GAC3BQ,IAAcR,EAAQ,KAAK,YAAA;AAkBjC,SAhBgBK,EAAkB,KAAK,CAAAI,MAAQ;AAE7C,QAAIA,EAAK,SAAS,GAAG,GAAG;AACtB,YAAM,CAACC,CAAS,IAAID,EAAK,MAAM,GAAG;AAClC,aAAOD,EAAY,WAAWE,IAAY,GAAG;AAAA,IAC/C;AAGA,WAAID,EAAK,WAAW,GAAG,IACdF,EAAY,SAASE,CAAI,IAI3BD,MAAgBC;AAAA,EACzB,CAAC,IAMM,OAHE;AAIX;AAKO,SAASE,EAAe;AAAA,EAC7B,iBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC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;AAAA,cACZ;AAAA,cACA1B,KAAkB;AAAA,cAClBN,KAAe;AAAA,YAAA,GAEd,UAAAA,IAAc,yBAAyBM,IAAiB,2BAA2BL,GACtF;AAAA,YAEC2B,KACC,gBAAAM,EAAC,KAAA,EAAE,WAAU,iCACV,UAAAN,GACH;AAAA,YAGD,CAAC7B,KAAY,CAACC,KAAeJ,KAAYC,IAAW,KACnD,gBAAAkC,EAAC,KAAA,EAAE,WAAU,iCAAgC,UAAA;AAAA,cAAA;AAAA,cACjBlC;AAAA,cAAS;AAAA,YAAA,EAAA,CACrC;AAAA,UAAA,GAEJ;AAAA,UAECE,KACC,gBAAAgC,EAAC,OAAA,EAAI,WAAU,yDACb,UAAA;AAAA,YAAA,gBAAAG,EAACE,GAAA,EAAY,WAAU,UAAA,CAAU;AAAA,YACjC,gBAAAF,EAAC,UAAK,UAAA,sBAAA,CAAmB;AAAA,UAAA,EAAA,CAC3B;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1,2 +1,2 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),b=require("react"),I=require("@radix-ui/react-slot"),c=require("react-hook-form"),d=require("../utils.cjs"),j=require("../primitives/label.cjs");function C(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const s=C(b),y=c.FormProvider,l=s.createContext({}),v=({...e})=>m.jsx(l.Provider,{value:{name:e.name},children:m.jsx(c.Controller,{...e})}),i=()=>{const e=s.useContext(l),o=s.useContext(u),{getFieldState:t}=c.useFormContext(),r=c.useFormState({name:e.name}),a=t(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=o;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...a}},u=s.createContext({}),f=s.forwardRef(({className:e,...o},t)=>{const r=s.useId();return m.jsx(u.Provider,{value:{id:r},children:m.jsx("div",{ref:t,"data-slot":"form-item",className:d.cn("grid gap-2",e),...o})})});f.displayName="FormItem";const F=s.forwardRef(({className:e,...o},t)=>{const{error:r,formItemId:a}=i();return m.jsx(j.Label,{ref:t,"data-slot":"form-label","data-error":!!r,className:d.cn("data-[error=true]:text-destructive",e),htmlFor:a,...o})});F.displayName="FormLabel";const x=s.forwardRef(({...e},o)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:n}=i();return m.jsx(I.Slot,{ref:o,"data-slot":"form-control",id:r,"aria-describedby":t?`${a} ${n}`:`${a}`,"aria-invalid":!!t,...e})});x.displayName="FormControl";const g=s.forwardRef(({className:e,...o},t)=>{const{formDescriptionId:r}=i();return m.jsx("p",{ref:t,"data-slot":"form-description",id:r,className:d.cn("text-muted-foreground text-sm",e),...o})});g.displayName="FormDescription";const p=s.forwardRef(({className:e,...o},t)=>{const{error:r,formMessageId:a}=i(),n=r?String((r==null?void 0:r.message)??""):o.children;return n?m.jsx("p",{ref:t,"data-slot":"form-message",id:a,className:d.cn("text-destructive text-sm",e),...o,children:n}):null});p.displayName="FormMessage";exports.Form=y;exports.FormControl=x;exports.FormDescription=g;exports.FormField=v;exports.FormItem=f;exports.FormLabel=F;exports.FormMessage=p;exports.useFormField=i;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),b=require("react"),I=require("@radix-ui/react-slot"),c=require("react-hook-form"),d=require("../utils.cjs"),j=require("../primitives/label.cjs");function C(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const s=C(b),y=c.FormProvider,l=s.createContext({}),v=({...e})=>m.jsx(l.Provider,{value:{name:e.name},children:m.jsx(c.Controller,{...e})}),i=()=>{const e=s.useContext(l),o=s.useContext(u),{getFieldState:t}=c.useFormContext(),r=c.useFormState({name:e.name}),a=t(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=o;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...a}},u=s.createContext({}),f=s.forwardRef(({className:e,...o},t)=>{const r=s.useId();return m.jsx(u.Provider,{value:{id:r},children:m.jsx("div",{ref:t,"data-slot":"form-item",className:d.cn("grid gap-2",e),...o})})});f.displayName="FormItem";const F=s.forwardRef(({className:e,...o},t)=>{const{error:r,formItemId:a}=i();return m.jsx(j.Label,{ref:t,"data-slot":"form-label","data-error":!!r,className:d.cn("data-[error=true]:text-destructive-emphasis",e),htmlFor:a,...o})});F.displayName="FormLabel";const x=s.forwardRef(({...e},o)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:n}=i();return m.jsx(I.Slot,{ref:o,"data-slot":"form-control",id:r,"aria-describedby":t?`${a} ${n}`:`${a}`,"aria-invalid":!!t,...e})});x.displayName="FormControl";const g=s.forwardRef(({className:e,...o},t)=>{const{formDescriptionId:r}=i();return m.jsx("p",{ref:t,"data-slot":"form-description",id:r,className:d.cn("text-muted-foreground text-sm",e),...o})});g.displayName="FormDescription";const p=s.forwardRef(({className:e,...o},t)=>{const{error:r,formMessageId:a}=i(),n=r?String((r==null?void 0:r.message)??""):o.children;return n?m.jsx("p",{ref:t,"data-slot":"form-message",id:a,className:d.cn("text-destructive-emphasis text-sm",e),...o,children:n}):null});p.displayName="FormMessage";exports.Form=y;exports.FormControl=x;exports.FormDescription=g;exports.FormField=v;exports.FormItem=f;exports.FormLabel=F;exports.FormMessage=p;exports.useFormField=i;
2
2
  //# sourceMappingURL=form.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.cjs","sources":["../../../../src/components/ui/forms/form.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\";\n\nimport { cn } from \"../utils\";\nimport { Label } from \"../primitives/label\";\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n ref={ref}\n data-slot=\"form-item\"\n className={cn(\"grid gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof Label>,\n React.ComponentPropsWithoutRef<typeof Label>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n ref={ref}\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? \"\") : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body"],"mappings":"6iBAiBMA,EAAOC,EAAAA,aASPC,EAAmBC,EAAM,cAC7B,CAAA,CACF,EAEMC,EAAY,CAGhB,CACA,GAAGC,CACL,IAEIC,EAAAA,IAACJ,EAAiB,SAAjB,CAA0B,MAAO,CAAE,KAAMG,EAAM,IAAA,EAC9C,SAAAC,EAAAA,IAACC,EAAAA,WAAA,CAAY,GAAGF,EAAO,EACzB,EAIEG,EAAe,IAAM,CACzB,MAAMC,EAAeN,EAAM,WAAWD,CAAgB,EAChDQ,EAAcP,EAAM,WAAWQ,CAAe,EAC9C,CAAE,cAAAC,CAAA,EAAkBC,iBAAA,EACpBC,EAAYC,EAAAA,aAAa,CAAE,KAAMN,EAAa,KAAM,EACpDO,EAAaJ,EAAcH,EAAa,KAAMK,CAAS,EAE7D,GAAI,CAACL,EACH,MAAM,IAAI,MAAM,gDAAgD,EAGlE,KAAM,CAAE,GAAAQ,GAAOP,EAEf,MAAO,CACL,GAAAO,EACA,KAAMR,EAAa,KACnB,WAAY,GAAGQ,CAAE,aACjB,kBAAmB,GAAGA,CAAE,yBACxB,cAAe,GAAGA,CAAE,qBACpB,GAAGD,CAAA,CAEP,EAMML,EAAkBR,EAAM,cAC5B,CAAA,CACF,EAEMe,EAAWf,EAAM,WAGrB,CAAC,CAAE,UAAAgB,EAAW,GAAGd,CAAA,EAASe,IAAQ,CAClC,MAAMH,EAAKd,EAAM,MAAA,EAEjB,aACGQ,EAAgB,SAAhB,CAAyB,MAAO,CAAE,GAAAM,GACjC,SAAAX,EAAAA,IAAC,MAAA,CACC,IAAAc,EACA,YAAU,YACV,UAAWC,EAAAA,GAAG,aAAcF,CAAS,EACpC,GAAGd,CAAA,CAAA,EAER,CAEJ,CAAC,EACDa,EAAS,YAAc,WAE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O,UAAW,EAAE,EAAIlB,EAAM,SAE1D,OAAK2B,EAKH1B,EAAAA,IAAC,IAAA,CACC,IAAAc,EACA,YAAU,eACV,GAAIQ,EACJ,UAAWP,EAAAA,GAAG,2BAA4BF,CAAS,EAClD,GAAGd,EAEH,SAAA2B,CAAA,CAAA,EAXI,IAcX,CAAC,EACDD,EAAY,YAAc"}
1
+ {"version":3,"file":"form.cjs","sources":["../../../../src/components/ui/forms/form.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\";\n\nimport { cn } from \"../utils\";\nimport { Label } from \"../primitives/label\";\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n ref={ref}\n data-slot=\"form-item\"\n className={cn(\"grid gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof Label>,\n React.ComponentPropsWithoutRef<typeof Label>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive-emphasis\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n ref={ref}\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? \"\") : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive-emphasis text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body"],"mappings":"6iBAiBMA,EAAOC,EAAAA,aASPC,EAAmBC,EAAM,cAC7B,CAAA,CACF,EAEMC,EAAY,CAGhB,CACA,GAAGC,CACL,IAEIC,EAAAA,IAACJ,EAAiB,SAAjB,CAA0B,MAAO,CAAE,KAAMG,EAAM,IAAA,EAC9C,SAAAC,EAAAA,IAACC,EAAAA,WAAA,CAAY,GAAGF,EAAO,EACzB,EAIEG,EAAe,IAAM,CACzB,MAAMC,EAAeN,EAAM,WAAWD,CAAgB,EAChDQ,EAAcP,EAAM,WAAWQ,CAAe,EAC9C,CAAE,cAAAC,CAAA,EAAkBC,iBAAA,EACpBC,EAAYC,EAAAA,aAAa,CAAE,KAAMN,EAAa,KAAM,EACpDO,EAAaJ,EAAcH,EAAa,KAAMK,CAAS,EAE7D,GAAI,CAACL,EACH,MAAM,IAAI,MAAM,gDAAgD,EAGlE,KAAM,CAAE,GAAAQ,GAAOP,EAEf,MAAO,CACL,GAAAO,EACA,KAAMR,EAAa,KACnB,WAAY,GAAGQ,CAAE,aACjB,kBAAmB,GAAGA,CAAE,yBACxB,cAAe,GAAGA,CAAE,qBACpB,GAAGD,CAAA,CAEP,EAMML,EAAkBR,EAAM,cAC5B,CAAA,CACF,EAEMe,EAAWf,EAAM,WAGrB,CAAC,CAAE,UAAAgB,EAAW,GAAGd,CAA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AAS,EACvD,GAAGd,CAAA,CAAA,CAGV,CAAC,EACDyB,EAAgB,YAAc,kBAE9B,MAAMC,EAAc5B,EAAM,WAGxB,CAAC,CAAE,UAAAgB,EAAW,GAAGd,CAAA,EAASe,IAAQ,CAClC,KAAM,CAAE,MAAAG,EAAO,cAAAK,CAAA,EAAkBpB,EAAA,EAC3BwB,EAAOT,EAAQ,QAAOA,GAAA,YAAAA,EAAO,UAAW,EAAE,EAAIlB,EAAM,SAE1D,OAAK2B,EAKH1B,EAAAA,IAAC,IAAA,CACC,IAAAc,EACA,YAAU,eACV,GAAIQ,EACJ,UAAWP,EAAAA,GAAG,oCAAqCF,CAAS,EAC3D,GAAGd,EAEH,SAAA2B,CAAA,CAAA,EAXI,IAcX,CAAC,EACDD,EAAY,YAAc"}
@@ -45,14 +45,14 @@ const C = m.forwardRef(({ className: e, ...t }, o) => {
45
45
  ref: o,
46
46
  "data-slot": "form-label",
47
47
  "data-error": !!r,
48
- className: i("data-[error=true]:text-destructive", e),
48
+ className: i("data-[error=true]:text-destructive-emphasis", e),
49
49
  htmlFor: a,
50
50
  ...t
51
51
  }
52
52
  );
53
53
  });
54
54
  C.displayName = "FormLabel";
55
- const v = m.forwardRef(({ ...e }, t) => {
55
+ const h = m.forwardRef(({ ...e }, t) => {
56
56
  const { error: o, formItemId: r, formDescriptionId: a, formMessageId: s } = d();
57
57
  return /* @__PURE__ */ n(
58
58
  f,
@@ -66,8 +66,8 @@ const v = m.forwardRef(({ ...e }, t) => {
66
66
  }
67
67
  );
68
68
  });
69
- v.displayName = "FormControl";
70
- const N = m.forwardRef(({ className: e, ...t }, o) => {
69
+ h.displayName = "FormControl";
70
+ const v = m.forwardRef(({ className: e, ...t }, o) => {
71
71
  const { formDescriptionId: r } = d();
72
72
  return /* @__PURE__ */ n(
73
73
  "p",
@@ -80,8 +80,8 @@ const N = m.forwardRef(({ className: e, ...t }, o) => {
80
80
  }
81
81
  );
82
82
  });
83
- N.displayName = "FormDescription";
84
- const b = m.forwardRef(({ className: e, ...t }, o) => {
83
+ v.displayName = "FormDescription";
84
+ const N = m.forwardRef(({ className: e, ...t }, o) => {
85
85
  const { error: r, formMessageId: a } = d(), s = r ? String((r == null ? void 0 : r.message) ?? "") : t.children;
86
86
  return s ? /* @__PURE__ */ n(
87
87
  "p",
@@ -89,21 +89,21 @@ const b = m.forwardRef(({ className: e, ...t }, o) => {
89
89
  ref: o,
90
90
  "data-slot": "form-message",
91
91
  id: a,
92
- className: i("text-destructive text-sm", e),
92
+ className: i("text-destructive-emphasis text-sm", e),
93
93
  ...t,
94
94
  children: s
95
95
  }
96
96
  ) : null;
97
97
  });
98
- b.displayName = "FormMessage";
98
+ N.displayName = "FormMessage";
99
99
  export {
100
100
  $ as Form,
101
- v as FormControl,
102
- N as FormDescription,
101
+ h as FormControl,
102
+ v as FormDescription,
103
103
  D as FormField,
104
104
  g as FormItem,
105
105
  C as FormLabel,
106
- b as FormMessage,
106
+ N as FormMessage,
107
107
  d as useFormField
108
108
  };
109
109
  //# sourceMappingURL=form.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","sources":["../../../../src/components/ui/forms/form.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\";\n\nimport { cn } from \"../utils\";\nimport { Label } from \"../primitives/label\";\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n ref={ref}\n data-slot=\"form-item\"\n className={cn(\"grid gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof Label>,\n React.ComponentPropsWithoutRef<typeof Label>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n ref={ref}\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? \"\") : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body"],"mappings":";;;;;;;AAiBA,MAAMA,IAAOC,GASPC,IAAmBC,EAAM;AAAA,EAC7B,CAAA;AACF,GAEMC,IAAY,CAGhB;AAAA,EACA,GAAGC;AACL,MAEI,gBAAAC,EAACJ,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMG,EAAM,KAAA,GAC9C,UAAA,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAO,GACzB,GAIEG,IAAe,MAAM;AACzB,QAAMC,IAAeN,EAAM,WAAWD,CAAgB,GAChDQ,IAAcP,EAAM,WAAWQ,CAAe,GAC9C,EAAE,eAAAC,EAAA,IAAkBC,EAAA,GACpBC,I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ui/forms/form.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\";\n\nimport { cn } from \"../utils\";\nimport { Label } from \"../primitives/label\";\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n ref={ref}\n data-slot=\"form-item\"\n className={cn(\"grid gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof Label>,\n React.ComponentPropsWithoutRef<typeof Label>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive-emphasis\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n ref={ref}\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? \"\") : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive-emphasis text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body"],"mappings":";;;;;;;AAiBA,MAAMA,IAAOC,GASPC,IAAmBC,EAAM;AAAA,EAC7B,CAAA;AACF,GAEMC,IAAY,CAGhB;AAAA,EACA,GAAGC;AACL,MAEI,gBAAAC,EAACJ,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMG,EAAM,KAAA,GAC9C,UAAA,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAO,GACzB,GAIEG,IAAe,MAAM;AACzB,QAAMC,IAAeN,EAAM,WAAWD,CAAgB,GAChDQ,IAAcP,EAAM,WAAWQ,CAAe,GAC9C,EAAE,eAAAC,EAAA,IAAkBC,EAAA,GACpBC,IAAYC,EAAa,EAAE,MAAMN,EAAa,MAAM,GACpDO,IAAaJ,EAAcH,EAAa,MAAMK,CAAS;AAE7D,MAAI,CAACL;AACH,UAAM,IAAI,MAAM,gDAAgD;AAGlE,QAAM,EAAE,IAAAQ,MAAOP;AAEf,SAAO;AAAA,IACL,IAAAO;AAAA,IACA,MAAMR,EAAa;AAAA,IACnB,YAAY,GAAGQ,CAAE;AAAA,IACjB,mBAAmB,GAAGA,CAAE;AAAA,IACxB,eAAe,GAAGA,CAAE;AAAA,IACpB,GAAGD;AAAA,EAAA;AAEP,GAMML,IAAkBR,EAAM;AAAA,EAC5B,CAAA;AACF,GAEMe,IAAWf,EAAM,WAGrB,CAAC,EAAE,WAAAgB,GAAW,GAAGd,EAAA,GAASe,MAAQ;AAClC,QAAMH,IAAKd,EAAM,MAAA;AAEjB,2BACGQ,EAAgB,UAAhB,EAAyB,OAAO,EAAE,IAAAM,KACjC,UAAA,gBAAAX;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAc;AAAA,MACA,aAAU;AAAA,MACV,WAAWC,EAAG,cAAcF,CAAS;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V,CAAC;AACDyB,EAAgB,cAAc;AAE9B,MAAMC,IAAc5B,EAAM,WAGxB,CAAC,EAAE,WAAAgB,GAAW,GAAGd,EAAA,GAASe,MAAQ;AAClC,QAAM,EAAE,OAAAG,GAAO,eAAAK,EAAA,IAAkBpB,EAAA,GAC3BwB,IAAOT,IAAQ,QAAOA,KAAA,gBAAAA,EAAO,YAAW,EAAE,IAAIlB,EAAM;AAE1D,SAAK2B,IAKH,gBAAA1B;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAc;AAAA,MACA,aAAU;AAAA,MACV,IAAIQ;AAAA,MACJ,WAAWP,EAAG,qCAAqCF,CAAS;AAAA,MAC3D,GAAGd;AAAA,MAEH,UAAA2B;AAAA,IAAA;AAAA,EAAA,IAXI;AAcX,CAAC;AACDD,EAAY,cAAc;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),b=require("react"),u=require("lucide-react"),j=require("./input.cjs"),g=require("../utils.cjs");function x(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return i.default=e,Object.freeze(i)}const o=x(b),d=o.forwardRef(({validationState:e,validate:i,onChange:t,className:n,...f},p)=>{const[v,s]=o.useState("idle"),a=e??v;function m(l){if(e===void 0&&i){const c=i(l.target.value);s(c===null?"idle":c?"valid":"invalid")}t==null||t(l)}return r.jsxs("div",{className:"relative flex items-center",children:[r.jsx(j.Input,{ref:p,className:g.cn(a!=="idle"&&"pr-9",n),"aria-invalid":a==="invalid"||void 0,onChange:m,...f}),a==="valid"&&r.jsx(u.CheckCircle2,{className:"absolute right-3 size-4 text-green-600 pointer-events-none","aria-hidden":"true"}),a==="invalid"&&r.jsx(u.XCircle,{className:"absolute right-3 size-4 text-destructive pointer-events-none","aria-hidden":"true"})]})});d.displayName="InputValidation";exports.InputValidation=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("react"),u=require("lucide-react"),j=require("./input.cjs"),g=require("../utils.cjs");function x(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return i.default=e,Object.freeze(i)}const o=x(b),d=o.forwardRef(({validationState:e,validate:i,onChange:t,className:a,...p},f)=>{const[v,r]=o.useState("idle"),n=e??v;function m(l){if(e===void 0&&i){const c=i(l.target.value);r(c===null?"idle":c?"valid":"invalid")}t==null||t(l)}return s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(j.Input,{ref:f,className:g.cn(n!=="idle"&&"pr-9",a),"aria-invalid":n==="invalid"||void 0,onChange:m,...p}),n==="valid"&&s.jsx(u.CheckCircle2,{className:"absolute right-3 size-4 text-success-emphasis pointer-events-none","aria-hidden":"true"}),n==="invalid"&&s.jsx(u.XCircle,{className:"absolute right-3 size-4 text-destructive-emphasis pointer-events-none","aria-hidden":"true"})]})});d.displayName="InputValidation";exports.InputValidation=d;
2
2
  //# sourceMappingURL=input-validation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-validation.cjs","sources":["../../../../src/components/ui/forms/input-validation.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckCircle2, XCircle } from \"lucide-react\";\n\nimport { Input } from \"./input\";\nimport { cn } from \"../utils\";\n\nexport type ValidationState = \"idle\" | \"valid\" | \"invalid\";\n\nexport interface InputValidationProps extends React.ComponentProps<\"input\"> {\n /**\n * Estado de validação controlado externamente.\n * Use \"idle\" antes da primeira interação, \"valid\" para sucesso e \"invalid\" para erro.\n */\n validationState?: ValidationState;\n /**\n * Função de validação automática disparada no onChange.\n * Retorna true para válido, false para inválido, null para idle.\n * Só é usada se `validationState` não for fornecido.\n */\n validate?: (value: string) => boolean | null;\n}\n\n/**\n * InputValidation — Input com feedback visual de validação em tempo real (Inline Validation).\n *\n * Exibe um ícone de CheckCircle (verde) para entradas válidas e XCircle (vermelho)\n * para entradas inválidas, comunicando o resultado imediatamente ao usuário — sem\n * esperar pelo submit do formulário.\n *\n * Arquétipo Governante: previne o erro antes que ele aconteça.\n * Arquétipo Herói: reduz a fricção com feedback imediato e encorajador.\n *\n * @example\n * // Modo controlado (recomendado com react-hook-form)\n * <InputValidation validationState={errors.email ? \"invalid\" : value ? \"valid\" : \"idle\"} />\n *\n * @example\n * // Modo com validate automático\n * <InputValidation validate={(v) => v.includes(\"@\") ? true : v.length > 0 ? false : null} />\n */\nexport const InputValidation = React.forwardRef<\n React.ElementRef<typeof Input>,\n InputValidationProps\n>(({\n validationState: controlledState,\n validate,\n onChange,\n className,\n ...props\n}, ref) => {\n const [internalState, setInternalState] = React.useState<ValidationState>(\"idle\");\n\n const state = controlledState ?? internalState;\n\n function handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n if (controlledState === undefined && validate) {\n const result = validate(e.target.value);\n if (result === null) setInternalState(\"idle\");\n else setInternalState(result ? \"valid\" : \"invalid\");\n }\n onChange?.(e);\n }\n\n return (\n <div className=\"relative flex items-center\">\n <Input\n ref={ref}\n className={cn(\n state !== \"idle\" && \"pr-9\",\n className,\n )}\n aria-invalid={state === \"invalid\" || undefined}\n onChange={handleChange}\n {...props}\n />\n {state === \"valid\" && (\n <CheckCircle2\n className=\"absolute right-3 size-4 text-green-600 pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n {state === \"invalid\" && (\n <XCircle\n className=\"absolute right-3 size-4 text-destructive pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n );\n});\nInputValidation.displayName = \"InputValidation\";\n"],"names":["InputValidation","React","controlledState","validate","onChange","className","props","ref","internalState","setInternalState","state","handleChange","e","result","jsxs","jsx","Input","cn","CheckCircle2","XCircle"],"mappings":"+eAwCaA,EAAkBC,EAAM,WAGnC,CAAC,CACD,gBAAiBC,EACjB,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAGC,IAAQ,CACT,KAAM,CAACC,EAAeC,CAAgB,EAAIR,EAAM,SAA0B,MAAM,EAE1ES,EAAQR,GAAmBM,EAEjC,SAASG,EAAaC,EAAwC,CAC5D,GAAIV,IAAoB,QAAaC,EAAU,CAC7C,MAAMU,EAASV,EAASS,EAAE,OAAO,KAAK,EACjBH,EAAjBI,IAAW,KAAuB,OAChBA,EAAS,QAAU,SADG,CAE9C,CACAT,GAAA,MAAAA,EAAWQ,EACb,CAEA,OACEE,EAAAA,KAAC,MAAA,CAAI,UAAU,6BACb,SAAA,CAAAC,EAAAA,IAACC,EAAAA,MAAA,CACC,IAAAT,EACA,UAAWU,EAAAA,GACTP,IAAU,QAAU,OACpBL,CAAA,EAEF,eAAcK,IAAU,WAAa,OACrC,SAAUC,EACT,GAAGL,CAAA,CAAA,EAELI,IAAU,SACTK,EAAAA,IAACG,EAAAA,aAAA,CACC,UAAU,6DACV,cAAY,MAAA,CAAA,EAGfR,IAAU,WACTK,EAAAA,IAACI,EAAAA,QAAA,CACC,UAAU,+DACV,cAAY,MAAA,CAAA,CACd,EAEJ,CAEJ,CAAC,EACDnB,EAAgB,YAAc"}
1
+ {"version":3,"file":"input-validation.cjs","sources":["../../../../src/components/ui/forms/input-validation.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckCircle2, XCircle } from \"lucide-react\";\n\nimport { Input } from \"./input\";\nimport { cn } from \"../utils\";\n\nexport type ValidationState = \"idle\" | \"valid\" | \"invalid\";\n\nexport interface InputValidationProps extends React.ComponentProps<\"input\"> {\n /**\n * Estado de validação controlado externamente.\n * Use \"idle\" antes da primeira interação, \"valid\" para sucesso e \"invalid\" para erro.\n */\n validationState?: ValidationState;\n /**\n * Função de validação automática disparada no onChange.\n * Retorna true para válido, false para inválido, null para idle.\n * Só é usada se `validationState` não for fornecido.\n */\n validate?: (value: string) => boolean | null;\n}\n\n/**\n * InputValidation — Input com feedback visual de validação em tempo real (Inline Validation).\n *\n * Exibe um ícone de CheckCircle (verde) para entradas válidas e XCircle (vermelho)\n * para entradas inválidas, comunicando o resultado imediatamente ao usuário — sem\n * esperar pelo submit do formulário.\n *\n * Arquétipo Governante: previne o erro antes que ele aconteça.\n * Arquétipo Herói: reduz a fricção com feedback imediato e encorajador.\n *\n * @example\n * // Modo controlado (recomendado com react-hook-form)\n * <InputValidation validationState={errors.email ? \"invalid\" : value ? \"valid\" : \"idle\"} />\n *\n * @example\n * // Modo com validate automático\n * <InputValidation validate={(v) => v.includes(\"@\") ? true : v.length > 0 ? false : null} />\n */\nexport const InputValidation = React.forwardRef<\n React.ElementRef<typeof Input>,\n InputValidationProps\n>(({\n validationState: controlledState,\n validate,\n onChange,\n className,\n ...props\n}, ref) => {\n const [internalState, setInternalState] = React.useState<ValidationState>(\"idle\");\n\n const state = controlledState ?? internalState;\n\n function handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n if (controlledState === undefined && validate) {\n const result = validate(e.target.value);\n if (result === null) setInternalState(\"idle\");\n else setInternalState(result ? \"valid\" : \"invalid\");\n }\n onChange?.(e);\n }\n\n return (\n <div className=\"relative flex items-center\">\n <Input\n ref={ref}\n className={cn(\n state !== \"idle\" && \"pr-9\",\n className,\n )}\n aria-invalid={state === \"invalid\" || undefined}\n onChange={handleChange}\n {...props}\n />\n {state === \"valid\" && (\n <CheckCircle2\n className=\"absolute right-3 size-4 text-success-emphasis pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n {state === \"invalid\" && (\n <XCircle\n className=\"absolute right-3 size-4 text-destructive-emphasis pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n );\n});\nInputValidation.displayName = \"InputValidation\";\n"],"names":["InputValidation","React","controlledState","validate","onChange","className","props","ref","internalState","setInternalState","state","handleChange","e","result","jsxs","jsx","Input","cn","CheckCircle2","XCircle"],"mappings":"+eAwCaA,EAAkBC,EAAM,WAGnC,CAAC,CACD,gBAAiBC,EACjB,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAGC,IAAQ,CACT,KAAM,CAACC,EAAeC,CAAgB,EAAIR,EAAM,SAA0B,MAAM,EAE1ES,EAAQR,GAAmBM,EAEjC,SAASG,EAAaC,EAAwC,CAC5D,GAAIV,IAAoB,QAAaC,EAAU,CAC7C,MAAMU,EAASV,EAASS,EAAE,OAAO,KAAK,EACjBH,EAAjBI,IAAW,KAAuB,OAChBA,EAAS,QAAU,SADG,CAE9C,CACAT,GAAA,MAAAA,EAAWQ,EACb,CAEA,OACEE,EAAAA,KAAC,MAAA,CAAI,UAAU,6BACb,SAAA,CAAAC,EAAAA,IAACC,EAAAA,MAAA,CACC,IAAAT,EACA,UAAWU,EAAAA,GACTP,IAAU,QAAU,OACpBL,CAAA,EAEF,eAAcK,IAAU,WAAa,OACrC,SAAUC,EACT,GAAGL,CAAA,CAAA,EAELI,IAAU,SACTK,EAAAA,IAACG,EAAAA,aAAA,CACC,UAAU,oEACV,cAAY,MAAA,CAAA,EAGfR,IAAU,WACTK,EAAAA,IAACI,EAAAA,QAAA,CACC,UAAU,wEACV,cAAY,MAAA,CAAA,CACd,EAEJ,CAEJ,CAAC,EACDnB,EAAgB,YAAc"}
@@ -1,26 +1,26 @@
1
- import { jsxs as p, jsx as i } from "react/jsx-runtime";
1
+ import { jsxs as v, jsx as t } from "react/jsx-runtime";
2
2
  import * as o from "react";
3
- import { CheckCircle2 as f, XCircle as x } from "lucide-react";
4
- import { Input as h } from "./input.js";
3
+ import { CheckCircle2 as f, XCircle as h } from "lucide-react";
4
+ import { Input as x } from "./input.js";
5
5
  import { cn as N } from "../utils.js";
6
6
  const I = o.forwardRef(({
7
7
  validationState: a,
8
- validate: r,
9
- onChange: t,
8
+ validate: s,
9
+ onChange: i,
10
10
  className: d,
11
11
  ...c
12
12
  }, m) => {
13
- const [u, n] = o.useState("idle"), e = a ?? u;
14
- function v(s) {
15
- if (a === void 0 && r) {
16
- const l = r(s.target.value);
17
- n(l === null ? "idle" : l ? "valid" : "invalid");
13
+ const [p, r] = o.useState("idle"), e = a ?? p;
14
+ function u(n) {
15
+ if (a === void 0 && s) {
16
+ const l = s(n.target.value);
17
+ r(l === null ? "idle" : l ? "valid" : "invalid");
18
18
  }
19
- t == null || t(s);
19
+ i == null || i(n);
20
20
  }
21
- return /* @__PURE__ */ p("div", { className: "relative flex items-center", children: [
22
- /* @__PURE__ */ i(
23
- h,
21
+ return /* @__PURE__ */ v("div", { className: "relative flex items-center", children: [
22
+ /* @__PURE__ */ t(
23
+ x,
24
24
  {
25
25
  ref: m,
26
26
  className: N(
@@ -28,21 +28,21 @@ const I = o.forwardRef(({
28
28
  d
29
29
  ),
30
30
  "aria-invalid": e === "invalid" || void 0,
31
- onChange: v,
31
+ onChange: u,
32
32
  ...c
33
33
  }
34
34
  ),
35
- e === "valid" && /* @__PURE__ */ i(
35
+ e === "valid" && /* @__PURE__ */ t(
36
36
  f,
37
37
  {
38
- className: "absolute right-3 size-4 text-green-600 pointer-events-none",
38
+ className: "absolute right-3 size-4 text-success-emphasis pointer-events-none",
39
39
  "aria-hidden": "true"
40
40
  }
41
41
  ),
42
- e === "invalid" && /* @__PURE__ */ i(
43
- x,
42
+ e === "invalid" && /* @__PURE__ */ t(
43
+ h,
44
44
  {
45
- className: "absolute right-3 size-4 text-destructive pointer-events-none",
45
+ className: "absolute right-3 size-4 text-destructive-emphasis pointer-events-none",
46
46
  "aria-hidden": "true"
47
47
  }
48
48
  )
@@ -1 +1 @@
1
- {"version":3,"file":"input-validation.js","sources":["../../../../src/components/ui/forms/input-validation.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckCircle2, XCircle } from \"lucide-react\";\n\nimport { Input } from \"./input\";\nimport { cn } from \"../utils\";\n\nexport type ValidationState = \"idle\" | \"valid\" | \"invalid\";\n\nexport interface InputValidationProps extends React.ComponentProps<\"input\"> {\n /**\n * Estado de validação controlado externamente.\n * Use \"idle\" antes da primeira interação, \"valid\" para sucesso e \"invalid\" para erro.\n */\n validationState?: ValidationState;\n /**\n * Função de validação automática disparada no onChange.\n * Retorna true para válido, false para inválido, null para idle.\n * Só é usada se `validationState` não for fornecido.\n */\n validate?: (value: string) => boolean | null;\n}\n\n/**\n * InputValidation — Input com feedback visual de validação em tempo real (Inline Validation).\n *\n * Exibe um ícone de CheckCircle (verde) para entradas válidas e XCircle (vermelho)\n * para entradas inválidas, comunicando o resultado imediatamente ao usuário — sem\n * esperar pelo submit do formulário.\n *\n * Arquétipo Governante: previne o erro antes que ele aconteça.\n * Arquétipo Herói: reduz a fricção com feedback imediato e encorajador.\n *\n * @example\n * // Modo controlado (recomendado com react-hook-form)\n * <InputValidation validationState={errors.email ? \"invalid\" : value ? \"valid\" : \"idle\"} />\n *\n * @example\n * // Modo com validate automático\n * <InputValidation validate={(v) => v.includes(\"@\") ? true : v.length > 0 ? false : null} />\n */\nexport const InputValidation = React.forwardRef<\n React.ElementRef<typeof Input>,\n InputValidationProps\n>(({\n validationState: controlledState,\n validate,\n onChange,\n className,\n ...props\n}, ref) => {\n const [internalState, setInternalState] = React.useState<ValidationState>(\"idle\");\n\n const state = controlledState ?? internalState;\n\n function handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n if (controlledState === undefined && validate) {\n const result = validate(e.target.value);\n if (result === null) setInternalState(\"idle\");\n else setInternalState(result ? \"valid\" : \"invalid\");\n }\n onChange?.(e);\n }\n\n return (\n <div className=\"relative flex items-center\">\n <Input\n ref={ref}\n className={cn(\n state !== \"idle\" && \"pr-9\",\n className,\n )}\n aria-invalid={state === \"invalid\" || undefined}\n onChange={handleChange}\n {...props}\n />\n {state === \"valid\" && (\n <CheckCircle2\n className=\"absolute right-3 size-4 text-green-600 pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n {state === \"invalid\" && (\n <XCircle\n className=\"absolute right-3 size-4 text-destructive pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n );\n});\nInputValidation.displayName = \"InputValidation\";\n"],"names":["InputValidation","React","controlledState","validate","onChange","className","props","ref","internalState","setInternalState","state","handleChange","e","result","jsxs","jsx","Input","cn","CheckCircle2","XCircle"],"mappings":";;;;;AAwCO,MAAMA,IAAkBC,EAAM,WAGnC,CAAC;AAAA,EACD,iBAAiBC;AAAA,EACjB,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,GAAGC,MAAQ;AACT,QAAM,CAACC,GAAeC,CAAgB,IAAIR,EAAM,SAA0B,MAAM,GAE1ES,IAAQR,KAAmBM;AAEjC,WAASG,EAAaC,GAAwC;AAC5D,QAAIV,MAAoB,UAAaC,GAAU;AAC7C,YAAMU,IAASV,EAASS,EAAE,OAAO,KAAK;AACtC,MAAqBH,EAAjBI,MAAW,OAAuB,SAChBA,IAAS,UAAU,SADG;AAAA,IAE9C;AACA,IAAAT,KAAA,QAAAA,EAAWQ;AAAA,EACb;AAEA,SACE,gBAAAE,EAAC,OAAA,EAAI,WAAU,8BACb,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAAT;AAAA,QACA,WAAWU;AAAA,UACTP,MAAU,UAAU;AAAA,UACpBL;AAAA,QAAA;AAAA,QAEF,gBAAcK,MAAU,aAAa;AAAA,QACrC,UAAUC;AAAA,QACT,GAAGL;AAAA,MAAA;AAAA,IAAA;AAAA,IAELI,MAAU,WACT,gBAAAK;AAAA,MAACG;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,eAAY;AAAA,MAAA;AAAA,IAAA;AAAA,IAGfR,MAAU,aACT,gBAAAK;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,eAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EACd,GAEJ;AAEJ,CAAC;AACDnB,EAAgB,cAAc;"}
1
+ {"version":3,"file":"input-validation.js","sources":["../../../../src/components/ui/forms/input-validation.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckCircle2, XCircle } from \"lucide-react\";\n\nimport { Input } from \"./input\";\nimport { cn } from \"../utils\";\n\nexport type ValidationState = \"idle\" | \"valid\" | \"invalid\";\n\nexport interface InputValidationProps extends React.ComponentProps<\"input\"> {\n /**\n * Estado de validação controlado externamente.\n * Use \"idle\" antes da primeira interação, \"valid\" para sucesso e \"invalid\" para erro.\n */\n validationState?: ValidationState;\n /**\n * Função de validação automática disparada no onChange.\n * Retorna true para válido, false para inválido, null para idle.\n * Só é usada se `validationState` não for fornecido.\n */\n validate?: (value: string) => boolean | null;\n}\n\n/**\n * InputValidation — Input com feedback visual de validação em tempo real (Inline Validation).\n *\n * Exibe um ícone de CheckCircle (verde) para entradas válidas e XCircle (vermelho)\n * para entradas inválidas, comunicando o resultado imediatamente ao usuário — sem\n * esperar pelo submit do formulário.\n *\n * Arquétipo Governante: previne o erro antes que ele aconteça.\n * Arquétipo Herói: reduz a fricção com feedback imediato e encorajador.\n *\n * @example\n * // Modo controlado (recomendado com react-hook-form)\n * <InputValidation validationState={errors.email ? \"invalid\" : value ? \"valid\" : \"idle\"} />\n *\n * @example\n * // Modo com validate automático\n * <InputValidation validate={(v) => v.includes(\"@\") ? true : v.length > 0 ? false : null} />\n */\nexport const InputValidation = React.forwardRef<\n React.ElementRef<typeof Input>,\n InputValidationProps\n>(({\n validationState: controlledState,\n validate,\n onChange,\n className,\n ...props\n}, ref) => {\n const [internalState, setInternalState] = React.useState<ValidationState>(\"idle\");\n\n const state = controlledState ?? internalState;\n\n function handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n if (controlledState === undefined && validate) {\n const result = validate(e.target.value);\n if (result === null) setInternalState(\"idle\");\n else setInternalState(result ? \"valid\" : \"invalid\");\n }\n onChange?.(e);\n }\n\n return (\n <div className=\"relative flex items-center\">\n <Input\n ref={ref}\n className={cn(\n state !== \"idle\" && \"pr-9\",\n className,\n )}\n aria-invalid={state === \"invalid\" || undefined}\n onChange={handleChange}\n {...props}\n />\n {state === \"valid\" && (\n <CheckCircle2\n className=\"absolute right-3 size-4 text-success-emphasis pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n {state === \"invalid\" && (\n <XCircle\n className=\"absolute right-3 size-4 text-destructive-emphasis pointer-events-none\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n );\n});\nInputValidation.displayName = \"InputValidation\";\n"],"names":["InputValidation","React","controlledState","validate","onChange","className","props","ref","internalState","setInternalState","state","handleChange","e","result","jsxs","jsx","Input","cn","CheckCircle2","XCircle"],"mappings":";;;;;AAwCO,MAAMA,IAAkBC,EAAM,WAGnC,CAAC;AAAA,EACD,iBAAiBC;AAAA,EACjB,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,GAAGC,MAAQ;AACT,QAAM,CAACC,GAAeC,CAAgB,IAAIR,EAAM,SAA0B,MAAM,GAE1ES,IAAQR,KAAmBM;AAEjC,WAASG,EAAaC,GAAwC;AAC5D,QAAIV,MAAoB,UAAaC,GAAU;AAC7C,YAAMU,IAASV,EAASS,EAAE,OAAO,KAAK;AACtC,MAAqBH,EAAjBI,MAAW,OAAuB,SAChBA,IAAS,UAAU,SADG;AAAA,IAE9C;AACA,IAAAT,KAAA,QAAAA,EAAWQ;AAAA,EACb;AAEA,SACE,gBAAAE,EAAC,OAAA,EAAI,WAAU,8BACb,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAAT;AAAA,QACA,WAAWU;AAAA,UACTP,MAAU,UAAU;AAAA,UACpBL;AAAA,QAAA;AAAA,QAEF,gBAAcK,MAAU,aAAa;AAAA,QACrC,UAAUC;AAAA,QACT,GAAGL;AAAA,MAAA;AAAA,IAAA;AAAA,IAELI,MAAU,WACT,gBAAAK;AAAA,MAACG;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,eAAY;AAAA,MAAA;AAAA,IAAA;AAAA,IAGfR,MAAU,aACT,gBAAAK;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,eAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EACd,GAEJ;AAEJ,CAAC;AACDnB,EAAgB,cAAc;"}
@@ -1,2 +1,2 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),te=require("react"),i=require("lucide-react"),c=require("../utils.cjs"),se=require("../primitives/button.cjs"),I=require("../primitives/badge.cjs"),N=require("../overlays/popover.cjs"),ne=require("./input.cjs");function re(n){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(o,a,r.get?r:{enumerable:!0,get:()=>n[a]})}}return o.default=n,Object.freeze(o)}const l=re(te),E=l.forwardRef(({value:n,onValueChange:o,options:a,groups:r,placeholder:W="Selecione...",searchPlaceholder:_="Buscar...",emptyMessage:$="Nenhum resultado encontrado",disabled:C=!1,loading:k=!1,maxVisibleChips:R=2,onSearch:u,onCreateOption:g,createOptionLabel:v,className:A,"aria-label":F,"aria-labelledby":H},M)=>{var B;const[h,K]=l.useState(!1),[d,y]=l.useState(""),[x,P]=l.useState(!1),w=l.useRef(null),q=l.useRef(null),z=l.useMemo(()=>c.mergeRefs(w,M),[M]),U=l.useCallback(e=>{e&&e.addEventListener("wheel",s=>s.stopPropagation(),{passive:!0})},[]),j=l.useMemo(()=>a||(r?[...r.filter(s=>s.value!=null).map(s=>({value:s.value,label:s.label})),...r.flatMap(s=>s.options)]:[]),[a,r]),b=!!u,D=l.useMemo(()=>{if(!a)return[];if(b)return a;const e=d.toLowerCase().trim();return e?a.filter(s=>s.label.toLowerCase().includes(e)||s.value.toLowerCase().includes(e)):a},[a,d,b]),m=l.useMemo(()=>{if(!r)return;if(b)return r;const e=d.toLowerCase().trim();return e?r.map(s=>({...s,options:s.options.filter(p=>p.label.toLowerCase().includes(e)||p.value.toLowerCase().includes(e))})).filter(s=>s.options.length>0):r},[r,d,b]),O=l.useMemo(()=>j.filter(e=>n.includes(e.value)),[j,n]),X=r?(m==null?void 0:m.some(e=>e.options.length>0))??!1:D.length>0,f=d.trim(),J=j.some(e=>e.label.trim().toLowerCase()===f.toLowerCase()),Q=!!g&&f.length>0&&!J,Y=async()=>{if(!(!g||x||!f)){P(!0);try{await g(f),y("")}catch{}finally{P(!1)}}},L=e=>{n.includes(e)?o(n.filter(s=>s!==e)):o([...n,e])},Z=(e,s)=>{s.stopPropagation(),o(n.filter(p=>p!==e))},G=e=>{C||(K(e),e||y(""))};l.useEffect(()=>{h&&(u==null||u(""))},[h]);const V=e=>{y(e.target.value),u==null||u(e.target.value)},ee=O.slice(0,R),S=O.length-R,T=e=>{const s=n.includes(e.value);return t.jsxs("button",{type:"button",role:"option","aria-selected":s,disabled:e.disabled,onClick:()=>L(e.value),className:c.cn("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground focus:outline-none","transition-colors duration-100",e.disabled&&"pointer-events-none opacity-50"),children:[t.jsx(i.Check,{className:c.cn("h-4 w-4 shrink-0 transition-opacity duration-100",s?"opacity-100":"opacity-0")}),t.jsx("span",{className:"flex-1 text-left truncate",children:e.label}),e.badge]},e.value)};return t.jsxs(N.Popover,{open:h,onOpenChange:G,children:[t.jsx(N.PopoverTrigger,{asChild:!0,children:t.jsxs(se.Button,{ref:z,type:"button",variant:"outline",role:"combobox","aria-expanded":h,"aria-label":F,"aria-labelledby":H,disabled:C,className:c.cn("w-full min-h-10 h-auto justify-between font-normal px-3 py-2",!n.length&&"text-muted-foreground",A),children:[t.jsx("div",{className:"flex flex-wrap items-center gap-1 flex-1 min-w-0",children:n.length===0?t.jsx("span",{className:"truncate text-sm",children:k?"Carregando...":W}):t.jsxs(t.Fragment,{children:[ee.map(e=>t.jsxs(I.Badge,{variant:"secondary",className:"rounded-sm h-5 gap-0.5 pr-1 font-normal max-w-[160px]",children:[t.jsx("span",{className:"truncate text-xs",children:e.label}),t.jsx("span",{role:"button",tabIndex:0,"aria-label":`Remover ${e.label}`,className:"inline-flex items-center justify-center rounded-sm hover:bg-muted/80 cursor-pointer shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-ring/60",onMouseDown:s=>s.preventDefault(),onClick:s=>Z(e.value,s),onKeyDown:c.pressableKeyDown,children:t.jsx(i.X,{className:"h-3 w-3"})})]},e.value)),S>0&&t.jsxs(I.Badge,{variant:"secondary",className:"rounded-sm h-5 px-1.5 font-normal text-xs shrink-0",children:["+",S]})]})}),t.jsx(i.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsxs(N.PopoverContent,{className:"p-0 overflow-hidden",style:{width:(B=w.current)!=null&&B.offsetWidth?`${w.current.offsetWidth}px`:"auto"},align:"start",onOpenAutoFocus:e=>{var s;e.preventDefault(),(s=q.current)==null||s.focus()},onWheel:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center border-b px-3",children:[t.jsx(i.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),t.jsx(ne.Input,{ref:q,placeholder:_,value:d,onChange:V,className:"h-10 border-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0"})]}),Q&&t.jsxs("button",{type:"button",onClick:Y,disabled:x,className:c.cn("flex w-full items-center gap-2 border-b px-3 py-2 text-sm text-primary","hover:bg-accent transition-colors duration-100","disabled:opacity-50 disabled:pointer-events-none"),children:[x?t.jsx(i.Loader2,{className:"h-4 w-4 shrink-0 animate-spin"}):t.jsx(i.Plus,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate",children:x?"Criando...":(v==null?void 0:v(f))??`Criar "${f}"`})]}),t.jsx("div",{ref:U,className:"max-h-70 overflow-y-auto [&::-webkit-scrollbar]:w-2.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-primary/30 [&::-webkit-scrollbar-thumb:hover]:bg-primary/50",children:t.jsx("div",{className:"p-1",role:"listbox","aria-multiselectable":!0,children:k?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[t.jsx(i.Loader2,{className:"h-4 w-4 animate-spin"}),"Carregando..."]}):X?r?m==null?void 0:m.map(e=>t.jsxs("div",{children:[e.value?t.jsxs("button",{type:"button",onClick:()=>L(e.value),className:c.cn("flex w-full items-center gap-2 rounded-sm px-2 py-1.5","hover:bg-accent hover:text-accent-foreground transition-colors duration-100",n.includes(e.value)&&"text-foreground"),children:[t.jsx(i.Check,{className:c.cn("h-4 w-4 shrink-0 transition-opacity duration-100",n.includes(e.value)?"opacity-100":"opacity-0")}),t.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:e.label})]}):t.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:e.label}),e.options.map(T)]},e.label)):D.map(T):t.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:$})})})]})]})});E.displayName="MultiSelect";exports.MultiSelect=E;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),te=require("react"),i=require("lucide-react"),c=require("../utils.cjs"),se=require("../primitives/button.cjs"),I=require("../primitives/badge.cjs"),N=require("../overlays/popover.cjs"),ne=require("./input.cjs");function re(n){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(o,a,r.get?r:{enumerable:!0,get:()=>n[a]})}}return o.default=n,Object.freeze(o)}const l=re(te),E=l.forwardRef(({value:n,onValueChange:o,options:a,groups:r,placeholder:W="Selecione...",searchPlaceholder:_="Buscar...",emptyMessage:$="Nenhum resultado encontrado",disabled:C=!1,loading:k=!1,maxVisibleChips:R=2,onSearch:d,onCreateOption:g,createOptionLabel:v,className:A,"aria-label":F,"aria-labelledby":H},M)=>{var B;const[h,K]=l.useState(!1),[u,y]=l.useState(""),[x,P]=l.useState(!1),w=l.useRef(null),q=l.useRef(null),z=l.useMemo(()=>c.mergeRefs(w,M),[M]),U=l.useCallback(e=>{e&&e.addEventListener("wheel",s=>s.stopPropagation(),{passive:!0})},[]),j=l.useMemo(()=>a||(r?[...r.filter(s=>s.value!=null).map(s=>({value:s.value,label:s.label})),...r.flatMap(s=>s.options)]:[]),[a,r]),b=!!d,D=l.useMemo(()=>{if(!a)return[];if(b)return a;const e=u.toLowerCase().trim();return e?a.filter(s=>s.label.toLowerCase().includes(e)||s.value.toLowerCase().includes(e)):a},[a,u,b]),m=l.useMemo(()=>{if(!r)return;if(b)return r;const e=u.toLowerCase().trim();return e?r.map(s=>({...s,options:s.options.filter(p=>p.label.toLowerCase().includes(e)||p.value.toLowerCase().includes(e))})).filter(s=>s.options.length>0):r},[r,u,b]),O=l.useMemo(()=>j.filter(e=>n.includes(e.value)),[j,n]),X=r?(m==null?void 0:m.some(e=>e.options.length>0))??!1:D.length>0,f=u.trim(),J=j.some(e=>e.label.trim().toLowerCase()===f.toLowerCase()),Q=!!g&&f.length>0&&!J,Y=async()=>{if(!(!g||x||!f)){P(!0);try{await g(f),y("")}catch{}finally{P(!1)}}},L=e=>{n.includes(e)?o(n.filter(s=>s!==e)):o([...n,e])},Z=(e,s)=>{s.stopPropagation(),o(n.filter(p=>p!==e))},G=e=>{C||(K(e),e||y(""))};l.useEffect(()=>{h&&(d==null||d(""))},[h]);const V=e=>{y(e.target.value),d==null||d(e.target.value)},ee=O.slice(0,R),S=O.length-R,T=e=>{const s=n.includes(e.value);return t.jsxs("button",{type:"button",role:"option","aria-selected":s,disabled:e.disabled,onClick:()=>L(e.value),className:c.cn("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm","aria-selected:bg-secondary aria-selected:text-secondary-foreground aria-selected:font-medium","not-aria-selected:hover:bg-accent not-aria-selected:hover:text-accent-foreground","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset","transition-colors duration-100",e.disabled&&"pointer-events-none opacity-50"),children:[t.jsx(i.Check,{className:c.cn("h-4 w-4 shrink-0 transition-opacity duration-100",s?"opacity-100":"opacity-0")}),t.jsx("span",{className:"flex-1 text-left truncate",children:e.label}),e.badge]},e.value)};return t.jsxs(N.Popover,{open:h,onOpenChange:G,children:[t.jsx(N.PopoverTrigger,{asChild:!0,children:t.jsxs(se.Button,{ref:z,type:"button",variant:"outline",role:"combobox","aria-expanded":h,"aria-label":F,"aria-labelledby":H,disabled:C,className:c.cn("w-full min-h-10 h-auto justify-between font-normal px-3 py-2",!n.length&&"text-muted-foreground",A),children:[t.jsx("div",{className:"flex flex-wrap items-center gap-1 flex-1 min-w-0",children:n.length===0?t.jsx("span",{className:"truncate text-sm",children:k?"Carregando...":W}):t.jsxs(t.Fragment,{children:[ee.map(e=>t.jsxs(I.Badge,{variant:"secondary",className:"rounded-sm h-5 gap-0.5 pr-1 font-normal max-w-[160px]",children:[t.jsx("span",{className:"truncate text-xs",children:e.label}),t.jsx("span",{role:"button",tabIndex:0,"aria-label":`Remover ${e.label}`,className:"inline-flex items-center justify-center rounded-sm hover:bg-muted/80 cursor-pointer shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-ring/60",onMouseDown:s=>s.preventDefault(),onClick:s=>Z(e.value,s),onKeyDown:c.pressableKeyDown,children:t.jsx(i.X,{className:"h-3 w-3"})})]},e.value)),S>0&&t.jsxs(I.Badge,{variant:"secondary",className:"rounded-sm h-5 px-1.5 font-normal text-xs shrink-0",children:["+",S]})]})}),t.jsx(i.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsxs(N.PopoverContent,{className:"p-0 overflow-hidden",style:{width:(B=w.current)!=null&&B.offsetWidth?`${w.current.offsetWidth}px`:"auto"},align:"start",onOpenAutoFocus:e=>{var s;e.preventDefault(),(s=q.current)==null||s.focus()},onWheel:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center border-b px-3",children:[t.jsx(i.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),t.jsx(ne.Input,{ref:q,placeholder:_,value:u,onChange:V,className:"h-10 border-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0"})]}),Q&&t.jsxs("button",{type:"button",onClick:Y,disabled:x,className:c.cn("flex w-full items-center gap-2 border-b px-3 py-2 text-sm text-primary","hover:bg-accent hover:text-accent-foreground transition-colors duration-100","disabled:opacity-50 disabled:pointer-events-none"),children:[x?t.jsx(i.Loader2,{className:"h-4 w-4 shrink-0 animate-spin"}):t.jsx(i.Plus,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate",children:x?"Criando...":(v==null?void 0:v(f))??`Criar "${f}"`})]}),t.jsx("div",{ref:U,className:"max-h-70 overflow-y-auto [&::-webkit-scrollbar]:w-2.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-primary/30 [&::-webkit-scrollbar-thumb:hover]:bg-primary/50",children:t.jsx("div",{className:"p-1",role:"listbox","aria-multiselectable":!0,children:k?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[t.jsx(i.Loader2,{className:"h-4 w-4 animate-spin"}),"Carregando..."]}):X?r?m==null?void 0:m.map(e=>t.jsxs("div",{children:[e.value?t.jsxs("button",{type:"button",onClick:()=>L(e.value),className:c.cn("flex w-full items-center gap-2 rounded-sm px-2 py-1.5","hover:bg-accent hover:text-accent-foreground transition-colors duration-100",n.includes(e.value)&&"text-foreground"),children:[t.jsx(i.Check,{className:c.cn("h-4 w-4 shrink-0 transition-opacity duration-100",n.includes(e.value)?"opacity-100":"opacity-0")}),t.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:e.label})]}):t.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:e.label}),e.options.map(T)]},e.label)):D.map(T):t.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:$})})})]})]})});E.displayName="MultiSelect";exports.MultiSelect=E;
2
2
  //# sourceMappingURL=multi-select.cjs.map