@flowtomic/ui 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/blocks/developer-panel/page.d.ts.map +1 -1
  2. package/dist/blocks/developer-panel/page.js +2 -2
  3. package/dist/components/atoms/actions/badge/badge.d.ts +1 -1
  4. package/dist/components/atoms/actions/button/button.d.ts +2 -2
  5. package/dist/components/atoms/animation/encrypted-text/encrypted-text.d.ts +57 -0
  6. package/dist/components/atoms/animation/encrypted-text/encrypted-text.d.ts.map +1 -0
  7. package/dist/components/atoms/animation/encrypted-text/encrypted-text.js +104 -0
  8. package/dist/components/atoms/animation/encrypted-text/index.d.ts +3 -0
  9. package/dist/components/atoms/animation/encrypted-text/index.d.ts.map +1 -0
  10. package/dist/components/atoms/animation/encrypted-text/index.js +1 -0
  11. package/dist/components/atoms/animation/index.d.ts +2 -0
  12. package/dist/components/atoms/animation/index.d.ts.map +1 -1
  13. package/dist/components/atoms/animation/index.js +1 -0
  14. package/dist/components/atoms/data-display/index.d.ts +2 -0
  15. package/dist/components/atoms/data-display/index.d.ts.map +1 -1
  16. package/dist/components/atoms/data-display/index.js +1 -0
  17. package/dist/components/atoms/data-display/qr-code/index.d.ts +3 -0
  18. package/dist/components/atoms/data-display/qr-code/index.d.ts.map +1 -0
  19. package/dist/components/atoms/data-display/qr-code/index.js +1 -0
  20. package/dist/components/atoms/data-display/qr-code/qr-code.d.ts +18 -0
  21. package/dist/components/atoms/data-display/qr-code/qr-code.d.ts.map +1 -0
  22. package/dist/components/atoms/data-display/qr-code/qr-code.js +79 -0
  23. package/dist/components/atoms/feedback/tooltip/index.d.ts +1 -1
  24. package/dist/components/atoms/feedback/tooltip/index.d.ts.map +1 -1
  25. package/dist/components/atoms/feedback/tooltip/index.js +1 -1
  26. package/dist/components/atoms/feedback/tooltip/tooltip.d.ts +42 -5
  27. package/dist/components/atoms/feedback/tooltip/tooltip.d.ts.map +1 -1
  28. package/dist/components/atoms/feedback/tooltip/tooltip.js +188 -5
  29. package/dist/components/atoms/forms/autocomplete/autocomplete-context.d.ts +29 -0
  30. package/dist/components/atoms/forms/autocomplete/autocomplete-context.d.ts.map +1 -0
  31. package/dist/components/atoms/forms/autocomplete/autocomplete-context.js +10 -0
  32. package/dist/components/atoms/forms/autocomplete/autocomplete-item.d.ts +16 -0
  33. package/dist/components/atoms/forms/autocomplete/autocomplete-item.d.ts.map +1 -0
  34. package/dist/components/atoms/forms/autocomplete/autocomplete-item.js +48 -0
  35. package/dist/components/atoms/forms/autocomplete/autocomplete-section.d.ts +14 -0
  36. package/dist/components/atoms/forms/autocomplete/autocomplete-section.d.ts.map +1 -0
  37. package/dist/components/atoms/forms/autocomplete/autocomplete-section.js +13 -0
  38. package/dist/components/atoms/forms/autocomplete/autocomplete.d.ts +13 -9
  39. package/dist/components/atoms/forms/autocomplete/autocomplete.d.ts.map +1 -1
  40. package/dist/components/atoms/forms/autocomplete/autocomplete.js +295 -87
  41. package/dist/components/atoms/forms/autocomplete/index.d.ts +6 -0
  42. package/dist/components/atoms/forms/autocomplete/index.d.ts.map +1 -1
  43. package/dist/components/atoms/forms/autocomplete/index.js +3 -0
  44. package/dist/components/atoms/forms/index.d.ts +0 -2
  45. package/dist/components/atoms/forms/index.d.ts.map +1 -1
  46. package/dist/components/atoms/forms/index.js +0 -1
  47. package/dist/components/atoms/forms/input/input.d.ts +1 -1
  48. package/dist/components/atoms/forms/toggle/toggle.d.ts +1 -1
  49. package/dist/components/atoms/layout/sidebar/sidebar.d.ts +1 -1
  50. package/dist/components/atoms/navigation/command/command.d.ts +13 -13
  51. package/dist/components/atoms/navigation/tabs/tabs.js +2 -2
  52. package/dist/components/molecules/auth/auth-navigation-link/auth-navigation-link.d.ts +1 -11
  53. package/dist/components/molecules/auth/auth-navigation-link/auth-navigation-link.d.ts.map +1 -1
  54. package/dist/components/molecules/auth/auth-navigation-link/auth-navigation-link.js +2 -3
  55. package/dist/components/molecules/forms/autocomplete/autocomplete-context.d.ts +16 -0
  56. package/dist/components/molecules/forms/autocomplete/autocomplete-context.d.ts.map +1 -0
  57. package/dist/components/molecules/forms/autocomplete/autocomplete-context.js +14 -0
  58. package/dist/components/molecules/forms/autocomplete/autocomplete-item.d.ts +23 -0
  59. package/dist/components/molecules/forms/autocomplete/autocomplete-item.d.ts.map +1 -0
  60. package/dist/components/molecules/forms/autocomplete/autocomplete-item.js +29 -0
  61. package/dist/components/molecules/forms/autocomplete/autocomplete-section.d.ts +19 -0
  62. package/dist/components/molecules/forms/autocomplete/autocomplete-section.d.ts.map +1 -0
  63. package/dist/components/molecules/forms/autocomplete/autocomplete-section.js +13 -0
  64. package/dist/components/molecules/forms/autocomplete/autocomplete.d.ts +33 -0
  65. package/dist/components/molecules/forms/autocomplete/autocomplete.d.ts.map +1 -0
  66. package/dist/components/molecules/forms/autocomplete/autocomplete.js +101 -0
  67. package/dist/components/molecules/forms/autocomplete/index.d.ts +9 -0
  68. package/dist/components/molecules/forms/autocomplete/index.d.ts.map +1 -0
  69. package/dist/components/molecules/forms/autocomplete/index.js +4 -0
  70. package/dist/components/molecules/forms/item/item.d.ts +1 -1
  71. package/dist/components/molecules/forms/text-editor/index.d.ts +3 -0
  72. package/dist/components/molecules/forms/text-editor/index.d.ts.map +1 -0
  73. package/dist/components/molecules/forms/text-editor/index.js +1 -0
  74. package/dist/components/molecules/forms/text-editor/text-editor.d.ts +33 -0
  75. package/dist/components/molecules/forms/text-editor/text-editor.d.ts.map +1 -0
  76. package/dist/components/molecules/forms/text-editor/text-editor.js +211 -0
  77. package/dist/components/molecules/index.d.ts +4 -2
  78. package/dist/components/molecules/index.d.ts.map +1 -1
  79. package/dist/components/molecules/index.js +2 -1
  80. package/dist/components/molecules/navigation/menu-dock/menu-dock.d.ts +5 -0
  81. package/dist/components/molecules/navigation/menu-dock/menu-dock.d.ts.map +1 -1
  82. package/dist/components/molecules/navigation/menu-dock/menu-dock.js +103 -10
  83. package/dist/components/molecules/typography/index.d.ts +0 -2
  84. package/dist/components/molecules/typography/index.d.ts.map +1 -1
  85. package/dist/components/molecules/typography/index.js +1 -1
  86. package/dist/components/organisms/context/context.d.ts +4 -4
  87. package/dist/components/organisms/document-editor/document-editor.d.ts +43 -0
  88. package/dist/components/organisms/document-editor/document-editor.d.ts.map +1 -0
  89. package/dist/components/organisms/document-editor/document-editor.js +144 -0
  90. package/dist/components/organisms/document-editor/index.d.ts +3 -0
  91. package/dist/components/organisms/document-editor/index.d.ts.map +1 -0
  92. package/dist/components/organisms/document-editor/index.js +1 -0
  93. package/dist/components/organisms/form-layout/form-layout.d.ts +111 -0
  94. package/dist/components/organisms/form-layout/form-layout.d.ts.map +1 -0
  95. package/dist/components/organisms/form-layout/form-layout.js +83 -0
  96. package/dist/components/organisms/form-layout/index.d.ts +2 -0
  97. package/dist/components/organisms/form-layout/index.d.ts.map +1 -0
  98. package/dist/components/organisms/form-layout/index.js +1 -0
  99. package/dist/components/organisms/index.d.ts +4 -0
  100. package/dist/components/organisms/index.d.ts.map +1 -1
  101. package/dist/components/organisms/index.js +2 -0
  102. package/dist/components/organisms/model-selector/model-selector.d.ts +1 -1
  103. package/dist/index.js +623 -526
  104. package/dist/styles/globals.css +489 -0
  105. package/dist/styles/theme.css +1364 -0
  106. package/dist/styles/typography.css +430 -0
  107. package/package.json +45 -18
@@ -1,10 +1,16 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /**
3
2
  * Tooltip Component - Flowtomic UI
4
3
  *
5
- * Componente Tooltip baseado em Radix UI
4
+ * Componente Tooltip baseado em Radix UI (padrão) ou React Aria (followMouse)
5
+ * com seguimento do mouse e posicionamento inteligente
6
+ * Baseado no Aceternity UI Tooltip Card para animações
6
7
  */
8
+ "use client";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
10
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
11
+ import { useTooltip } from "@react-aria/tooltip";
12
+ import { useTooltipTriggerState } from "@react-stately/tooltip";
13
+ import { AnimatePresence, motion } from "motion/react";
8
14
  import * as React from "react";
9
15
  import { cn } from "@/lib/utils";
10
16
  /**
@@ -20,7 +26,9 @@ Tooltip.displayName = "Tooltip";
20
26
  /**
21
27
  * TooltipTrigger - Trigger do tooltip
22
28
  */
23
- const TooltipTrigger = TooltipPrimitive.Trigger;
29
+ const TooltipTrigger = React.forwardRef(({ "data-follow-mouse": followMouse, ...props }, ref) => {
30
+ return (_jsx(TooltipPrimitive.Trigger, { ref: ref, "data-radix-tooltip-trigger": "", "data-follow-mouse": followMouse, ...props }));
31
+ });
24
32
  TooltipTrigger.displayName = "TooltipTrigger";
25
33
  /**
26
34
  * TooltipPortal - Portal do tooltip
@@ -28,8 +36,183 @@ TooltipTrigger.displayName = "TooltipTrigger";
28
36
  const TooltipPortal = TooltipPrimitive.Portal;
29
37
  TooltipPortal.displayName = "TooltipPortal";
30
38
  /**
31
- * TooltipContent - Conteúdo do tooltip
39
+ * TooltipContent - Conteúdo do tooltip com suporte a seguimento do mouse
32
40
  */
33
- const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(TooltipPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className), ...props })));
41
+ const TooltipContent = React.forwardRef(({ className, sideOffset = 4, followMouse = false, minWidth = 240, children, ...props }, ref) => {
42
+ // Se não seguir o mouse, usar comportamento padrão do Radix
43
+ if (!followMouse) {
44
+ return (_jsx(TooltipPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className), ...props, children: children }));
45
+ }
46
+ // Comportamento com seguimento do mouse - implementação customizada baseada no Aceternity
47
+ return (_jsx(TooltipContentWithMouseFollow, { ref: ref, sideOffset: sideOffset, className: className, minWidth: minWidth, ...props, children: children }));
48
+ });
34
49
  TooltipContent.displayName = TooltipPrimitive.Content.displayName;
50
+ /**
51
+ * TooltipContentWithMouseFollow - Versão com seguimento do mouse
52
+ * Este componente não renderiza nada - o tooltip é renderizado via portal
53
+ * O estado é gerenciado pelo TooltipWithMouseFollowWrapper
54
+ */
55
+ const TooltipContentWithMouseFollow = React.forwardRef(({ className, minWidth, children, ...props }, ref) => {
56
+ // Este componente não renderiza - o tooltip é gerenciado pelo wrapper
57
+ return null;
58
+ });
59
+ TooltipContentWithMouseFollow.displayName = "TooltipContentWithMouseFollow";
60
+ /**
61
+ * TooltipWithMouseFollow - Wrapper completo para tooltip com seguimento do mouse
62
+ * Implementação baseada no Aceternity UI, sem Radix
63
+ */
64
+ export function TooltipWithMouseFollow({ content, children, containerClassName, className, minWidth = 240, }) {
65
+ const [isVisible, setIsVisible] = React.useState(false);
66
+ const [mouse, setMouse] = React.useState({ x: 0, y: 0 });
67
+ const [height, setHeight] = React.useState(0);
68
+ const [position, setPosition] = React.useState({ x: 0, y: 0 });
69
+ const contentRef = React.useRef(null);
70
+ const containerRef = React.useRef(null);
71
+ // Usar React Aria para acessibilidade
72
+ const state = useTooltipTriggerState({ delay: 0 });
73
+ const { tooltipProps } = useTooltip({}, state);
74
+ // Sincronizar estado do React Aria com estado local
75
+ React.useEffect(() => {
76
+ setIsVisible(state.isOpen);
77
+ }, [state.isOpen]);
78
+ React.useEffect(() => {
79
+ if (isVisible && contentRef.current) {
80
+ // Usar múltiplos requestAnimationFrame para garantir que o DOM foi totalmente renderizado
81
+ const rafId1 = requestAnimationFrame(() => {
82
+ const rafId2 = requestAnimationFrame(() => {
83
+ if (contentRef.current) {
84
+ // scrollHeight do conteúdo interno
85
+ const contentScrollHeight = contentRef.current.scrollHeight;
86
+ // py-1.5 = 0.375rem = 6px top + 6px bottom = 12px total
87
+ // Adicionar buffer extra para garantir que não corte
88
+ setHeight(contentScrollHeight + 16);
89
+ }
90
+ });
91
+ return () => cancelAnimationFrame(rafId2);
92
+ });
93
+ return () => cancelAnimationFrame(rafId1);
94
+ }
95
+ }, [isVisible, content]);
96
+ const calculatePosition = React.useCallback((mouseX, mouseY) => {
97
+ if (!contentRef.current || !containerRef.current) {
98
+ return { x: mouseX + 12, y: mouseY + 12 };
99
+ }
100
+ const tooltip = contentRef.current;
101
+ const container = containerRef.current;
102
+ const containerRect = container.getBoundingClientRect();
103
+ const viewportWidth = window.innerWidth;
104
+ const viewportHeight = window.innerHeight;
105
+ // Dimensões do tooltip
106
+ const tooltipWidth = minWidth;
107
+ const tooltipHeight = tooltip.scrollHeight;
108
+ // Calcular posição absoluta relativa ao viewport
109
+ const absoluteX = containerRect.left + mouseX;
110
+ const absoluteY = containerRect.top + mouseY;
111
+ // Posição inicial relativa ao container (como no original)
112
+ let finalX = mouseX + 12;
113
+ let finalY = mouseY + 12;
114
+ // Verificar se ultrapassa a borda direita
115
+ if (absoluteX + 12 + tooltipWidth > viewportWidth) {
116
+ finalX = mouseX - tooltipWidth - 12;
117
+ }
118
+ // Verificar se ultrapassa a borda esquerda
119
+ if (absoluteX + finalX < 0) {
120
+ finalX = -containerRect.left + 12;
121
+ }
122
+ // Verificar se ultrapassa a borda inferior
123
+ if (absoluteY + 12 + tooltipHeight > viewportHeight) {
124
+ finalY = mouseY - tooltipHeight - 12;
125
+ }
126
+ // Verificar se ultrapassa a borda superior
127
+ if (absoluteY + finalY < 0) {
128
+ finalY = -containerRect.top + 12;
129
+ }
130
+ return { x: finalX, y: finalY };
131
+ }, [minWidth]);
132
+ const updateMousePosition = React.useCallback((mouseX, mouseY) => {
133
+ setMouse({ x: mouseX, y: mouseY });
134
+ const newPosition = calculatePosition(mouseX, mouseY);
135
+ setPosition(newPosition);
136
+ }, [calculatePosition]);
137
+ const handleMouseEnter = (e) => {
138
+ state.open();
139
+ const rect = e.currentTarget.getBoundingClientRect();
140
+ // Usar coordenadas relativas ao container para cálculo
141
+ const mouseX = e.clientX - rect.left;
142
+ const mouseY = e.clientY - rect.top;
143
+ updateMousePosition(mouseX, mouseY);
144
+ };
145
+ const handleMouseLeave = () => {
146
+ state.close();
147
+ setMouse({ x: 0, y: 0 });
148
+ setPosition({ x: 0, y: 0 });
149
+ };
150
+ const handleMouseMove = (e) => {
151
+ if (!isVisible)
152
+ return;
153
+ const rect = e.currentTarget.getBoundingClientRect();
154
+ const mouseX = e.clientX - rect.left;
155
+ const mouseY = e.clientY - rect.top;
156
+ updateMousePosition(mouseX, mouseY);
157
+ };
158
+ const handleTouchStart = (e) => {
159
+ const touch = e.touches[0];
160
+ const rect = e.currentTarget.getBoundingClientRect();
161
+ const mouseX = touch.clientX - rect.left;
162
+ const mouseY = touch.clientY - rect.top;
163
+ updateMousePosition(mouseX, mouseY);
164
+ state.open();
165
+ };
166
+ const handleTouchEnd = () => {
167
+ setTimeout(() => {
168
+ state.close();
169
+ setMouse({ x: 0, y: 0 });
170
+ setPosition({ x: 0, y: 0 });
171
+ }, 2000);
172
+ };
173
+ const handleClick = (e) => {
174
+ if (window.matchMedia("(hover: none)").matches) {
175
+ e.preventDefault();
176
+ if (isVisible) {
177
+ state.close();
178
+ setMouse({ x: 0, y: 0 });
179
+ setPosition({ x: 0, y: 0 });
180
+ }
181
+ else {
182
+ const rect = e.currentTarget.getBoundingClientRect();
183
+ const mouseX = e.clientX - rect.left;
184
+ const mouseY = e.clientY - rect.top;
185
+ updateMousePosition(mouseX, mouseY);
186
+ state.open();
187
+ }
188
+ }
189
+ };
190
+ // Recalcular posição quando altura mudar ou tooltip ficar visível
191
+ React.useEffect(() => {
192
+ if (isVisible && mouse.x !== 0 && mouse.y !== 0) {
193
+ // Usar requestAnimationFrame para garantir que o DOM foi atualizado
194
+ requestAnimationFrame(() => {
195
+ const newPosition = calculatePosition(mouse.x, mouse.y);
196
+ setPosition(newPosition);
197
+ });
198
+ }
199
+ }, [isVisible, height, mouse.x, mouse.y, calculatePosition]);
200
+ return (_jsxs("div", { ref: containerRef, className: cn("relative inline-block", containerClassName), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseMove: handleMouseMove, onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd, onClick: handleClick, children: [children, _jsx(AnimatePresence, { children: isVisible && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height, opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: {
201
+ type: "spring",
202
+ stiffness: 200,
203
+ damping: 20,
204
+ }, role: "tooltip", id: tooltipProps.id, className: cn("pointer-events-none absolute z-50 rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md", className), style: {
205
+ top: position.y,
206
+ left: position.x,
207
+ minWidth: `${minWidth}px`,
208
+ zIndex: 9999,
209
+ overflow: "visible",
210
+ wordWrap: "break-word",
211
+ whiteSpace: "normal",
212
+ }, children: _jsx("div", { ref: contentRef, className: "overflow-visible", style: {
213
+ whiteSpace: "normal",
214
+ wordWrap: "break-word",
215
+ overflowWrap: "break-word",
216
+ }, children: content }) }, String(isVisible))) })] }));
217
+ }
35
218
  export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, TooltipPortal };
@@ -0,0 +1,29 @@
1
+ import type { ComboBoxState } from "@react-stately/combobox";
2
+ import type { ListState } from "@react-stately/list";
3
+ import * as React from "react";
4
+ export interface AutocompleteOption {
5
+ value: string;
6
+ label: string;
7
+ disabled?: boolean;
8
+ }
9
+ export interface AutocompleteContextValue {
10
+ state: ComboBoxState<unknown>;
11
+ listState: ListState<unknown>;
12
+ inputRef: React.RefObject<HTMLInputElement | null>;
13
+ listBoxRef: React.RefObject<HTMLUListElement | null>;
14
+ popoverRef: React.RefObject<HTMLDivElement | null>;
15
+ inputProps: React.InputHTMLAttributes<HTMLInputElement>;
16
+ listBoxProps: React.HTMLAttributes<HTMLUListElement>;
17
+ popoverProps: React.HTMLAttributes<HTMLDivElement>;
18
+ handleClear: (e: React.MouseEvent<HTMLButtonElement>) => void;
19
+ size: "sm" | "default" | "lg";
20
+ disabled: boolean;
21
+ maxListboxHeight: string;
22
+ isLoading: boolean;
23
+ emptyMessage: string;
24
+ options?: AutocompleteOption[];
25
+ }
26
+ declare const AutocompleteContext: React.Context<AutocompleteContextValue | null>;
27
+ export declare const useAutocompleteContext: () => AutocompleteContextValue;
28
+ export { AutocompleteContext };
29
+ //# sourceMappingURL=autocomplete-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-context.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/forms/autocomplete/autocomplete-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACnD,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACrD,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,UAAU,EAAE,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IACxD,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACrD,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACnD,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC9D,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED,QAAA,MAAM,mBAAmB,gDAA6D,CAAC;AAEvF,eAAO,MAAM,sBAAsB,gCAMlC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ const AutocompleteContext = React.createContext(null);
3
+ export const useAutocompleteContext = () => {
4
+ const context = React.useContext(AutocompleteContext);
5
+ if (!context) {
6
+ throw new Error("Autocomplete components must be used within Autocomplete");
7
+ }
8
+ return context;
9
+ };
10
+ export { AutocompleteContext };
@@ -0,0 +1,16 @@
1
+ import type { ListState } from "@react-stately/list";
2
+ import * as React from "react";
3
+ type CollectionItem = ReturnType<ListState<unknown>["collection"]["getItem"]>;
4
+ export interface AutocompleteItemProps {
5
+ value?: string;
6
+ disabled?: boolean;
7
+ startContent?: React.ReactNode;
8
+ endContent?: React.ReactNode;
9
+ children?: React.ReactNode;
10
+ className?: string;
11
+ item?: NonNullable<CollectionItem>;
12
+ state?: ListState<unknown>;
13
+ }
14
+ declare const AutocompleteItemComponent: React.ForwardRefExoticComponent<AutocompleteItemProps & React.RefAttributes<HTMLLIElement>>;
15
+ export { AutocompleteItemComponent as AutocompleteItem };
16
+ //# sourceMappingURL=autocomplete-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-item.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/forms/autocomplete/autocomplete-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,KAAK,cAAc,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAE9E,MAAM,WAAW,qBAAqB;IAEpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,IAAI,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,QAAA,MAAM,yBAAyB,6FAiF9B,CAAC;AAIF,OAAO,EAAE,yBAAyB,IAAI,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useOption } from "@react-aria/listbox";
3
+ import { mergeProps } from "@react-aria/utils";
4
+ import { CheckIcon } from "lucide-react";
5
+ import * as React from "react";
6
+ import { cn } from "@/lib/utils";
7
+ import { useAutocompleteContext } from "./autocomplete-context";
8
+ const AutocompleteItemComponent = React.forwardRef(({ className, startContent, endContent, value, disabled, children, item, state, ...props }, ref) => {
9
+ const context = useAutocompleteContext();
10
+ const optionRef = React.useRef(null);
11
+ // Determinar se está usando composição ou API antiga
12
+ const useComposition = value !== undefined || children !== undefined;
13
+ // Sempre usar o contexto para composição, ou state/item para API antiga
14
+ const listStateToUse = useComposition ? context.listState : state;
15
+ const itemKey = useComposition ? value || String(children) : item?.key;
16
+ const isDisabledProp = useComposition ? disabled : item?.props?.isDisabled;
17
+ // Sempre chamar useOption no topo (regra dos hooks)
18
+ // Se não tiver key válido, usar um fallback
19
+ const validKey = itemKey || String(children || value || "");
20
+ const { optionProps: propsFromHook, isSelected: selected, isFocused: focused, isDisabled: disabledState, } = useOption({
21
+ key: validKey,
22
+ isDisabled: isDisabledProp,
23
+ }, listStateToUse, optionRef);
24
+ // Validar se tem os dados necessários
25
+ if (!useComposition && (!item || !state)) {
26
+ throw new Error("AutocompleteItem requires either (value/children) or (item/state)");
27
+ }
28
+ const optionProps = propsFromHook;
29
+ const isSelected = selected;
30
+ const isFocused = focused;
31
+ const isDisabled = disabledState || false;
32
+ const itemChildren = useComposition ? children : item?.props?.children || item?.rendered;
33
+ const mergedRef = React.useMemo(() => {
34
+ if (ref) {
35
+ if (typeof ref === "function") {
36
+ return (node) => {
37
+ ref(node);
38
+ optionRef.current = node;
39
+ };
40
+ }
41
+ return Object.assign(ref, optionRef);
42
+ }
43
+ return optionRef;
44
+ }, [ref]);
45
+ return (_jsxs("li", { ...mergeProps(optionProps, props), ref: mergedRef, className: cn("relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none transition-colors", "focus:bg-accent focus:text-accent-foreground", isSelected && "bg-accent text-accent-foreground", isFocused && !isSelected && "bg-accent/50", isDisabled && "pointer-events-none opacity-50", className), children: [startContent && _jsx("span", { className: "shrink-0", children: startContent }), _jsx("span", { className: "flex-1 truncate", children: itemChildren }), endContent && _jsx("span", { className: "shrink-0", children: endContent }), isSelected && (_jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: _jsx(CheckIcon, { className: "size-4" }) }))] }));
46
+ });
47
+ AutocompleteItemComponent.displayName = "AutocompleteItem";
48
+ export { AutocompleteItemComponent as AutocompleteItem };
@@ -0,0 +1,14 @@
1
+ import type { ListState } from "@react-stately/list";
2
+ import * as React from "react";
3
+ export interface AutocompleteSectionProps {
4
+ state: ListState<unknown>;
5
+ title?: string;
6
+ "aria-label"?: string;
7
+ children?: React.ReactNode;
8
+ className?: string;
9
+ titleClassName?: string;
10
+ separatorClassName?: string;
11
+ }
12
+ declare const AutocompleteSection: React.ForwardRefExoticComponent<AutocompleteSectionProps & React.RefAttributes<HTMLLIElement>>;
13
+ export { AutocompleteSection };
14
+ //# sourceMappingURL=autocomplete-section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-section.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/forms/autocomplete/autocomplete-section.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,QAAA,MAAM,mBAAmB,gGAyCxB,CAAC;AAIF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useListBoxSection } from "@react-aria/listbox";
3
+ import * as React from "react";
4
+ import { cn } from "@/lib/utils";
5
+ const AutocompleteSection = React.forwardRef(({ state: _state, className, titleClassName, separatorClassName, title, "aria-label": ariaLabel, children, ..._props }, ref) => {
6
+ const { itemProps, headingProps, groupProps } = useListBoxSection({
7
+ heading: title,
8
+ "aria-label": ariaLabel,
9
+ });
10
+ return (_jsxs(_Fragment, { children: [title && (_jsx("li", { className: cn("sticky top-0 z-10 bg-popover px-2 py-1.5 text-xs font-semibold text-muted-foreground", separatorClassName), children: _jsx("div", { ...headingProps, className: cn("truncate", titleClassName), children: title }) })), _jsx("li", { ...itemProps, ref: ref, className: cn("list-none", className), children: _jsx("ul", { ...groupProps, className: "list-none p-0", children: children }) })] }));
11
+ });
12
+ AutocompleteSection.displayName = "AutocompleteSection";
13
+ export { AutocompleteSection };
@@ -1,11 +1,7 @@
1
1
  import * as React from "react";
2
- export interface AutocompleteOption {
3
- value: string;
4
- label: string;
5
- disabled?: boolean;
6
- }
7
- export interface AutocompleteProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "value" | "onChange"> {
8
- options: AutocompleteOption[];
2
+ import { type AutocompleteOption } from "./autocomplete-context";
3
+ export interface AutocompleteProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "value" | "onChange" | "defaultValue"> {
4
+ options?: AutocompleteOption[];
9
5
  value?: string;
10
6
  defaultValue?: string;
11
7
  onValueChange?: (value: string | undefined) => void;
@@ -17,7 +13,15 @@ export interface AutocompleteProps extends Omit<React.InputHTMLAttributes<HTMLIn
17
13
  emptyMessage?: string;
18
14
  filterFunction?: (option: AutocompleteOption, searchTerm: string) => boolean;
19
15
  allowCustomValue?: boolean;
16
+ isLoading?: boolean;
17
+ maxListboxHeight?: string;
18
+ children?: React.ReactNode;
20
19
  }
21
- declare const Autocomplete: React.ForwardRefExoticComponent<AutocompleteProps & React.RefAttributes<HTMLInputElement>>;
22
- export { Autocomplete };
20
+ export declare const Autocomplete: React.ForwardRefExoticComponent<AutocompleteProps & React.RefAttributes<HTMLInputElement>> & {
21
+ List: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLUListElement> & React.RefAttributes<HTMLUListElement>>;
22
+ Empty: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
23
+ Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
24
+ Item: React.ForwardRefExoticComponent<import("./autocomplete-item").AutocompleteItemProps & React.RefAttributes<HTMLLIElement>>;
25
+ };
26
+ export type { AutocompleteOption } from "./autocomplete-context";
23
27
  //# sourceMappingURL=autocomplete.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/forms/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;IACxF,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAMD,QAAA,MAAM,YAAY,4FAiNjB,CAAC;AAIF,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/forms/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,wBAAwB,CAAC;AAIhC,MAAM,WAAW,iBACf,SAAQ,IAAI,CACV,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAC3C,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,CAC/C;IAED,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAEpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA0eD,eAAO,MAAM,YAAY;;;;;CAKvB,CAAC;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}